MtDu has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/330880 )
Change subject: Add a reason field to Special:PageLanguage and ApiSetPageLanguage ...................................................................... Add a reason field to Special:PageLanguage and ApiSetPageLanguage Most MediaWiki actions allow a user to enter a comment/reason for taking the action. This is logged in the change log. However, currently, both ApiSetPageLanguage and Special:PageLanguage do not do thi. This patch fixes this issue. Bug: T154644 Change-Id: I6ae021086e1ec4440d6b2894a1b85d62eb36e172 --- M includes/api/ApiSetPageLanguage.php M includes/api/i18n/en.json M includes/api/i18n/qqq.json M includes/specials/SpecialPageLanguage.php M languages/i18n/en.json M languages/i18n/qqq.json 6 files changed, 22 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/80/330880/1 diff --git a/includes/api/ApiSetPageLanguage.php b/includes/api/ApiSetPageLanguage.php index 3f03c02..1a4a10b 100755 --- a/includes/api/ApiSetPageLanguage.php +++ b/includes/api/ApiSetPageLanguage.php @@ -84,7 +84,8 @@ $this, $titleObj, $params['lang'], - $params['tags'] ?: [] + $params['tags'] ?: [], + $params['reason'] ?: '' ); if ( !$status->isOK() ) { @@ -121,6 +122,7 @@ ), ApiBase::PARAM_REQUIRED => true, ], + 'reason' => null, 'tags' => [ ApiBase::PARAM_TYPE => 'tags', ApiBase::PARAM_ISMULTI => true, diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json index 9915d39..1385097 100644 --- a/includes/api/i18n/en.json +++ b/includes/api/i18n/en.json @@ -1360,6 +1360,7 @@ "apihelp-setpagelanguage-param-title": "Title of the page whose language you wish to change. Cannot be used together with <var>$1pageid</var>.", "apihelp-setpagelanguage-param-pageid": "Page ID of the page whose language you wish to change. Cannot be used together with <var>$1title</var>.", "apihelp-setpagelanguage-param-lang": "Language code of the language to change the page to. Use <kbd>default</kbd> to reset the page to the wiki's default content language.", + "apihelp-setpagelanguage-param-reason": "Reason for the change.", "apihelp-setpagelanguage-param-tags": "Change tags to apply to the log entry resulting from this action.", "apihelp-setpagelanguage-example-language": "Change the language of <kbd>Main Page</kbd> to Basque.", "apihelp-setpagelanguage-example-default": "Change the language of the page with ID 123 to the wiki's default content language.", diff --git a/includes/api/i18n/qqq.json b/includes/api/i18n/qqq.json index c6b14cd..cab2a3e 100644 --- a/includes/api/i18n/qqq.json +++ b/includes/api/i18n/qqq.json @@ -1268,6 +1268,7 @@ "apihelp-setpagelanguage-param-title": "{{doc-apihelp-param|setpagelanguage|title}}", "apihelp-setpagelanguage-param-pageid": "{{doc-apihelp-param|setpagelanguage|pageid}}", "apihelp-setpagelanguage-param-lang": "{{doc-apihelp-param|setpagelanguage|lang}}", + "apihelp-setpagelanguage-param-reason": "{{doc-apihelp-param|setpagelanguage|reason}}", "apihelp-setpagelanguage-param-tags": "{{doc-apihelp-param|setpagelanguage|tags}}", "apihelp-setpagelanguage-example-language": "{{doc-apihelp-example|setpagelanguage}}", "apihelp-setpagelanguage-example-default": "{{doc-apihelp-example|setpagelanguage}}", diff --git a/includes/specials/SpecialPageLanguage.php b/includes/specials/SpecialPageLanguage.php index 8546a08..fa44dd9 100644 --- a/includes/specials/SpecialPageLanguage.php +++ b/includes/specials/SpecialPageLanguage.php @@ -89,6 +89,12 @@ 'default' => $this->getConfig()->get( 'LanguageCode' ), ]; + // Allow user to enter a comment explaining the change + $page['reason'] = [ + 'type' => 'text', + 'label-message' => 'pagelang-reason' + ]; + return $page; } @@ -132,7 +138,12 @@ // Url to redirect to after the operation $this->goToUrl = $title->getFullURL(); - return self::changePageLanguage( $this->getContext(), $title, $newLanguage ); + return self::changePageLanguage( + $this->getContext(), + $title, + $newLanguage, + $data['reason'] ?: '' + ); } /** @@ -140,10 +151,11 @@ * @param Title $title * @param string $newLanguage Language code * @param array $tags Change tags to apply to the log entry + * @param string $reason Reason for the change * @return Status */ public static function changePageLanguage( IContextSource $context, Title $title, - $newLanguage, array $tags = [] ) { + $newLanguage, array $tags = [], $reason ) { // Get the default language for the wiki $defLang = $context->getConfig()->get( 'LanguageCode' ); @@ -219,6 +231,7 @@ $entry->setTarget( $title ); $entry->setParameters( $logParams ); $entry->setTags( $tags ); + $entry->setComment( $reason ); $logid = $entry->insert(); $entry->publish( $logid ); diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 076ce40..4131777 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -4063,6 +4063,7 @@ "pagelang-language": "Language", "pagelang-use-default": "Use default language", "pagelang-select-lang": "Select language", + "pagelang-reason": "Reason", "pagelang-submit": "Submit", "pagelang-nonexistent-page": "The page $1 does not exist.", "pagelang-unchanged-language": "The page $1 is already set to language $2.", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index bf23a1b..78a0f9c 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -4247,6 +4247,7 @@ "pagelang-language": "Language selector label for Special:PageLanguage\n{{Identical|Language}}", "pagelang-use-default": "Radio label for selector on Special:PageLanguage for default language", "pagelang-select-lang": "Radio label for selector on Special:PageLanguage for language selection\n{{Identical|Select language}}", + "pagelang-reason": "Input label for reason on Special:PageLanguage\n\n{{Identical|Reason}}", "pagelang-submit": "Submit button label for Special:PageLanguage form\n{{Identical|Submit}}", "pagelang-nonexistent-page": "Error message shown when the page the user is trying to change the language on does not exist.\n\nParameters:\n* $1 - the title of the nonexistent page", "pagelang-unchanged-language": "Error message shown when the language the user is trying to change the page to and the current language the page is in are the same.\n\nParameters:\n* $1 - the title of the target page\n* $2 - the current language of the page", -- To view, visit https://gerrit.wikimedia.org/r/330880 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6ae021086e1ec4440d6b2894a1b85d62eb36e172 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: MtDu <justin.d...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits