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
|
|
|
|
* @param array|bool $params Parameters to the job, containing an array of
|
|
|
|
* 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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|