From: Catrope Date: Thu, 19 Jul 2012 21:22:27 +0000 (-0700) Subject: Fix bug in moveTo() with $auth=false and $createRedirect=false X-Git-Tag: 1.31.0-rc.0~22999 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=e23e3a3c79d0cbf092a0dc2698705917b6d7d053;p=lhc%2Fweb%2Fwiklou.git Fix bug in moveTo() with $auth=false and $createRedirect=false Even when $auth=false, moveToInternal() would unconditionally check $wgUser's 'suppressredirect' permissions and override $createRedirect. This means it was impossible to suppress redirect creation when moving pages in a maintenance script, even when telling moveTo() to disable permissions checks. Fixed by moving the check from moveToInternal() up into moveTo() and respecting $auth there Change-Id: I9b52dc67c7ae2dbda3ca62f78d4d7df118771c0f --- diff --git a/includes/Title.php b/includes/Title.php index 6ddf6da4aa..4f7984ef23 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -3474,6 +3474,10 @@ class Title { $wgUser->spreadAnyEditBlock(); return $err; } + // Check suppressredirect permission + if ( $auth && !$wgUser->isAllowed( 'suppressredirect' ) ) { + $createRedirect = true; + } // If it is a file, move it first. // It is done before all other moving stuff is done because it's hard to revert. @@ -3570,8 +3574,8 @@ class Title { * * @param $nt Title the page to move to, which should be a redirect or nonexistent * @param $reason String The reason for the move - * @param $createRedirect Bool Whether to leave a redirect at the old title. Ignored - * if the user doesn't have the suppressredirect right + * @param $createRedirect Bool Whether to leave a redirect at the old title. Does not check + * if the user has the suppressredirect right * @throws MWException */ private function moveToInternal( &$nt, $reason = '', $createRedirect = true ) { @@ -3585,7 +3589,7 @@ class Title { $logType = 'move'; } - $redirectSuppressed = !$createRedirect && $wgUser->isAllowed( 'suppressredirect' ); + $redirectSuppressed = !$createRedirect; $logEntry = new ManualLogEntry( 'move', $logType ); $logEntry->setPerformer( $wgUser );