From 30a5b88ea1c62e5b488014a1bbec2c824fa5a553 Mon Sep 17 00:00:00 2001 From: Amir Sarabadani Date: Wed, 27 Dec 2017 13:13:37 +0100 Subject: [PATCH] Use ExtensionRegistry instead of class_exists Bug: T183096 Change-Id: I963704cdcfdbc97727f435eb16998c16c692ed01 --- Hooks.php | 2 +- maintenance/generateSampleNotifications.php | 10 +++------- maintenance/processEchoEmailBatch.php | 4 ---- tests/phpunit/DiscussionParserTest.php | 2 +- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/Hooks.php b/Hooks.php index bd8a98f01..c934f5cc7 100644 --- a/Hooks.php +++ b/Hooks.php @@ -55,7 +55,7 @@ class EchoHooks { } // turn schema off if eventLogging is not enabled - if ( !class_exists( 'EventLogging' ) ) { + if ( !ExtensionRegistry::getInstance()->isLoaded( 'EventLogging' ) ) { foreach ( $wgEchoEventLoggingSchemas as $schema => $property ) { if ( $property['enabled'] ) { $wgEchoEventLoggingSchemas[$schema]['enabled'] = false; diff --git a/maintenance/generateSampleNotifications.php b/maintenance/generateSampleNotifications.php index ed6070c4b..cd0d1618a 100644 --- a/maintenance/generateSampleNotifications.php +++ b/maintenance/generateSampleNotifications.php @@ -60,10 +60,6 @@ class GenerateSampleNotifications extends Maintenance { } public function execute() { - if ( !class_exists( 'EchoHooks' ) ) { - $this->error( "Echo isn't enabled on this wiki\n", 1 ); - } - $user = $this->getOptionUser( 'user' ); $agent = $this->getOptionUser( 'agent' ); $otherUser = $this->getOptionUser( 'other' ); @@ -301,7 +297,7 @@ class GenerateSampleNotifications extends Maintenance { } private function generateContentTranslation( User $user ) { - if ( !class_exists( 'ContentTranslationHooks' ) ) { + if ( !ExtensionRegistry::getInstance()->isLoaded( 'ContentTranslation' ) ) { return; } @@ -387,7 +383,7 @@ class GenerateSampleNotifications extends Maintenance { } private function generateOneEditThanks( User $user, User $agent ) { - if ( !class_exists( 'ThanksHooks' ) ) { + if ( !ExtensionRegistry::getInstance()->isLoaded( 'Thanks' ) ) { return; } // make an edit, thank it once @@ -406,7 +402,7 @@ class GenerateSampleNotifications extends Maintenance { $this->output( "{$agent->getName()} is thanking {$user->getName()} for edit {$revision->getId()} on {$title->getPrefixedText()}\n" ); } private function generateMultipleEditThanks( User $user, User $agent, User $otherUser ) { - if ( !class_exists( 'ThanksHooks' ) ) { + if ( !ExtensionRegistry::getInstance()->isLoaded( 'Thanks' ) ) { return; } // make an edit, thank it twice diff --git a/maintenance/processEchoEmailBatch.php b/maintenance/processEchoEmailBatch.php index 9ad950869..dbb78c34c 100644 --- a/maintenance/processEchoEmailBatch.php +++ b/maintenance/processEchoEmailBatch.php @@ -32,10 +32,6 @@ class ProcessEchoEmailBatch extends Maintenance { public function execute() { global $wgEchoCluster; - if ( !class_exists( 'EchoHooks' ) ) { - $this->error( "Echo isn't enabled on this wiki\n", 1 ); - } - $ignoreConfiguredSchedule = $this->getOption( "ignoreConfiguredSchedule", 0 ); $this->output( "Started processing... \n" ); diff --git a/tests/phpunit/DiscussionParserTest.php b/tests/phpunit/DiscussionParserTest.php index 35da3fae4..24de8bf29 100644 --- a/tests/phpunit/DiscussionParserTest.php +++ b/tests/phpunit/DiscussionParserTest.php @@ -1795,7 +1795,7 @@ TEXT } protected function isParserFunctionsInstalled() { - if ( class_exists( 'ExtParserFunctions' ) ) { + if ( ExtensionRegistry::getInstance()->isLoaded( 'ParserFunctions' ) ) { return true; } else { return "ParserFunctions not enabled";