From a4c4f6700fcad3ac0ea10e30da3c901d77aa6784 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Tue, 12 Jul 2016 16:02:39 -0700 Subject: [PATCH] Remove uncessary ParserClearState hook The ParserOutput object is already reset when state is reset, so there's no point in setting or unsetting properties on it. And since the only unit test was deleted, remove the hook for that too. Change-Id: Idf12365e8c4b14e527d923edc1086bdaf349df32 --- extension.json | 6 ------ includes/Hooks.php | 36 ------------------------------------ tests/phpunit/HooksTest.php | 34 ---------------------------------- 3 files changed, 76 deletions(-) delete mode 100644 tests/phpunit/HooksTest.php diff --git a/extension.json b/extension.json index afe8d9b1..6fee7f43 100644 --- a/extension.json +++ b/extension.json @@ -20,9 +20,6 @@ "RelatedArticlesMagic": "RelatedArticles.i18n.magic.php" }, "Hooks": { - "UnitTestsList": [ - "RelatedArticles\\Hooks::onUnitTestsList" - ], "ResourceLoaderTestModules": [ "RelatedArticles\\Hooks::onResourceLoaderTestModules" ], @@ -30,9 +27,6 @@ "ParserFirstCallInit": [ "RelatedArticles\\Hooks::onParserFirstCallInit" ], - "ParserClearState": [ - "RelatedArticles\\Hooks::onParserClearState" - ], "OutputPageParserOutput": [ "RelatedArticles\\Hooks::onOutputPageParserOutput" ], diff --git a/includes/Hooks.php b/includes/Hooks.php index ac8fac98..6329e0f9 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -55,27 +55,6 @@ class Hooks { return ''; } - /** - * Handler for the ParserClearState hook. - * - * Empties the internal list so that related pages are not passed on to future - * ParserOutput's - note that {{#related:Foo}} appends and can be used multiple times - * in the page. - * - * @param Parser $parser - * @return boolean Always true - */ - public static function onParserClearState( Parser &$parser ) { - $parserOutput = $parser->getOutput(); - - $parserOutput->setExtensionData( 'RelatedArticles', [] ); - - // FIXME: Remove in 30 days (T115698) - $parserOutput->unsetProperty( 'RelatedArticles' ); - - return true; - } - /** * Passes the related pages list from the cached parser output * object to the output page for rendering. @@ -97,21 +76,6 @@ class Hooks { return true; } - /** - * Handler for the UnitTestsList hook. - * - * Adds the path to this extension's PHPUnit test suite to the set of - * paths. - * - * @param array $paths - * @return boolean Always true - */ - public static function onUnitTestsList( array &$paths ) { - $paths[] = __DIR__ . '/../tests/phpunit'; - - return true; - } - /** * Register QUnit tests. * @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderTestModules diff --git a/tests/phpunit/HooksTest.php b/tests/phpunit/HooksTest.php deleted file mode 100644 index 2297bed4..00000000 --- a/tests/phpunit/HooksTest.php +++ /dev/null @@ -1,34 +0,0 @@ -mOutput = new ParserOutput(); - $relatedPages = [ 'Maybeshewill' ]; - - $parserOutput->setExtensionData( 'RelatedArticles', $relatedPages ); - $parserOutput->setProperty( 'RelatedArticles', $relatedPages ); - - Hooks::onParserClearState( $parser ); - - $this->assertEquals( - [], - $parserOutput->getExtensionData( 'RelatedArticles' ), - 'It clears the list of related pages.' - ); - - $this->assertEquals( - false, - $parserOutput->getProperty( 'RelatedArticles' ), - '[T115698] It unsets the list of related pages that were set as a property.' - ); - } -}