From 5b1ae8cea0bf27fb3cddb3b5b2d1bedbe43c6d04 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 17 Mar 2016 18:16:18 -0700 Subject: [PATCH] Make spreadAnyEditBlock() calls respect read-only mode Bug: T129968 Change-Id: Ib391bd880fa9e04777a355634035183065de5b0a --- includes/EditPage.php | 15 +++++++++------ includes/user/User.php | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index 32687003c1..520ca57cfe 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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; diff --git a/includes/user/User.php b/includes/user/User.php index 09124bfd61..831966e43c 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -3989,6 +3989,7 @@ class User implements IDBAccessObject { if ( $this->isLoggedIn() && $this->isBlocked() ) { return $this->spreadBlock(); } + return false; } -- 2.20.1