mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-09-23 18:30:06 +00:00
Replace deprecated JobQueueGroup::singleton()
Change-Id: I298d8507f4ec706c235087b726b7b230ed5e9ac6
This commit is contained in:
parent
c9f4e7224f
commit
9bf6ceb738
|
@ -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 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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'
|
||||
];
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 )
|
||||
|
|
Loading…
Reference in a new issue