Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/303912
Change subject: Implement magic word based opt-out
......................................................................
Implement magic word based opt-out
The current method of opting out via <noinclude> tags is a bit hacky and
has a few problems:
* It requires transcluding the page itself
* Determining opt-out requires a full page parse
* Not re-usable for generic shadow namespaces
Instead, this adds a __NOGLOBAL__ magic word, which if present on the
central user page, will prevent it from being displayed on remote wikis.
Additionally, this is checked when determining whether a link should be
red or blue.
The old way of opt-out still works, but will be removed in the future
after a deprecation period and time for migration to the new magic word.
Bug: T90849
Change-Id: I29a45bb40b16516f15dfff9a445080949b7fb221
---
M GlobalUserPage.body.php
M GlobalUserPage.hooks.php
A GlobalUserPage.i18n.magic.php
M extension.json
4 files changed, 38 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalUserPage
refs/changes/12/303912/1
diff --git a/GlobalUserPage.body.php b/GlobalUserPage.body.php
index bd60d45..aed7664 100644
--- a/GlobalUserPage.body.php
+++ b/GlobalUserPage.body.php
@@ -160,15 +160,28 @@
global $wgGlobalUserPageDBname;
$lb = wfGetLB( $wgGlobalUserPageDBname );
$dbr = $lb->getConnection( DB_SLAVE, array(),
$wgGlobalUserPageDBname );
- $touched = $dbr->selectField(
- 'page',
- 'page_touched',
+ $row = $dbr->selectRow(
+ [ 'page', 'page_props' ],
+ [ 'page_touched', 'pp_propname' ],
array(
'page_namespace' => NS_USER,
- 'page_title' => $user->getUserPage()->getDBkey()
+ 'page_title' =>
$user->getUserPage()->getDBkey(),
),
- __METHOD__
+ __METHOD__,
+ [],
+ [ 'page_props' =>
+ [ 'LEFT JOIN', [ 'page_id=pp_page',
'pp_propname' => 'noglobal' ] ]
+ ]
);
+ if ( $row ) {
+ if ( $row->pp_propname == 'noglobal' ) {
+ $touched = false;
+ } else {
+ $touched = $row->page_touched;
+ }
+ } else {
+ $touched = false;
+ }
$lb->reuseConnection( $dbr );
self::$touchedCache->set( $user->getName(), $touched );
diff --git a/GlobalUserPage.hooks.php b/GlobalUserPage.hooks.php
index b3317bf..1054c06 100644
--- a/GlobalUserPage.hooks.php
+++ b/GlobalUserPage.hooks.php
@@ -156,4 +156,11 @@
return true;
}
+
+ /**
+ * @param array $ids
+ */
+ public static function onGetDoubleUnderscoreIDs( array &$ids ) {
+ $ids[] = 'noglobal';
+ }
}
diff --git a/GlobalUserPage.i18n.magic.php b/GlobalUserPage.i18n.magic.php
new file mode 100644
index 0000000..869cbf3
--- /dev/null
+++ b/GlobalUserPage.i18n.magic.php
@@ -0,0 +1,8 @@
+<?php
+
+$magicWords = array();
+
+$magicWords['en'] = array(
+ 'noglobal' => array( 1, '__NOGLOBAL__' ),
+);
+
diff --git a/extension.json b/extension.json
index ee6e10f..69d4549 100644
--- a/extension.json
+++ b/extension.json
@@ -17,6 +17,9 @@
"i18n"
]
},
+ "ExtensionMessagesFiles": {
+ "GlobalUserPageMagic": "GlobalUserPage.i18n.magic.php"
+ },
"Hooks": {
"GetPreferences": [
"GlobalUserPageHooks::onGetPreferences"
@@ -41,7 +44,8 @@
],
"TitleGetEditNotices": [
"GlobalUserPageHooks::onTitleGetEditNotices"
- ]
+ ],
+ "GetDoubleUnderscoreIDs":
"GlobalUserPageHooks::onGetDoubleUnderscoreIDs"
},
"config": {
"GlobalUserPageCacheExpiry": 604800,
--
To view, visit https://gerrit.wikimedia.org/r/303912
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I29a45bb40b16516f15dfff9a445080949b7fb221
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalUserPage
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits