Ladsgroup has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/400395 )
Change subject: Use ExtensionRegistry instead of class_exists
......................................................................
Use ExtensionRegistry instead of class_exists
Bug: T183096
Change-Id: I963704cdcfdbc97727f435eb16998c16c692ed01
---
M Hooks.php
M maintenance/generateSampleNotifications.php
M maintenance/processEchoEmailBatch.php
M tests/phpunit/DiscussionParserTest.php
4 files changed, 14 insertions(+), 12 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Echo
refs/changes/95/400395/1
diff --git a/Hooks.php b/Hooks.php
index bd8a98f..e4fccec 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -1,5 +1,6 @@
<?php
+use ExtensionRegistry;
use MediaWiki\Auth\AuthManager;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
@@ -55,7 +56,7 @@
}
// 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 ed6070c..797f4c9 100644
--- a/maintenance/generateSampleNotifications.php
+++ b/maintenance/generateSampleNotifications.php
@@ -60,7 +60,7 @@
}
public function execute() {
- if ( !class_exists( 'EchoHooks' ) ) {
+ if ( !ExtensionRegistry::getInstance()->isLoaded( 'Echo' ) ) {
$this->error( "Echo isn't enabled on this wiki\n", 1 );
}
@@ -301,7 +301,7 @@
}
private function generateContentTranslation( User $user ) {
- if ( !class_exists( 'ContentTranslationHooks' ) ) {
+ if ( !ExtensionRegistry::getInstance()->isLoaded(
'ContentTranslation' ) ) {
return;
}
@@ -350,7 +350,7 @@
}
private function generateOpenStackManager( User $user, User $agent ) {
- if ( !class_exists( 'OpenStackManagerHooks' ) ) {
+ if ( !ExtensionRegistry::getInstance()->isLoaded(
'OpenStackManager' ) ) {
return;
}
@@ -387,7 +387,7 @@
}
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 +406,7 @@
$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
@@ -436,8 +436,8 @@
}
private function generateEducationProgram( User $user, User $agent ) {
- if ( !class_exists( 'EducationProgram\Extension' ) ) {
- $this->output( 'class EducationProgram\Extension not
found' );
+ if ( !ExtensionRegistry::getInstance()->isLoaded(
'EducationProgram' ) ) {
+ $this->output( 'Extension EducationProgram not found' );
return;
}
@@ -472,8 +472,8 @@
}
private function generateWikibase( User $user, User $agent ) {
- if ( !class_exists(
'Wikibase\Client\Hooks\EchoNotificationsHandlers' ) ) {
- $this->output( 'class
Wikibase\Client\Hooks\EchoNotificationsHandlers not found' );
+ if ( !ExtensionRegistry::getInstance()->isLoaded(
'WikibaseClient' ) ) {
+ $this->output( 'Extension WikibaseClient not found' );
return;
}
diff --git a/maintenance/processEchoEmailBatch.php
b/maintenance/processEchoEmailBatch.php
index 9ad9508..c692b53 100644
--- a/maintenance/processEchoEmailBatch.php
+++ b/maintenance/processEchoEmailBatch.php
@@ -32,7 +32,7 @@
public function execute() {
global $wgEchoCluster;
- if ( !class_exists( 'EchoHooks' ) ) {
+ if ( !ExtensionRegistry::getInstance()->isLoaded( 'Echo' ) ) {
$this->error( "Echo isn't enabled on this wiki\n", 1 );
}
diff --git a/tests/phpunit/DiscussionParserTest.php
b/tests/phpunit/DiscussionParserTest.php
index 35da3fa..251265e 100644
--- a/tests/phpunit/DiscussionParserTest.php
+++ b/tests/phpunit/DiscussionParserTest.php
@@ -1,5 +1,6 @@
<?php
+use ExtensionRegistry;
use MediaWiki\MediaWikiServices;
use Wikimedia\ScopedCallback;
use Wikimedia\TestingAccessWrapper;
@@ -1795,7 +1796,7 @@
}
protected function isParserFunctionsInstalled() {
- if ( class_exists( 'ExtParserFunctions' ) ) {
+ if ( ExtensionRegistry::getInstance()->isLoaded(
'ParserFunctions' ) ) {
return true;
} else {
return "ParserFunctions not enabled";
--
To view, visit https://gerrit.wikimedia.org/r/400395
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I963704cdcfdbc97727f435eb16998c16c692ed01
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Echo
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits