jenkins-bot has submitted this change and it was merged.
Change subject: Implement ChangeTagCanCreate hook
......................................................................
Implement ChangeTagCanCreate hook
This is to prevent users manually creating tags whose names begin with
"OAuth CID:", as these tags are used by OAuth.
The ChangeTagCanCreate hook was introduced to core in
I77f476c8d0f32c80f720aa2c5e66869c81faa282
Change-Id: I6ab34eabb953709a627054e0b0c50f21adfacac6
---
M OAuth.setup.php
M backend/MWOAuth.hooks.php
M i18n/en.json
M i18n/qqq.json
4 files changed, 24 insertions(+), 2 deletions(-)
Approvals:
Anomie: Looks good to me, approved
jenkins-bot: Verified
diff --git a/OAuth.setup.php b/OAuth.setup.php
index 7c709e7..979f68e 100644
--- a/OAuth.setup.php
+++ b/OAuth.setup.php
@@ -106,6 +106,7 @@
public static function unconditionalSetup() {
global $wgHooks;
+ $wgHooks['ChangeTagCanCreate'][] =
'MediaWiki\Extensions\OAuth\MWOAuthHooks::onChangeTagCanCreate';
$wgHooks['MergeAccountFromTo'][] =
'MediaWiki\Extensions\OAuth\MWOAuthHooks::onMergeAccountFromTo';
$wgHooks['CentralAuthGlobalUserMerged'][] =
'MediaWiki\Extensions\OAuth\MWOAuthHooks::onCentralAuthGlobalUserMerged';
$wgHooks['LoadExtensionSchemaUpdates'][] =
'MediaWiki\Extensions\OAuth\MWOAuthUpdaterHooks::addSchemaUpdates';
diff --git a/backend/MWOAuth.hooks.php b/backend/MWOAuth.hooks.php
index 467d92f..d0dbcb6 100644
--- a/backend/MWOAuth.hooks.php
+++ b/backend/MWOAuth.hooks.php
@@ -6,6 +6,25 @@
* Class containing hooked functions for an OAuth environment
*/
class MWOAuthHooks {
+ /**
+ * Reserve all change tags beginning with 'OAuth CID:'
(case-insensitive) so
+ * that the user may not create them
+ *
+ * @todo Also consume ListDefinedTags and ChangeTagsListActive hooks in
a
+ * sensible way, so OAuth tags don't appear undefined and inactive on
Special:Tags
+ *
+ * @param string $tag
+ * @param \User $user
+ * @param \Status $status
+ * @return bool
+ */
+ public static function onChangeTagCanCreate( $tag, \User $user, \Status
&$status ) {
+ if ( strpos( strtolower( $tag ), 'oauth cid:' ) === 0 ) {
+ $status->fatal( 'mwoauth-tag-reserved' );
+ }
+ return true;
+ }
+
public static function onMergeAccountFromTo( \User $oUser, \User $nUser
) {
global $wgMWOAuthSharedUserIDs;
diff --git a/i18n/en.json b/i18n/en.json
index 07846ee..bbc7400 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -260,5 +260,6 @@
"mwoauth-listgrantrights-summary": "The following is a list of OAuth
grants, with their associated access to user rights. Users can authorize
applications to use their account, but with limited permissions based on the
grants the user gave to the application. An application acting on behalf of a
user cannot actually use rights that the user does not have however.\nThere may
be [[{{MediaWiki:Listgrouprights-helppage}}|additional information]] about
individual rights.",
"mwoauth-listgrants-grant": "Grant",
"mwoauth-listgrants-rights": "Rights",
- "mwoauth-listgrantrights-right-display": "$1 <code>($2)</code>"
+ "mwoauth-listgrantrights-right-display": "$1 <code>($2)</code>",
+ "mwoauth-tag-reserved": "Tags beginning with <code>OAuth CID:</code> are
reserved for use by OAuth."
}
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 498278f..76bf4e8 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -266,5 +266,6 @@
"mwoauth-listgrantrights-summary": "Explanatory text shown at the top
of the grant/rights mapping table.\n\nRefers to
{{msg-mw|Listgrouprights-helppage}}.",
"mwoauth-listgrants-grant": "Used as table header for the grant/rights
mapping table.\n{{Identical|Grant}}",
"mwoauth-listgrants-rights": "Used as table header for the grant/rights
mapping table.\n{{Identical|Right}}",
- "mwoauth-listgrantrights-right-display": "Used to format rights
descriptions on the grant/rights mapping table. Parameters:\n* $1 - ...\n* $2 -
..."
+ "mwoauth-listgrantrights-right-display": "Used to format rights
descriptions on the grant/rights mapping table. Parameters:\n* $1 - ...\n* $2 -
...",
+ "mwoauth-tag-reserved": "Error message displayed on [[Special:Tags]]
when a user attempts to manually create a change tag reserved by OAuth."
}
--
To view, visit https://gerrit.wikimedia.org/r/187330
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6ab34eabb953709a627054e0b0c50f21adfacac6
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/OAuth
Gerrit-Branch: master
Gerrit-Owner: TTO <[email protected]>
Gerrit-Reviewer: Anomie <[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