2016-12-05 17:45:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace PageImages\Job;
|
|
|
|
|
|
|
|
use Job;
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
use MWExceptionHandler;
|
|
|
|
use RefreshLinks;
|
|
|
|
use Title;
|
|
|
|
|
|
|
|
class InitImageDataJob extends Job {
|
2017-12-06 22:44:34 +00:00
|
|
|
/**
|
|
|
|
* @param Title $title Title object associated with this job
|
2018-04-07 10:07:53 +00:00
|
|
|
* @param array $params Parameters to the job, containing an array of
|
2017-12-06 22:44:34 +00:00
|
|
|
* page ids representing which pages to process
|
|
|
|
*/
|
2016-12-05 17:45:34 +00:00
|
|
|
public function __construct( Title $title, array $params ) {
|
|
|
|
parent::__construct( 'InitImageDataJob', $title, $params );
|
|
|
|
}
|
|
|
|
|
2017-12-06 22:44:34 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2016-12-05 17:45:34 +00:00
|
|
|
public function run() {
|
|
|
|
$lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
|
|
|
|
|
|
|
|
foreach ( $this->params['page_ids'] as $id ) {
|
|
|
|
try {
|
|
|
|
RefreshLinks::fixLinksFromArticle( $id );
|
2016-12-07 18:16:48 +00:00
|
|
|
$lbFactory->waitForReplication();
|
2017-05-30 19:49:44 +00:00
|
|
|
} catch ( \Exception $e ) {
|
2016-12-05 17:45:34 +00:00
|
|
|
// There are some broken pages out there that just don't parse.
|
|
|
|
// Log it and keep on trucking.
|
|
|
|
MWExceptionHandler::logException( $e );
|
|
|
|
}
|
|
|
|
}
|
2018-04-07 10:07:53 +00:00
|
|
|
return true;
|
2016-12-05 17:45:34 +00:00
|
|
|
}
|
|
|
|
}
|