Fix access to invalid symbol in Special:Userrights
[lhc/web/wiklou.git] / includes / Block.php
index 5dee23e..c017c6c 100644 (file)
@@ -296,7 +296,7 @@ class Block {
                        $block = self::newFromRow( $row );
 
                        # Don't use expired blocks
-                       if ( $block->deleteIfExpired() ) {
+                       if ( $block->isExpired() ) {
                                continue;
                        }
 
@@ -308,8 +308,8 @@ class Block {
                        if ( $block->getType() == self::TYPE_RANGE ) {
                                # This is the number of bits that are allowed to vary in the block, give
                                # or take some floating point errors
-                               $end = wfBaseconvert( $block->getRangeEnd(), 16, 10 );
-                               $start = wfBaseconvert( $block->getRangeStart(), 16, 10 );
+                               $end = Wikimedia\base_convert( $block->getRangeEnd(), 16, 10 );
+                               $start = Wikimedia\base_convert( $block->getRangeStart(), 16, 10 );
                                $size = log( $end - $start + 1, 2 );
 
                                # This has the nice property that a /32 block is ranked equally with a
@@ -681,10 +681,10 @@ class Block {
        public static function isWhitelistedFromAutoblocks( $ip ) {
                // Try to get the autoblock_whitelist from the cache, as it's faster
                // than getting the msg raw and explode()'ing it.
-
-               $lines = ObjectCache::getMainWANInstance()->getWithSetCallback(
+               $cache = ObjectCache::getMainWANInstance();
+               $lines = $cache->getWithSetCallback(
                        wfMemcKey( 'ipb', 'autoblock', 'whitelist' ),
-                       86400,
+                       $cache::TTL_DAY,
                        function () {
                                return explode( "\n",
                                        wfMessage( 'autoblock_whitelist' )->inContentLanguage()->plain() );
@@ -1021,12 +1021,17 @@ class Block {
                        return;
                }
 
-               $method = __METHOD__;
-               $dbw = wfGetDB( DB_MASTER );
-               $dbw->onTransactionIdle( function () use ( $dbw, $method ) {
-                       $dbw->delete( 'ipblocks',
-                               array( 'ipb_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ), $method );
-               } );
+               DeferredUpdates::addUpdate( new AtomicSectionUpdate(
+                       wfGetDB( DB_MASTER ),
+                       __METHOD__,
+                       function ( IDatabase $dbw, $fname ) {
+                               $dbw->delete(
+                                       'ipblocks',
+                                       array( 'ipb_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ),
+                                       $fname
+                               );
+                       }
+               ) );
        }
 
        /**
@@ -1140,7 +1145,7 @@ class Block {
                $blocks = array();
                foreach ( $rows as $row ) {
                        $block = self::newFromRow( $row );
-                       if ( !$block->deleteIfExpired() ) {
+                       if ( !$block->isExpired() ) {
                                $blocks[] = $block;
                        }
                }