mediawiki-extensions-PageIm.../includes/Job/InitImageDataJob.php
gerritbot a85ae32a5e Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: I80f2f9cdd569d549de8b403226000bb5c88fcb67
2023-08-19 04:18:19 +00:00

40 lines
982 B
PHP

<?php
namespace PageImages\Job;
use Job;
use MediaWiki\MediaWikiServices;
use MediaWiki\Title\Title;
use MWExceptionHandler;
use RefreshLinks;
class InitImageDataJob extends Job {
/**
* @param Title $title Title object associated with this job
* @param array $params Parameters to the job, containing an array of
* page ids representing which pages to process
*/
public function __construct( Title $title, array $params ) {
parent::__construct( 'InitImageDataJob', $title, $params );
}
/**
* @inheritDoc
*/
public function run() {
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
foreach ( $this->params['page_ids'] as $id ) {
try {
RefreshLinks::fixLinksFromArticle( $id );
$lbFactory->waitForReplication();
} catch ( \Exception $e ) {
// There are some broken pages out there that just don't parse.
// Log it and keep on trucking.
MWExceptionHandler::logException( $e );
}
}
return true;
}
}