Skip to content

Commit

Permalink
Add replacement for deprecated JobQueueGroup::singleton (#8)
Browse files Browse the repository at this point in the history
* Replace deprecated JobQueueGroup::singleton

ERM29488

* Check mwVersion

* Replace deprecated Hooks::run

* Remove REL1_35 compat

* Bump version

---------

Co-authored-by: hslater <[email protected]>
  • Loading branch information
HamishSlater and hslater authored Aug 22, 2024
1 parent dba0e39 commit 25df5ed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
12 changes: 4 additions & 8 deletions src/HandlerFactory/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace MWStake\MediaWiki\Component\RunJobsTrigger\HandlerFactory;

use Config;
use Hooks;
use MediaWiki\MediaWikiServices;
use MWStake\MediaWiki\Component\RunJobsTrigger\ObjectFactory;

Expand All @@ -30,14 +29,11 @@ public function __construct( $config = null ) {
* @inheritDoc
*/
public function processHandlers( $handlers ) {
$mwVersion = $this->config->get( 'Version' );
$handlerSpecs = [];
if ( version_compare( $mwVersion, '1.35', '>=' ) ) {
$hookContainer = MediaWikiServices::getInstance()->getHookContainer();
$hookContainer->run( 'MWStakeRunJobsTriggerRegisterHandlers', [ &$handlerSpecs ] );
} else {
Hooks::run( 'MWStakeRunJobsTriggerRegisterHandlers', [ &$handlerSpecs ] );
}
MediaWikiServices::getInstance()->getHookContainer()->run(
'MWStakeRunJobsTriggerRegisterHandlers',
[ &$handlerSpecs ]
);
foreach ( $handlerSpecs as $handlerId => $handlerSpec ) {
$handlers[$handlerId] = ObjectFactory::getObjectFromSpec( $handlerSpec );
}
Expand Down
6 changes: 4 additions & 2 deletions src/Runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use DateTime;
use Exception;
use GlobalVarConfig;
use JobQueueGroup;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
use MWStake\MediaWiki\Component\RunJobsTrigger\Job\InvokeRunner;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -129,7 +129,9 @@ public static function runDeferred() {
return;
}

JobQueueGroup::singleton()->push( new InvokeRunner() );
MediaWikiServices::getInstance()->getJobQueueGroupFactory()
->makeJobQueueGroup()
->push( new InvokeRunner() );
}

/**
Expand Down

0 comments on commit 25df5ed

Please sign in to comment.