* Added a proper Pager::doBatchLookups() function
[lhc/web/wiklou.git] / includes / Block.php
index a59d935..368ab81 100644 (file)
@@ -77,7 +77,7 @@ class Block {
                $this->mAuto = $auto;
                $this->isHardblock( !$anonOnly );
                $this->prevents( 'createaccount', $createAccount );
-               if ( $expiry == 'infinity' || $expiry == Block::infinity() ) {
+               if ( $expiry == 'infinity' || $expiry == wfGetDB( DB_SLAVE )->getInfinity() ) {
                        $this->mExpiry = 'infinity';
                } else {
                        $this->mExpiry = wfTimestamp( TS_MW, $expiry );
@@ -346,13 +346,13 @@ class Block {
        protected function initFromRow( $row ) {
                $this->setTarget( $row->ipb_address );
                $this->setBlocker( User::newFromId( $row->ipb_by ) );
-               
+
                $this->mReason = $row->ipb_reason;
                $this->mTimestamp = wfTimestamp( TS_MW, $row->ipb_timestamp );
                $this->mAuto = $row->ipb_auto;
                $this->mHideName = $row->ipb_deleted;
                $this->mId = $row->ipb_id;
-               
+
                // I wish I didn't have to do this
                $db = wfGetDB( DB_SLAVE );
                if ( $row->ipb_expiry == $db->getInfinity() ) {
@@ -643,7 +643,6 @@ class Block {
                $autoblock->mHideName = $this->mHideName;
                $autoblock->prevents( 'editownusertalk', $this->prevents( 'editownusertalk' ) );
 
-                $dbr = wfGetDB( DB_SLAVE );
                if ( $this->mExpiry == 'infinity' ) {
                        # Original block was indefinite, start an autoblock now
                        $autoblock->mExpiry = Block::getAutoblockExpiry( $timestamp );
@@ -893,7 +892,7 @@ class Block {
         * @param $expiry String: Database expiry format
         * @param $timestampType Int Requested timestamp format
         * @return String
-        * @deprecated since 1.18; use $wgLang->decodeExpiry() instead
+        * @deprecated since 1.18; use $wgLang->formatExpiry() instead
         */
        public static function decodeExpiry( $expiry, $timestampType = TS_MW ) {
                global $wgContLang;
@@ -1058,6 +1057,19 @@ class Block {
                        return array( null, null );
                }
 
+               if ( IP::isValid( $target ) ) {
+                       # We can still create a User if it's an IP address, but we need to turn
+                       # off validation checking (which would exclude IP addresses)
+                       return array(
+                               User::newFromName( IP::sanitizeIP( $target ), false ),
+                               Block::TYPE_IP
+                       );
+
+               } elseif ( IP::isValidBlock( $target ) ) {
+                       # Can't create a User from an IP range
+                       return array( IP::sanitizeRange( $target ), Block::TYPE_RANGE );
+               }
+
                # Consider the possibility that this is not a username at all
                # but actually an old subpage (bug #29797)
                if( strpos( $target, '/' ) !== false ){
@@ -1073,18 +1085,6 @@ class Block {
                        # since hash characters are not valid in usernames or titles generally.
                        return array( $userObj, Block::TYPE_USER );
 
-               } elseif ( IP::isValid( $target ) ) {
-                       # We can still create a User if it's an IP address, but we need to turn
-                       # off validation checking (which would exclude IP addresses)
-                       return array(
-                               User::newFromName( IP::sanitizeIP( $target ), false ),
-                               Block::TYPE_IP
-                       );
-
-               } elseif ( IP::isValidBlock( $target ) ) {
-                       # Can't create a User from an IP range
-                       return array( IP::sanitizeRange( $target ), Block::TYPE_RANGE );
-
                } elseif ( preg_match( '/^#\d+$/', $target ) ) {
                        # Autoblock reference in the form "#12345"
                        return array( substr( $target, 1 ), Block::TYPE_AUTO );