Fix bug in moveTo() with $auth=false and $createRedirect=false
authorCatrope <roan.kattouw@gmail.com>
Thu, 19 Jul 2012 21:22:27 +0000 (14:22 -0700)
committerCatrope <roan.kattouw@gmail.com>
Thu, 19 Jul 2012 22:48:05 +0000 (15:48 -0700)
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

includes/Title.php

index 6ddf6da..4f7984e 100644 (file)
@@ -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 );