Lucas Werkmeister (WMDE) has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/403459 )
Change subject: Gradually enable constraints gadget for all users
......................................................................
Gradually enable constraints gadget for all users
Starting 2018-02-28, we enable the constraints gadget for more and more
users (selected by the first character of their user name), until by
2018-04-04 it’s enabled for all (logged in) users. This is done by
loading a new ResourceLoader module unconditionally which then,
depending on the user name, possibly pulls in the gadget module.
Bug: T184069
Change-Id: If67d053626b85dfb2e870b2720fda689a8ee25b6
---
M extension.json
A modules/rollout/rollout.js
M src/WikibaseQualityConstraintsHooks.php
3 files changed, 66 insertions(+), 1 deletion(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
refs/changes/59/403459/1
diff --git a/extension.json b/extension.json
index 7e5c26b..61eb574 100644
--- a/extension.json
+++ b/extension.json
@@ -21,7 +21,8 @@
"Hooks": {
"LoadExtensionSchemaUpdates":
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onCreateSchema",
"WikibaseChangeNotification":
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onWikibaseChange",
- "ArticlePurge":
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onArticlePurge"
+ "ArticlePurge":
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onArticlePurge",
+ "BeforePageDisplay":
"WikibaseQuality\\ConstraintReport\\WikibaseQualityConstraintsHooks::onBeforePageDisplay"
},
"SpecialPages": {
"ConstraintReport":
"WikibaseQuality\\ConstraintReport\\Specials\\SpecialConstraintReport::newFromGlobalState"
@@ -104,6 +105,9 @@
"wikibase.quality.constraints.ui"
],
"skipFunction": "modules/gadget-skip.js"
+ },
+ "wikibase.quality.constraints.rollout": {
+ "scripts": "modules/rollout/rollout.js"
}
},
"JobClasses": {
diff --git a/modules/rollout/rollout.js b/modules/rollout/rollout.js
new file mode 100644
index 0000000..b8ddb04
--- /dev/null
+++ b/modules/rollout/rollout.js
@@ -0,0 +1,42 @@
+( function( mw ) {
+ 'use strict';
+
+ function isEnabledForUserName( userName, date ) {
+ var threshold, initial, week;
+
+ if ( userName === null ) {
+ // anonymous
+ return false;
+ }
+
+ userName = userName.toLowerCase();
+ initial = userName[ 0 ];
+
+ if ( initial === 'z' ) {
+ week = 0;
+ } else if ( initial >= 'w' && initial < 'z' ) {
+ week = 1;
+ } else if ( initial >= 't' && initial < 'w' ) {
+ week = 2;
+ } else if ( initial >= 'n' && initial < 't' ) {
+ week = 3;
+ } else if ( initial >= 'e' && initial < 'n' ) {
+ week = 4;
+ } else {
+ week = 5;
+ }
+
+ threshold = new Date( Date.UTC(
+ 2018,
+ 3 - 1, // month numbers are zero-based
+ week * 7 // out-of-range values overflow into previous
or next month(s)
+ ) );
+
+ return date.getTime() >= threshold.getTime();
+ }
+
+ if ( isEnabledForUserName( mw.config.get( 'wgUserName' ), new Date() )
) {
+ mw.loader.load( [ 'wikibase.quality.constraints.gadget' ] );
+ }
+
+} )( mediaWiki );
diff --git a/src/WikibaseQualityConstraintsHooks.php
b/src/WikibaseQualityConstraintsHooks.php
index e24a3c8..6ec1447 100644
--- a/src/WikibaseQualityConstraintsHooks.php
+++ b/src/WikibaseQualityConstraintsHooks.php
@@ -7,6 +7,8 @@
use JobQueueGroup;
use JobSpecification;
use MediaWiki\MediaWikiServices;
+use OutputPage;
+use Skin;
use Title;
use Wikibase\Change;
use Wikibase\DataModel\Entity\PropertyId;
@@ -81,4 +83,21 @@
}
}
+ public static function onBeforePageDisplay( OutputPage &$out, Skin
&$skin ) {
+ $repo = WikibaseRepo::getDefaultInstance();
+
+ $lookup = $repo->getEntityNamespaceLookup();
+ $title = $out->getTitle();
+ if ( $title === null ) {
+ return;
+ }
+
+ if (
+ $lookup->isEntityNamespace( $title->getNamespace() ) &&
+ $out->getUser()->isLoggedIn()
+ ) {
+ $out->addModules(
'wikibase.quality.constraints.rollout' );
+ }
+ }
+
}
--
To view, visit https://gerrit.wikimedia.org/r/403459
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If67d053626b85dfb2e870b2720fda689a8ee25b6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Lucas Werkmeister (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits