mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-23 23:44:53 +00:00
Use $this->getServiceContainer() in maintenance and tests
Use $this->getServiceContainer() instead of MediaWikiServices::getInstance() in maintenance and tests. Change-Id: I845e8f083b19da093166d6551683f2013eec7bb1
This commit is contained in:
parent
e4f2c0e4b0
commit
829003cabf
|
@ -4,7 +4,6 @@ use MediaWiki\Extension\Notifications\AttributeManager;
|
|||
use MediaWiki\Extension\Notifications\DbFactory;
|
||||
use MediaWiki\Extension\Notifications\NotifUser;
|
||||
use MediaWiki\Extension\Notifications\UnreadWikis;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\WikiMap\WikiMap;
|
||||
|
||||
$IP = getenv( 'MW_INSTALL_PATH' );
|
||||
|
@ -25,7 +24,7 @@ class BackfillUnreadWikis extends Maintenance {
|
|||
|
||||
public function execute() {
|
||||
$dbFactory = DbFactory::newFromDefault();
|
||||
$lookup = MediaWikiServices::getInstance()->getCentralIdLookup();
|
||||
$lookup = $this->getServiceContainer()->getCentralIdLookup();
|
||||
|
||||
$rebuild = $this->hasOption( 'rebuild' );
|
||||
if ( $rebuild ) {
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
// @phan-file-suppress PhanUndeclaredClassMethod, PhanUndeclaredClassConstant Other extensions used for testing purposes
|
||||
|
||||
use MediaWiki\Extension\Notifications\Model\Event;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Revision\RevisionRecord;
|
||||
use MediaWiki\Revision\SlotRecord;
|
||||
|
||||
|
@ -214,7 +213,7 @@ class GenerateSampleNotifications extends Maintenance {
|
|||
}
|
||||
|
||||
private function addToPageContent( Title $title, User $agent, $contentText ) {
|
||||
$page = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromTitle( $title );
|
||||
$page = $this->getServiceContainer()->getWikiPageFactory()->newFromTitle( $title );
|
||||
$previousContent = "";
|
||||
$page->loadPageData( WikiPage::READ_LATEST );
|
||||
$revision = $page->getRevisionRecord();
|
||||
|
@ -267,7 +266,7 @@ class GenerateSampleNotifications extends Maintenance {
|
|||
}
|
||||
|
||||
private function generateReverted( User $user, User $agent ) {
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$services = $this->getServiceContainer();
|
||||
$services->getUserGroupManager()->addUserToGroup( $agent, 'sysop' );
|
||||
|
||||
// revert (undo)
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
* @ingroup Maintenance
|
||||
*/
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
require_once getenv( 'MW_INSTALL_PATH' ) !== false
|
||||
? getenv( 'MW_INSTALL_PATH' ) . '/maintenance/Maintenance.php'
|
||||
: __DIR__ . '/../../../maintenance/Maintenance.php';
|
||||
|
@ -31,7 +29,7 @@ class EchoUpdatePerUserBlacklist extends LoggedUpdateMaintenance {
|
|||
}
|
||||
|
||||
public function doDBUpdates() {
|
||||
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
|
||||
$lbFactory = $this->getServiceContainer()->getDBLoadBalancerFactory();
|
||||
$dbw = $this->getDB( DB_PRIMARY );
|
||||
$dbr = $this->getDB( DB_REPLICA );
|
||||
$iterator = new BatchRowIterator(
|
||||
|
@ -52,7 +50,7 @@ class EchoUpdatePerUserBlacklist extends LoggedUpdateMaintenance {
|
|||
|
||||
$this->output( "Updating Echo Notification Blacklist...\n" );
|
||||
|
||||
$centralIdLookup = MediaWikiServices::getInstance()->getCentralIdLookup();
|
||||
$centralIdLookup = $this->getServiceContainer()->getCentralIdLookup();
|
||||
$processed = 0;
|
||||
foreach ( $iterator as $batch ) {
|
||||
foreach ( $batch as $row ) {
|
||||
|
|
|
@ -7,7 +7,6 @@ use MediaWiki\Extension\Notifications\Mapper\TargetPageMapper;
|
|||
use MediaWiki\Extension\Notifications\Model\Event;
|
||||
use MediaWiki\Extension\Notifications\Model\Notification;
|
||||
use MediaWiki\Extension\Notifications\NotifUser;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\User\TalkPageNotificationManager;
|
||||
use MediaWiki\User\UserFactory;
|
||||
use MediaWiki\User\UserGroupManager;
|
||||
|
@ -28,7 +27,7 @@ class NotifUserTest extends MediaWikiIntegrationTestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->cache = new WANObjectCache( [
|
||||
'cache' => MediaWikiServices::getInstance()->getMainObjectStash(),
|
||||
'cache' => $this->getServiceContainer()->getMainObjectStash(),
|
||||
] );
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace MediaWiki\Extension\Notifications\Test;
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWikiIntegrationTestCase;
|
||||
|
||||
/**
|
||||
|
@ -22,7 +21,7 @@ class ServiceWiringTest extends MediaWikiIntegrationTestCase {
|
|||
* @dataProvider provideService
|
||||
*/
|
||||
public function testService( string $name ) {
|
||||
MediaWikiServices::getInstance()->get( $name );
|
||||
$this->getServiceContainer()->get( $name );
|
||||
$this->addToAssertionCount( 1 );
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ use MediaWiki\Extension\Notifications\AttributeManager;
|
|||
use MediaWiki\Extension\Notifications\Push\NotificationServiceClient;
|
||||
use MediaWiki\Extension\Notifications\Push\SubscriptionManager;
|
||||
use MediaWiki\Extension\Notifications\Services;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWikiIntegrationTestCase;
|
||||
|
||||
/**
|
||||
|
@ -24,7 +23,7 @@ class ServicesTest extends MediaWikiIntegrationTestCase {
|
|||
}
|
||||
|
||||
public function testWrap(): void {
|
||||
$services = Services::wrap( MediaWikiServices::getInstance() );
|
||||
$services = Services::wrap( $this->getServiceContainer() );
|
||||
$this->assertInstanceOf( Services::class, $services );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue