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

Fixed Weird code

Discussion in 'Resolved Bug Reports' started by Ralle, May 22, 2014.

  1. Ralle

    Ralle Active Member

    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.
     
    Liam W, Jay and Adam Howard like this.
  2. Mike

    Mike XenForo Developer Staff Member

    There are actually 3 references in the login model that are like this, they're all fixed now though. Thanks.
     
    Liam W, Ralle and Adam Howard like this.

Share This Page