Addshore has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/342911 )

Change subject: Use ExtensionFunctions instead of BeforeInitialize hook
......................................................................

Use ExtensionFunctions instead of BeforeInitialize hook

Bug: T160465
Change-Id: Ib47938781b1b6ee8c73ac57aacf1daea8a112f7f
---
M extension.json
M src/InterwikiSortingHooks.php
M tests/phpunit/InterwikiSortingHooksTest.php
3 files changed, 7 insertions(+), 19 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/InterwikiSorting 
refs/changes/11/342911/1

diff --git a/extension.json b/extension.json
index 2df926e..d9a3600 100644
--- a/extension.json
+++ b/extension.json
@@ -24,11 +24,9 @@
                "InterwikiSorting\\InterwikiSortingHooks": 
"src/InterwikiSortingHooks.php",
                "InterwikiSorting\\InterwikiSortingHookHandlers": 
"src/InterwikiSortingHookHandlers.php"
        },
-       "Hooks": {
-               "BeforeInitialize": [
-                       
"InterwikiSorting\\InterwikiSortingHooks::onBeforeInitialize"
-               ]
-       },
+       "ExtensionFunctions": [
+               "InterwikiSorting\\InterwikiSortingHooks::registerHook"
+       ],
        "MessagesDirs": {
                "InterwikiSorting": [
                        "i18n"
diff --git a/src/InterwikiSortingHooks.php b/src/InterwikiSortingHooks.php
index 5db5e21..671d43e 100644
--- a/src/InterwikiSortingHooks.php
+++ b/src/InterwikiSortingHooks.php
@@ -28,9 +28,7 @@
                $handler->doContentAlterParserOutput( $title, $parserOutput );
        }
 
-       public static function onBeforeInitialize(
-               /* Deliberately ignore all params ( We dont need them ) */
-       ) {
+       public static function registerHook() {
                global $wgHooks;
 
                /**
diff --git a/tests/phpunit/InterwikiSortingHooksTest.php 
b/tests/phpunit/InterwikiSortingHooksTest.php
index 2c06d3f..1f36891 100644
--- a/tests/phpunit/InterwikiSortingHooksTest.php
+++ b/tests/phpunit/InterwikiSortingHooksTest.php
@@ -16,21 +16,13 @@
 class InterwikiSortingHooksTest extends MediaWikiTestCase {
 
        public function testHooksAreCorrectlyRegistered() {
-               $initHook = InterwikiSortingHooks::class . 
'::onBeforeInitialize';
-               $finalHook = InterwikiSortingHooks::class. 
'::onContentAlterParserOutput';
-
-               // Make sure the first hook has been registered
-               $this->assertContains( $initHook, Hooks::getHandlers( 
'BeforeInitialize' ) );
-
-               // Fire the init hook which should register the second hook.
-               // In PHP7 we could just do $initHook();
-               InterwikiSortingHooks::onBeforeInitialize();
+               $expectedHook = InterwikiSortingHooks::class. 
'::onContentAlterParserOutput';
 
                // Make sure that the hook has been registered and is at the 
end of the list.
                $onContentAlterParserOutputHooks = Hooks::getHandlers( 
'ContentAlterParserOutput' );
-               $this->assertContains( $finalHook, 
$onContentAlterParserOutputHooks );
+               $this->assertContains( $expectedHook, 
$onContentAlterParserOutputHooks );
                $this->assertEquals(
-                       $finalHook,
+                       $expectedHook,
                        end( $onContentAlterParserOutputHooks ),
                        'Hook should be the last to be fired'
                );

-- 
To view, visit https://gerrit.wikimedia.org/r/342911
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib47938781b1b6ee8c73ac57aacf1daea8a112f7f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/InterwikiSorting
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to