Skip to content

Commit

Permalink
Use JobSpecification
Browse files Browse the repository at this point in the history
  • Loading branch information
Universal-Omega authored Nov 18, 2024
1 parent 36b7106 commit 3500284
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions includes/HookHandlers/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Miraheze\RottenLinks\HookHandlers;

use JobSpecification;
use MediaWiki\Deferred\LinksUpdate\LinksUpdate;
use MediaWiki\Hook\LinksUpdateCompleteHook;
use MediaWiki\Hook\ParserFirstCallInitHook;
Expand All @@ -11,7 +12,10 @@
use Miraheze\RottenLinks\RottenLinksParserFunctions;
use Wikimedia\Rdbms\IConnectionProvider;

class Main implements LinksUpdateCompleteHook, ParserFirstCallInitHook {
class Main implements
LinksUpdateCompleteHook,
ParserFirstCallInitHook
{

private JobQueueGroupFactory $jobQueueGroupFactory;
private RottenLinksParserFunctions $parserFunctions;
Expand All @@ -35,13 +39,16 @@ public function onLinksUpdateComplete( $linksUpdate, $ticket ) {
$removedExternalLinks = $linksUpdate->getRemovedExternalLinks();

if ( $addedExternalLinks || $removedExternalLinks ) {
$params = [
'addedExternalLinks' => $addedExternalLinks ?? [],
'removedExternalLinks' => $removedExternalLinks ?? [],
];

$jobQueueGroup = $this->jobQueueGroupFactory->makeJobQueueGroup();
$jobQueueGroup->push( new RottenLinksJob( $params ) );
$jobQueueGroup->push(
new JobSpecification(
RottenLinksJob::JOB_NAME,
[
'addedExternalLinks' => $addedExternalLinks ?? [],
'removedExternalLinks' => $removedExternalLinks ?? [],
]
)
);
}
}

Expand Down

0 comments on commit 3500284

Please sign in to comment.