From: Jackmcbarn Date: Mon, 5 May 2014 18:22:53 +0000 (-0400) Subject: Allow moving category pages X-Git-Tag: 1.31.0-rc.0~15829^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=f14e48f4f9bd83d190464b4e9b8844046f51a192 Allow moving category pages Allow category pages to be moved. This is to preserve attribution of the page only and does not cause pages in the category to recategorize to the new one. A warning explains this when such a move is attempted. The new right move-categorypages is required to do this, which is assigned to user and sysop by default (the same as other move-related rights). The message category-move-redirect-override can be used to cause custom text to be placed on the "old" category page in lieu of a redirect. Bug: 28569 Bug: 5451 Change-Id: Ic93616a54c8e98e3dc71daee3c92c466d64daffc --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index fa153da0d9..e157cab2ca 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4260,6 +4260,7 @@ $wgGroupPermissions['*']['editmyoptions'] = true; $wgGroupPermissions['user']['move'] = true; $wgGroupPermissions['user']['move-subpages'] = true; $wgGroupPermissions['user']['move-rootuserpages'] = true; // can move root userpages +$wgGroupPermissions['user']['move-categorypages'] = true; $wgGroupPermissions['user']['movefile'] = true; $wgGroupPermissions['user']['read'] = true; $wgGroupPermissions['user']['edit'] = true; @@ -4307,6 +4308,7 @@ $wgGroupPermissions['sysop']['importupload'] = true; $wgGroupPermissions['sysop']['move'] = true; $wgGroupPermissions['sysop']['move-subpages'] = true; $wgGroupPermissions['sysop']['move-rootuserpages'] = true; +$wgGroupPermissions['sysop']['move-categorypages'] = true; $wgGroupPermissions['sysop']['patrol'] = true; $wgGroupPermissions['sysop']['autopatrol'] = true; $wgGroupPermissions['sysop']['protect'] = true; diff --git a/includes/Namespace.php b/includes/Namespace.php index 45c2da9cff..4edddbc9b0 100644 --- a/includes/Namespace.php +++ b/includes/Namespace.php @@ -67,7 +67,7 @@ class MWNamespace { public static function isMovable( $index ) { global $wgAllowImageMoving; - $result = !( $index < NS_MAIN || ( $index == NS_FILE && !$wgAllowImageMoving ) || $index == NS_CATEGORY ); + $result = !( $index < NS_MAIN || ( $index == NS_FILE && !$wgAllowImageMoving ) ); /** * @since 1.20 diff --git a/includes/Title.php b/includes/Title.php index 70d2baa5af..b3371ab3f4 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1924,6 +1924,11 @@ class Title { $errors[] = array( 'movenotallowedfile' ); } + // Check if user is allowed to move category pages if it's a category page + if ( $this->mNamespace == NS_CATEGORY && !$user->isAllowed( 'move-categorypages' ) ) { + $errors[] = array( 'cant-move-category-page' ); + } + if ( !$user->isAllowed( 'move' ) ) { // User can't move anything $userCanMove = User::groupHasPermission( 'user', 'move' ); @@ -1943,6 +1948,10 @@ class Title { && $this->mNamespace == NS_USER && !$this->isSubpage() ) { // Show user page-specific message only if the user can move other pages $errors[] = array( 'cant-move-to-user-page' ); + } elseif ( !$user->isAllowed( 'move-categorypages' ) + && $this->mNamespace == NS_CATEGORY ) { + // Show user page-specific message only if the user can move other pages + $errors[] = array( 'cant-move-to-category-page' ); } } elseif ( !$user->isAllowed( $action ) ) { $errors[] = $this->missingPermissionError( $action, $short ); @@ -3812,9 +3821,14 @@ class Title { } if ( $createRedirect ) { - $contentHandler = ContentHandler::getForTitle( $this ); - $redirectContent = $contentHandler->makeRedirectContent( $nt, - wfMessage( 'move-redirect-text' )->inContentLanguage()->plain() ); + if ( $this->getNamespace() == NS_CATEGORY && !wfMessage( 'category-move-redirect-override' )->isDisabled() ) { + $redirectContent = new WikitextContent( + wfMessage( 'category-move-redirect-override' )->params( $nt->getPrefixedText() )->inContentLanguage()->plain() ); + } else { + $contentHandler = ContentHandler::getForTitle( $this ); + $redirectContent = $contentHandler->makeRedirectContent( $nt, + wfMessage( 'move-redirect-text' )->inContentLanguage()->plain() ); + } // NOTE: If this page's content model does not support redirects, $redirectContent will be null. } else { diff --git a/includes/User.php b/includes/User.php index f5768afefd..8228f1c207 100644 --- a/includes/User.php +++ b/includes/User.php @@ -143,6 +143,7 @@ class User { 'minoredit', 'move', 'movefile', + 'move-categorypages', 'move-rootuserpages', 'move-subpages', 'nominornewtalk', diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index 91ef797326..14d671c790 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -163,6 +163,11 @@ class MovePageForm extends UnlistedSpecialPage { "
\n$1\n
", 'moveuserpage-warning' ); + } elseif ( $this->oldTitle->getNamespace() == NS_CATEGORY ) { + $out->wrapWikiMsg( + "
\n$1\n
", + 'movecategorypage-warning' + ); } $out->addWikiMsg( $wgFixDoubleRedirects ? diff --git a/languages/i18n/en.json b/languages/i18n/en.json index a38a4ba052..78b484a2bf 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -1080,6 +1080,7 @@ "right-move": "Move pages", "right-move-subpages": "Move pages with their subpages", "right-move-rootuserpages": "Move root user pages", + "right-move-categorypages": "Move category pages", "right-movefile": "Move files", "right-suppressredirect": "Not create redirects from source pages when moving pages", "right-upload": "Upload files", @@ -1153,6 +1154,7 @@ "action-move": "move this page", "action-move-subpages": "move this page, and its subpages", "action-move-rootuserpages": "move root user pages", + "action-move-categorypages": "move category pages", "action-movefile": "move this file", "action-upload": "upload this file", "action-reupload": "overwrite this existing file", @@ -2173,11 +2175,14 @@ "movepagetalktext": "The associated talk page will be automatically moved along with it unless:\n*A non-empty talk page already exists under the new name, or\n*You uncheck the box below.\n\nIn those cases, you will have to move or merge the page manually if desired.", "movearticle": "Move page:", "moveuserpage-warning": "Warning: You are about to move a user page. Please note that only the page will be moved and the user will not be renamed.", + "movecategorypage-warning": "Warning: You are about to move a category page. Please note that only the page will be moved and any pages in the old category will not be recategorized into the new one.", "movenologintext": "You must be a registered user and [[Special:UserLogin|logged in]] to move a page.", "movenotallowed": "You do not have permission to move pages.", "movenotallowedfile": "You do not have permission to move files.", "cant-move-user-page": "You do not have permission to move user pages (apart from subpages).", "cant-move-to-user-page": "You do not have permission to move a page to a user page (except to a user subpage).", + "cant-move-category-page": "You do not have permission to move category pages.", + "cant-move-to-category-page": "You do not have permission to move a page to a category page.", "newtitle": "To new title:", "move-watch": "Watch source page and target page", "movepagebtn": "Move page", @@ -2201,6 +2206,7 @@ "movenosubpage": "This page has no subpages.", "movereason": "Reason:", "move-redirect-text": "", + "category-move-redirect-override": "-", "revertmove": "revert", "delete_and_move": "Delete and move", "delete_and_move_text": "== Deletion required ==\nThe destination page \"[[:$1]]\" already exists.\nDo you want to delete it to make way for the move?", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 9444a33f76..523461cdd9 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -1242,6 +1242,7 @@ "right-move": "{{doc-right|move}}\nThe right to move any page that is not protected from moving.\n{{Identical|Move page}}", "right-move-subpages": "{{doc-right|move-subpages}}", "right-move-rootuserpages": "{{doc-right|move-rootuserpages}}", + "right-move-categorypages": "{{doc-right|move-categorypages}}", "right-movefile": "{{doc-right|movefile}}", "right-suppressredirect": "{{doc-right|suppressredirect}}", "right-upload": "{{doc-right|upload}}\nThe right to [[Special:Upload|upload]] a file (this includes images, media, audio, ...).\n{{Identical|Upload file}}", @@ -1315,6 +1316,7 @@ "action-move": "{{Doc-action|move}}", "action-move-subpages": "{{Doc-action|move-subpages}}", "action-move-rootuserpages": "{{Doc-action|move-rootuserpages}}", + "action-move-categorypages": "{{Doc-action|move-categorypages}}", "action-movefile": "{{doc-action|movefile}}", "action-upload": "{{Doc-action|upload}}", "action-reupload": "{{Doc-action|reupload}}", @@ -2335,11 +2337,14 @@ "movepagetalktext": "Text on the special 'Move page'. This text only appears if the talk page is not empty.", "movearticle": "The text before the name of the page that you are moving. Can be translated as \"Page that is going to be moved\". Used in [[Special:MovePage]].\n\nSee also:\n* {{msg-mw|move-page-legend|legend for the form}}\n* {{msg-mw|newtitle|label for new title}}\n* {{msg-mw|movereason|label for textarea}}\n* {{msg-mw|movetalk|label for checkbox}}\n* {{msg-mw|move-leave-redirect|label for checkbox}}\n* {{msg-mw|fix-double-redirects|label for checkbox}}\n* {{msg-mw|move-subpages|label for checkbox}}\n* {{msg-mw|move-talk-subpages|label for checkbox}}\n* {{msg-mw|move-watch|label for checkbox}}\n{{Identical|Move page}}", "moveuserpage-warning": "Used as warning in [[Special:MovePage]], when moving a user page.", - "movenologintext": "Text of message on special page 'Permissions Errors', which appears when somebody tries to move a page without being logged in.\n\nSee also:\n* {{msg-mw|cant-move-user-page}}\n* {{msg-mw|cant-move-to-user-page}}\n* {{msg-mw|movenotallowedfile}}\n* {{msg-mw|movenotallowed}}", - "movenotallowed": "Used as error message.\n\nSee also:\n* {{msg-mw|cant-move-user-page}}\n* {{msg-mw|cant-move-to-user-page}}\n* {{msg-mw|movenotallowedfile}}\n* {{msg-mw|movenologintext}}", - "movenotallowedfile": "Used as error message.\n\nSee also:\n* {{msg-mw|cant-move-user-page}}\n* {{msg-mw|cant-move-to-user-page}}\n* {{msg-mw|movenotallowed}}\n* {{msg-mw|movenologintext}}", - "cant-move-user-page": "Used as error message.\n\nSee also:\n* {{msg-mw|cant-move-to-user-page}}\n* {{msg-mw|movenotallowedfile}}\n* {{msg-mw|movenotallowed}}\n* {{msg-mw|movenologintext}}", - "cant-move-to-user-page": "Used as error message.\n\nSee also:\n* {{msg-mw|cant-move-user-page}}\n* {{msg-mw|movenotallowedfile}}\n* {{msg-mw|movenotallowed}}\n* {{msg-mw|movenologintext}}", + "movecategorypage-warning": "Used as warning in [[Special:MovePage]], when moving a category page.", + "movenologintext": "Text of message on special page 'Permissions Errors', which appears when somebody tries to move a page without being logged in.\n\nSee also:\n* {{msg-mw|cant-move-user-page}}\n* {{msg-mw|cant-move-to-user-page}}\n* {{msg-mw|cant-move-category-page}}\n* {{msg-mw|cant-move-to-category-page}}\n* {{msg-mw|movenotallowedfile}}\n* {{msg-mw|movenotallowed}}", + "movenotallowed": "Used as error message.\n\nSee also:\n* {{msg-mw|cant-move-user-page}}\n* {{msg-mw|cant-move-to-user-page}}\n* {{msg-mw|cant-move-category-page}}\n* {{msg-mw|cant-move-to-category-page}}\n* {{msg-mw|movenotallowedfile}}\n* {{msg-mw|movenologintext}}", + "movenotallowedfile": "Used as error message.\n\nSee also:\n* {{msg-mw|cant-move-user-page}}\n* {{msg-mw|cant-move-to-user-page}}\n* {{msg-mw|cant-move-category-page}}\n* {{msg-mw|cant-move-to-category-page}}\n* {{msg-mw|movenotallowed}}\n* {{msg-mw|movenologintext}}", + "cant-move-user-page": "Used as error message.\n\nSee also:\n* {{msg-mw|cant-move-to-user-page}}\n* {{msg-mw|cant-move-category-page}}\n* {{msg-mw|cant-move-to-category-page}}\n* {{msg-mw|movenotallowedfile}}\n* {{msg-mw|movenotallowed}}\n* {{msg-mw|movenologintext}}", + "cant-move-to-user-page": "Used as error message.\n\nSee also:\n* {{msg-mw|cant-move-user-page}}\n* {{msg-mw|cant-move-category-page}}\n* {{msg-mw|cant-move-to-category-page}}\n* {{msg-mw|movenotallowedfile}}\n* {{msg-mw|movenotallowed}}\n* {{msg-mw|movenologintext}}", + "cant-move-category-page": "Used as error message.\n\nSee also:\n* {{msg-mw|cant-move-user-page}}\n* {{msg-mw|cant-move-to-user-page}}\n* {{msg-mw|cant-move-to-category-page}}\n* {{msg-mw|movenotallowedfile}}\n* {{msg-mw|movenotallowed}}\n* {{msg-mw|movenologintext}}", + "cant-move-to-category-page": "Used as error message.\n\nSee also:\n* {{msg-mw|cant-move-user-page}}\n* {{msg-mw|cant-move-to-user-page}}\n* {{msg-mw|cant-move-category-page}}\n* {{msg-mw|movenotallowedfile}}\n* {{msg-mw|movenotallowed}}\n* {{msg-mw|movenologintext}}", "newtitle": "Used in the special page \"[[Special:MovePage]]\". The text for the inputbox to give the new page title.\n\nSee also:\n* {{msg-mw|Move-page-legend|legend for the form}}\n* {{msg-mw|Movearticle|label for old title}}\n* {{msg-mw|Movereason|label for textarea}}\n* {{msg-mw|Movetalk|label for checkbox}}\n* {{msg-mw|Move-leave-redirect|label for checkbox}}\n* {{msg-mw|Fix-double-redirects|label for checkbox}}\n* {{msg-mw|Move-subpages|label for checkbox}}\n* {{msg-mw|Move-talk-subpages|label for checkbox}}\n* {{msg-mw|Move-watch|label for checkbox}}", "move-watch": "The text of the checkbox to watch the pages you are moving from and to. If checked, both the destination page and the original page will be added to the watchlist, even if you decide not to leave a redirect behind.\n\nSee also:\n* {{msg-mw|Move-page-legend|legend for the form}}\n* {{msg-mw|Movearticle|label for old title}}\n* {{msg-mw|Newtitle|label for new title}}\n* {{msg-mw|Movereason|label for textarea}}\n* {{msg-mw|Movetalk|label for checkbox}}\n* {{msg-mw|Move-leave-redirect|label for checkbox}}\n* {{msg-mw|Fix-double-redirects|label for checkbox}}\n* {{msg-mw|Move-subpages|label for checkbox}}\n* {{msg-mw|Move-talk-subpages|label for checkbox}}", "movepagebtn": "Button label on the special 'Move page'.\n\n{{Identical|Move page}}", @@ -2363,6 +2368,7 @@ "movenosubpage": "See also:\n* {{msg-mw|movesubpage|section header}}\n* {{msg-mw|movenosubpage|without subpage}}\n* {{msg-mw|movesubpagetext|with subpages}}", "movereason": "Used in [[Special:MovePage]]. The text for the inputbox to give a reason for the page move.\n\nSee also:\n* {{msg-mw|Move-page-legend|legend for the form}}\n* {{msg-mw|Movearticle|label for old title}}\n* {{msg-mw|Newtitle|label for new title}}\n* {{msg-mw|Movetalk|label for checkbox}}\n* {{msg-mw|Move-leave-redirect|label for checkbox}}\n* {{msg-mw|Fix-double-redirects|label for checkbox}}\n* {{msg-mw|Move-subpages|label for checkbox}}\n* {{msg-mw|Move-talk-subpages|label for checkbox}}\n* {{msg-mw|Move-watch|label for checkbox}}\n{{Identical|Reason}}", "move-redirect-text": "{{ignored}}The text that's added to a redirected page when that redirect is created.", + "category-move-redirect-override": "{{ignored}}The text that's added to a redirected category page when that redirect is created.", "revertmove": "{{Identical|Revert}}", "delete_and_move": "Button text on the move page when the target page already exists.", "delete_and_move_text": "Used when moving a page, but the destination page already exists and needs deletion.\n\nThis message is to confirm that you really want to delete the page.\n\nParameters:\n* $1 - the destination page title\n\nSee also:\n* {{msg-mw|Delete and move confirm}}", diff --git a/maintenance/language/messageTypes.inc b/maintenance/language/messageTypes.inc index 9f73c8047e..10a3745098 100644 --- a/maintenance/language/messageTypes.inc +++ b/maintenance/language/messageTypes.inc @@ -271,6 +271,7 @@ $wgIgnoredMessages = array( 'helplogin-url', 'autocomment-prefix', 'move-redirect-text', + 'category-move-redirect-override', 'interlanguage-link-title-langonly', 'createaccount-hook-abort', ); diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 62d1fa6cbf..b53130b391 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1201,6 +1201,7 @@ $wgMessageStructure = array( 'right-move', 'right-move-subpages', 'right-move-rootuserpages', + 'right-move-categorypages', 'right-movefile', 'right-suppressredirect', 'right-upload', @@ -1279,6 +1280,7 @@ $wgMessageStructure = array( 'action-move', 'action-move-subpages', 'action-move-rootuserpages', + 'action-move-categorypages', 'action-movefile', 'action-upload', 'action-reupload', @@ -2432,11 +2434,14 @@ $wgMessageStructure = array( 'movepagetalktext', 'movearticle', 'moveuserpage-warning', + 'movecategorypage-warning', 'movenologintext', 'movenotallowed', 'movenotallowedfile', 'cant-move-user-page', 'cant-move-to-user-page', + 'cant-move-category-page', + 'cant-move-to-category-page', 'newtitle', 'move-watch', 'movepagebtn', @@ -2460,6 +2465,7 @@ $wgMessageStructure = array( 'movenosubpage', 'movereason', 'move-redirect-text', + 'category-move-redirect-override', 'revertmove', 'delete_and_move', 'delete_and_move_text', diff --git a/tests/phpunit/includes/MWNamespaceTest.php b/tests/phpunit/includes/MWNamespaceTest.php index 49fdd48274..350e83fd27 100644 --- a/tests/phpunit/includes/MWNamespaceTest.php +++ b/tests/phpunit/includes/MWNamespaceTest.php @@ -36,7 +36,7 @@ class MWNamespaceTest extends MediaWikiTestCase { * @covers MWNamespace::isMovable */ public function testIsMovable() { - $this->assertFalse( MWNamespace::isMovable( NS_CATEGORY ) ); + $this->assertFalse( MWNamespace::isMovable( NS_SPECIAL ) ); # @todo FIXME: Write more tests!! }