jenkins-bot has submitted this change and it was merged.
Change subject: Prevent patrol footer from appearing on translation pages
......................................................................
Prevent patrol footer from appearing on translation pages
Hooks getUserPermissionsErrors to return false when action is 'patrol'.
Bug: T44162
Change-Id: Ia1ccd346acf92a129b7d094b3085ea45ff321bbf
---
M TranslateHooks.php
M i18n/pagetranslation/en.json
M i18n/pagetranslation/qqq.json
M tag/PageTranslationHooks.php
4 files changed, 31 insertions(+), 0 deletions(-)
Approvals:
Nikerabbit: Looks good to me, approved
jenkins-bot: Verified
diff --git a/TranslateHooks.php b/TranslateHooks.php
index 42d5abe..a49d1a4 100644
--- a/TranslateHooks.php
+++ b/TranslateHooks.php
@@ -141,6 +141,9 @@
// Prevent editing of translation pages directly
$wgHooks['getUserPermissionsErrorsExpensive'][] =
'PageTranslationHooks::preventDirectEditing';
+ // Prevent patroling of translation pages
+ $wgHooks['getUserPermissionsErrors'][] =
+ 'PageTranslationHooks::preventPatrolling';
// Our custom header for translation pages
$wgHooks['ArticleViewHeader'][] =
'PageTranslationHooks::translatablePageHeader';
diff --git a/i18n/pagetranslation/en.json b/i18n/pagetranslation/en.json
index 3dd9793..0562e47 100644
--- a/i18n/pagetranslation/en.json
+++ b/i18n/pagetranslation/en.json
@@ -67,6 +67,7 @@
"tpt-languages-nonzero": "$1 ($2% translated)",
"tpt-tab-translate": "Translate",
"tpt-target-page": "This page cannot be updated manually.\nThis page is
a translation of the page [[$1]] and the translation can be updated using [$2
the translation tool].",
+ "tpt-patrolling-blocked": "This page cannot be patrolled. Instead, use
the translate action to review it.",
"tpt-unknown-page": "This namespace is reserved for content page
translations.\nThe page you are trying to edit does not seem to correspond any
page marked for translation.",
"tpt-translation-restricted": "Translation of this page to this
language has been prevented by a translation administrator.\n\nReason: $1",
"tpt-discouraged-language-force-header": "This page cannot be
translated to $1.",
diff --git a/i18n/pagetranslation/qqq.json b/i18n/pagetranslation/qqq.json
index d9a8bac..029ad73 100644
--- a/i18n/pagetranslation/qqq.json
+++ b/i18n/pagetranslation/qqq.json
@@ -79,6 +79,7 @@
"tpt-languages-nonzero": "Tooltip for a link to go to a translated
version of a translatable page.\n\nParameters:\n* $1 - page title (translated
if present)\n* $2 - translation percentage, without decimals (supports PLURAL)",
"tpt-tab-translate": "Used as label for the tab.\n\nReplaces the edit
tab with translation tab for translation pages.\n{{Identical|Translate}}",
"tpt-target-page": "Message displayed when trying to edit a
translatable page directly. Parameters:\n* $1 is the translatable page\n* $2 is
a link to the translation tool for the translatable page.",
+ "tpt-patrolling-blocked": "Message returned when a user tries to patrol
a translation page directly.",
"tpt-unknown-page": "See [[mw:Help:Extension:Translate/Translation
example]] for context on page translation feature.",
"tpt-translation-restricted": "Error message shown to user when
translation to a language which is restricted by translation
admin.\n\nParameters:\n* $1 - reason",
"tpt-discouraged-language-force-header": "Header for error shown along
with group description if the language is prevented from translation for the
selected language.\n\nParameter:\n* $1 - the language to which the user asked
to translate the page",
diff --git a/tag/PageTranslationHooks.php b/tag/PageTranslationHooks.php
index 7c01e7e..636381c 100644
--- a/tag/PageTranslationHooks.php
+++ b/tag/PageTranslationHooks.php
@@ -595,6 +595,32 @@
}
/**
+ * Prevent patrol links from appearing on translation pages.
+ * Hook: getUserPermissionsErrors
+ *
+ * @param Title $title
+ * @param User $user
+ * @param string $action
+ * @param mixed $result
+ *
+ * @return bool
+ */
+ public static function preventPatrolling( Title $title, User $user,
$action, &$result ) {
+ if ( $action !== 'patrol') {
+ return true;
+ }
+
+ $page = TranslatablePage::isTranslationPage( $title );
+
+ if ( $page !== false ) {
+ $result[] = 'tpt-patrolling-blocked';
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
* Redirects the delete action to our own for translatable pages.
* Hook: ArticleConfirmDelete
*
--
To view, visit https://gerrit.wikimedia.org/r/185101
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia1ccd346acf92a129b7d094b3085ea45ff321bbf
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: NoahM <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: NoahM <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits