r27774 - Code Review

From MediaWiki.org

Jump to: navigation, search
Repository:MediaWiki
Revision:r27773 | r27774 (on ViewVC) | r27775 >
Date:11:27, 23 November 2007
Author:catrope
Status:ok
Tags:
Comment:Requiring suppressredirect right to suppress redirect creation
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/Title.php
===================================================================
--- trunk/phase3/includes/Title.php	(revision 27773)
+++ trunk/phase3/includes/Title.php	(revision 27774)
@@ -2193,7 +2193,8 @@
 	 * @param bool $auth indicates whether $wgUser's permissions
 	 * 	should be checked
 	 * @param string $reason The reason for the move
-	 * @param bool $createRedirect Whether to create a redirect from the old title to the new title
+	 * @param bool $createRedirect Whether to create a redirect from the old title to the new title.
+	 *  Ignored if the user doesn't have the suppressredirect right.
 	 * @return mixed true on success, message name on failure
 	 */
 	public function moveTo( &$nt, $auth = true, $reason = '', $createRedirect = true ) {
@@ -2268,10 +2269,11 @@
 	 * @param Title &$nt the page to move to, which should currently
 	 * 	be a redirect
 	 * @param string $reason The reason for the move
-	 * @param bool $createRedirect Whether to leave a redirect at the old title
+	 * @param bool $createRedirect Whether to leave a redirect at the old title.
+	 *  Ignored if the user doesn't have the suppressredirect right
 	 */
 	private function moveOverExistingRedirect( &$nt, $reason = '', $createRedirect = true ) {
-		global $wgUseSquid;
+		global $wgUseSquid, $wgUser;
 		$fname = 'Title::moveOverExistingRedirect';
 		$comment = wfMsgForContent( '1movedto2_redir', $this->getPrefixedText(), $nt->getPrefixedText() );
 
@@ -2309,7 +2311,7 @@
 		$linkCache->clearLink( $nt->getPrefixedDBkey() );
 
 		# Recreate the redirect, this time in the other direction.
-		if($createRedirect)
+		if($createRedirect || !$wgUser->isAllowed('suppressredirect'))
 		{
 			$mwRedir = MagicWord::get( 'redirect' );
 			$redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n";
@@ -2351,9 +2353,10 @@
 	 * @param Title &$nt the new Title
 	 * @param string $reason The reason for the move
 	 * @param bool $createRedirect Whether to create a redirect from the old title to the new title
+	 *  Ignored if the user doesn't have the suppressredirect right
 	 */
 	private function moveToNewTitle( &$nt, $reason = '', $createRedirect = true ) {
-		global $wgUseSquid;
+		global $wgUseSquid, $wgUser;
 		$fname = 'MovePageForm::moveToNewTitle';
 		$comment = wfMsgForContent( '1movedto2', $this->getPrefixedText(), $nt->getPrefixedText() );
 		if ( $reason ) {
@@ -2384,7 +2387,7 @@
 
 		$linkCache->clearLink( $nt->getPrefixedDBkey() );
 
-		if($createRedirect)
+		if($createRedirect || !$wgUser->isAllowed('suppressredirect'))
 		{
 			# Insert redirect
 			$mwRedir = MagicWord::get( 'redirect' );
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 27773)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 27774)
@@ -1097,6 +1097,7 @@
 $wgGroupPermissions['sysop']['ipblock-exempt']	= true;
 $wgGroupPermissions['sysop']['blockemail']      = true;
 $wgGroupPermissions['sysop']['markbotedits']	= true;
+$wgGroupPermissions['sysop']['suppressredirect'] = true;
 
 // Permission to change users' group assignments
 $wgGroupPermissions['bureaucrat']['userrights'] = true;
Views
Toolbox