jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/330880 )
Change subject: Add a reason field to both Special:PageLanguage and
ApiSetPageLanguage
......................................................................
Add a reason field to both 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.
Currently, both ApiSetPageLanguage and Special:PageLanguage don't do this.
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, 21 insertions(+), 2 deletions(-)
Approvals:
TTO: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/api/ApiSetPageLanguage.php
b/includes/api/ApiSetPageLanguage.php
index 3f03c02..3ff99f1 100755
--- a/includes/api/ApiSetPageLanguage.php
+++ b/includes/api/ApiSetPageLanguage.php
@@ -84,6 +84,7 @@
$this,
$titleObj,
$params['lang'],
+ $params['reason'] === null ? '' : $params['reason'],
$params['tags'] ?: []
);
@@ -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..d4cd2ac 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,18 +138,24 @@
// 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'] === null ? '' : $data['reason']
+ );
}
/**
* @param IContextSource $context
* @param Title $title
* @param string $newLanguage Language code
+ * @param string $reason Reason for the change
* @param array $tags Change tags to apply to the log entry
* @return Status
*/
public static function changePageLanguage( IContextSource $context,
Title $title,
- $newLanguage, array $tags = [] ) {
+ $newLanguage, $reason, array $tags = [] ) {
// Get the default language for the wiki
$defLang = $context->getConfig()->get( 'LanguageCode' );
@@ -218,6 +230,7 @@
$entry->setPerformer( $context->getUser() );
$entry->setTarget( $title );
$entry->setParameters( $logParams );
+ $entry->setComment( $reason );
$entry->setTags( $tags );
$logid = $entry->insert();
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: merged
Gerrit-Change-Id: I6ae021086e1ec4440d6b2894a1b85d62eb36e172
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: MtDu <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: TTO <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits