(Bug 17970) {{PROTECTIONLEVEL}} should be able to return the status for pages besides...
[lhc/web/wiklou.git] / includes / Block.php
index afacc43..b81cf3a 100644 (file)
@@ -594,7 +594,7 @@ class Block {
                $res = $dbr->select( 'recentchanges', array( 'rc_ip' ), $conds,
                        __METHOD__ ,  $options );
 
-               if ( !$dbr->numRows( $res ) ) {
+               if ( !$res->numRows() ) {
                        # No results, don't autoblock anything
                        wfDebug( "No IP found to retroactively autoblock\n" );
                } else {
@@ -696,7 +696,7 @@ class Block {
                wfDebug( "Autoblocking {$this->getTarget()}@" . $autoblockIP . "\n" );
                $autoblock->setTarget( $autoblockIP );
                $autoblock->setBlocker( $this->getBlocker() );
-               $autoblock->mReason = wfMessage( 'autoblocker', $this->getTarget(), $this->mReason )->inContentLanguage()->text();
+               $autoblock->mReason = wfMessage( 'autoblocker', $this->getTarget(), $this->mReason )->inContentLanguage()->plain();
                $timestamp = wfTimestampNow();
                $autoblock->mTimestamp = $timestamp;
                $autoblock->mAuto = 1;
@@ -997,9 +997,11 @@ class Block {
         * Purge expired blocks from the ipblocks table
         */
        public static function purgeExpired() {
-               $dbw = wfGetDB( DB_MASTER );
-               $dbw->delete( 'ipblocks',
-                       array( 'ipb_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ), __METHOD__ );
+               if ( !wfReadOnly() ) {
+                       $dbw = wfGetDB( DB_MASTER );
+                       $dbw->delete( 'ipblocks',
+                               array( 'ipb_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ), __METHOD__ );
+               }
        }
 
        /**
@@ -1057,7 +1059,7 @@ class Block {
                        # passed by some callers (bug 29116)
                        return null;
 
-               } elseif( in_array( $type, array( Block::TYPE_USER, Block::TYPE_IP, Block::TYPE_RANGE ) ) ) {
+               } elseif( in_array( $type, array( Block::TYPE_USER, Block::TYPE_IP, Block::TYPE_RANGE, null ) ) ) {
                        $block = new Block();
                        $block->fromMaster( $fromMaster );