• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Fixed Weird code

Ralle

Active member
#1
I started using XenForo_Helper_Ip in my code and I came across this:

PHP:
// XenForo_Model_Login:

public function clearLoginAttempts($usernameOrEmail, $ipAddress = null)
{
    $ipAddress = XenForo_Helper_Ip::getBinaryIp($ipAddress);

    // ...
}

public function countLoginAttempts($usernameOrEmail, $ipAddress = null)
{
    $ipAddress = XenForo_Helper_Ip::getBinaryIp($ipAddress);

    // ...
}

// XenForo_Helper_Ip:

public static function getBinaryIp(Zend_Controller_Request_Http $request = null, $ip = null, $invalidValue = false)
{
    // ...
}
As you can see, if the clearLoginAttempts actually gets an ipAddress as input, it will pass it as a Zend_Controller_Request_Http. That does not sound right to me. At the very least, the $ipAddress needs to be renamed to $request. I see no place in the codebase where the $ipAddress is ever set, but it is still wrong at some level.
In many other places, you call it with a null at its first argument, but seems like it was forgotten here.