Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/264614
Change subject: User CentralIdLookup instead of LoadGlobalCssJs hook
......................................................................
User CentralIdLookup instead of LoadGlobalCssJs hook
Change-Id: I8b6862e941c342aceb84691f71b1d20fe4f5eaba
---
M GlobalCssJs.hooks.php
M extension.json
D tests/GlobalCssJsHooksTest.php
3 files changed, 12 insertions(+), 45 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalCssJs
refs/changes/14/264614/1
diff --git a/GlobalCssJs.hooks.php b/GlobalCssJs.hooks.php
index 161bf38..96057a5 100644
--- a/GlobalCssJs.hooks.php
+++ b/GlobalCssJs.hooks.php
@@ -57,8 +57,15 @@
static function loadForUser( User $user ) {
$config = self::getConfig()->get( 'GlobalCssJsConfig' );
$wiki = $config['wiki'];
- return $wiki === wfWikiID() || ( $wiki !== false ) &&
- Hooks::run( 'LoadGlobalCssJs', array( $user, $wiki,
wfWikiID() ) );
+ if ( $wiki === wfWikiID() ) {
+ return true;
+ } elseif ( $wiki === false ) {
+ // Not configured, don't load anything
+ return false;
+ }
+
+ $lookup = CentralIdLookup::factory();
+ return $lookup->isAttached( $user ) && $lookup->isAttached(
$user, $wiki );
}
/**
diff --git a/extension.json b/extension.json
index 51d036e..d13a7d8 100644
--- a/extension.json
+++ b/extension.json
@@ -11,6 +11,9 @@
"namemsg": "globalcssjs-extensionname",
"license-name": "GPL-2.0+",
"type": "other",
+ "requires": {
+ "MediaWiki": ">= 1.27.0"
+ },
"Hooks": {
"BeforePageDisplay": [
"GlobalCssJsHooks::onBeforePageDisplay"
diff --git a/tests/GlobalCssJsHooksTest.php b/tests/GlobalCssJsHooksTest.php
deleted file mode 100644
index 83ec95c..0000000
--- a/tests/GlobalCssJsHooksTest.php
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-
-class GlobalCssJsHooksTest extends MediaWikiTestCase {
-
- public static function provideLoadForUser() {
- return array(
- array( false, false, 'Hook not called if "wiki" set to
false' ),
- array( 'wikiid', false, 'Hook not called if "wiki" set
to wfWikiId()' ),
- array( 'somewiki', true, 'Hook called if "wiki" set to
"somewiki"' ),
- );
- }
-
- /**
- * @covers GlobalCssJsHooks::loadForUser
- * @dataProvider provideLoadForUser
- */
- public function testLoadForUser( $wiki, $assert, $desc ) {
- $wiki = $wiki === 'wikiid' ? wfWikiID() : $wiki;
- $us = $this;
-
- $this->setMwGlobals( array(
- 'wgGlobalCssJsConfig' => array(
- 'wiki' => $wiki,
- 'source' => 'fakesource'
- ),
- 'wgHooks' => array(
- 'LoadGlobalCssJs' => array(
- function( $user, $wiki ) use ( $us,
$assert, $desc ) {
- // Check whether the hook was
run, and whether we wanted it to be.
- $us->assertTrue( $assert, $desc
);
- return true;
- },
- )
- )
- ) );
-
- GlobalCssJsHooks::loadForUser( new User );
-
- if ( $assert === false ) {
- $this->assertTrue( true ); // So the test isn't marked
as risky.
- }
- }
-}
--
To view, visit https://gerrit.wikimedia.org/r/264614
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8b6862e941c342aceb84691f71b1d20fe4f5eaba
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GlobalCssJs
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits