Replace deprecated JobQueueGroup::singleton()

Change-Id: I298d8507f4ec706c235087b726b7b230ed5e9ac6
This commit is contained in:
Umherirrender 2022-01-25 22:24:53 +01:00
parent c9f4e7224f
commit 9bf6ceb738
5 changed files with 12 additions and 9 deletions

View file

@ -4,7 +4,7 @@ namespace EchoPush;
use EchoEvent;
use EchoServices;
use JobQueueGroup;
use MediaWiki\MediaWikiServices;
use User;
class PushNotifier {
@ -19,7 +19,7 @@ class PushNotifier {
$attributeManager = EchoServices::getInstance()->getAttributeManager();
$userEnabledEvents = $attributeManager->getUserEnabledEvents( $user, 'push' );
if ( in_array( $event->getType(), $userEnabledEvents ) ) {
JobQueueGroup::singleton()->push( self::createJob( $user, $event ) );
MediaWikiServices::getInstance()->getJobQueueGroup()->push( self::createJob( $user, $event ) );
}
}

View file

@ -44,7 +44,7 @@ class ApiEchoArticleReminder extends ApiBase {
[ 'removeDuplicates' => true ],
Title::newFromID( $params['pageid'] )
);
JobQueueGroup::singleton()->push( $job );*/
MediaWikiServices::getInstance()->getJobQueueGroup()->push( $job );*/
$result += [
'result' => 'success'
];

View file

@ -198,7 +198,7 @@ class EchoNotificationController {
'userIds' => $userIds
]
);
JobQueueGroup::singleton()->push( $job );
MediaWikiServices::getInstance()->getJobQueueGroup()->push( $job );
}
/**
@ -240,7 +240,7 @@ class EchoNotificationController {
* @param EchoEvent $event
*/
public static function enqueueEvent( EchoEvent $event ) {
$queue = JobQueueGroup::singleton();
$queue = MediaWikiServices::getInstance()->getJobQueueGroup();
$params = self::getEventParams( $event );
$job = new EchoNotificationJob(

View file

@ -1,5 +1,7 @@
<?php
use MediaWiki\MediaWikiServices;
/**
* This job is created when sending notifications to the target users. The purpose
* of this job is to delete older notifications when the number of notifications a
@ -33,7 +35,7 @@ class EchoNotificationDeleteJob extends Job {
foreach ( $this->params['userIds'] as $userId ) {
$jobs[] = new EchoNotificationDeleteJob( $this->title, [ 'userIds' => [ $userId ] ] );
}
JobQueueGroup::singleton()->push( $jobs );
MediaWikiServices::getInstance()->getJobQueueGroup()->push( $jobs );
return true;
}

View file

@ -278,16 +278,17 @@ class NotificationControllerTest extends MediaWikiIntegrationTestCase {
->method( 'getId' )
->will( $this->returnValue( 42 ) );
EchoNotificationController::enqueueEvent( $event );
$queues = JobQueueGroup::singleton()->getQueuesWithJobs();
$jobQueueGroup = $this->getServiceContainer()->getJobQueueGroup();
$queues = $jobQueueGroup->getQueuesWithJobs();
$this->assertCount( 1, $queues );
$this->assertEquals( 'EchoNotificationJob', $queues[0] );
$job = JobQueueGroup::singleton()->pop( 'EchoNotificationJob' );
$job = $jobQueueGroup->pop( 'EchoNotificationJob' );
$this->assertEquals( 'Test-title', $job->params[ 'title' ] );
$this->assertEquals( 42, $job->params[ 'eventId' ] );
}
public function testNotSupportedDelay() {
$queueGroup = JobQueueGroup::singleton();
$queueGroup = $this->getServiceContainer()->getJobQueueGroup();
$this->assertCount( 0, $queueGroup->getQueuesWithJobs() );
$event = $this->getMockBuilder( EchoEvent::class )