Make spreadAnyEditBlock() calls respect read-only mode
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 18 Mar 2016 01:16:18 +0000 (18:16 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 18 Mar 2016 05:32:53 +0000 (05:32 +0000)
Bug: T129968
Change-Id: Ib391bd880fa9e04777a355634035183065de5b0a

includes/EditPage.php
includes/user/User.php

index 3268700..520ca57 100644 (file)
@@ -530,11 +530,12 @@ class EditPage {
                if ( $permErrors ) {
                        wfDebug( __METHOD__ . ": User can't edit\n" );
                        // Auto-block user's IP if the account was "hard" blocked
-                       $user = $wgUser;
-                       DeferredUpdates::addCallableUpdate( function() use ( $user ) {
-                               $user->spreadAnyEditBlock();
-                       } );
-
+                       if ( !wfReadOnly() ) {
+                               $user = $wgUser;
+                               DeferredUpdates::addCallableUpdate( function () use ( $user ) {
+                                       $user->spreadAnyEditBlock();
+                               } );
+                       }
                        $this->displayPermissionsError( $permErrors );
 
                        return;
@@ -1735,7 +1736,9 @@ class EditPage {
 
                if ( $wgUser->isBlockedFrom( $this->mTitle, false ) ) {
                        // Auto-block user's IP if the account was "hard" blocked
-                       $wgUser->spreadAnyEditBlock();
+                       if ( !wfReadOnly() ) {
+                               $wgUser->spreadAnyEditBlock();
+                       }
                        # Check block state against master, thus 'false'.
                        $status->setResult( false, self::AS_BLOCKED_PAGE_FOR_USER );
                        return $status;
index 09124bf..831966e 100644 (file)
@@ -3989,6 +3989,7 @@ class User implements IDBAccessObject {
                if ( $this->isLoggedIn() && $this->isBlocked() ) {
                        return $this->spreadBlock();
                }
+
                return false;
        }