From: Brad Jorsch Date: Mon, 19 Dec 2016 19:03:52 +0000 (-0500) Subject: Title: Fix subpage move error reporting X-Git-Tag: 1.31.0-rc.0~4484^2 X-Git-Url: http://git.cyclocoop.org/fichier?a=commitdiff_plain;h=d5423f43d082654a40ae6c2cf16b9d562944b828;p=lhc%2Fweb%2Fwiklou.git Title: Fix subpage move error reporting Title::moveSubpages() sometimes returns a single message-specifier array and sometimes returns an array of such arrays. This is extremely difficult for a caller to deal with. Since nothing in Gerrit other than ApiMove calls this, let's just fix it. Also, it seems that messages were never created for the errors returned by this method. So let's create them. Change-Id: I4e55483c4476a1bb96c87266a4661871776fbf9b --- diff --git a/includes/Title.php b/includes/Title.php index 64ff5b417b..c4584bd38f 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -3703,23 +3703,28 @@ class Title implements LinkTarget { * @param bool $createRedirect Whether to create redirects from the old subpages to * the new ones Ignored if the user doesn't have the 'suppressredirect' right * @return array Array with old page titles as keys, and strings (new page titles) or - * arrays (errors) as values, or an error array with numeric indices if no pages - * were moved + * getUserPermissionsErrors()-like arrays (errors) as values, or a + * getUserPermissionsErrors()-like error array with numeric indices if + * no pages were moved */ public function moveSubpages( $nt, $auth = true, $reason = '', $createRedirect = true ) { global $wgMaximumMovedPages; // Check permissions if ( !$this->userCan( 'move-subpages' ) ) { - return [ 'cant-move-subpages' ]; + return [ + [ 'cant-move-subpages' ], + ]; } // Do the source and target namespaces support subpages? if ( !MWNamespace::hasSubpages( $this->getNamespace() ) ) { - return [ 'namespace-nosubpages', - MWNamespace::getCanonicalName( $this->getNamespace() ) ]; + return [ + [ 'namespace-nosubpages', MWNamespace::getCanonicalName( $this->getNamespace() ) ], + ]; } if ( !MWNamespace::hasSubpages( $nt->getNamespace() ) ) { - return [ 'namespace-nosubpages', - MWNamespace::getCanonicalName( $nt->getNamespace() ) ]; + return [ + [ 'namespace-nosubpages', MWNamespace::getCanonicalName( $nt->getNamespace() ) ], + ]; } $subpages = $this->getSubpages( $wgMaximumMovedPages + 1 ); @@ -3728,9 +3733,9 @@ class Title implements LinkTarget { foreach ( $subpages as $oldSubpage ) { $count++; if ( $count > $wgMaximumMovedPages ) { - $retval[$oldSubpage->getPrefixedText()] = - [ 'movepage-max-pages', - $wgMaximumMovedPages ]; + $retval[$oldSubpage->getPrefixedText()] = [ + [ 'movepage-max-pages', $wgMaximumMovedPages ], + ]; break; } diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 166140a408..e1fdc42c8e 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -2499,6 +2499,9 @@ "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.", + "cant-move-subpages": "You do not have permission to move subpages.", + "namespace-nosubpages": "Namespace \"$1\" does not allow subpages.", + "movepage-max-pages": "The source page has more than the maximum $1 {{PLURAL:$1|subpage|subpages}}.", "newtitle": "New title:", "move-watch": "Watch source page and target page", "movepagebtn": "Move page", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 15ac91a96d..b0282efa26 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -2683,6 +2683,9 @@ "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}}", + "cant-move-subpages": "Used as an error message.", + "namespace-nosubpages": "Used as an error message. Parameters:\n* $1 - Namespace name.", + "movepage-max-pages": "Used as an error message. Parameters:\n* $1 - Maximum number of subpages allowed.", "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|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|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}}",