2016-12-05 17:45:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace PageImages\Job;
|
|
|
|
|
|
|
|
use Job;
|
2023-08-19 04:18:19 +00:00
|
|
|
use MediaWiki\Title\Title;
|
2016-12-05 17:45:34 +00:00
|
|
|
use MWExceptionHandler;
|
|
|
|
use RefreshLinks;
|
2023-10-15 12:18:57 +00:00
|
|
|
use Wikimedia\Rdbms\LBFactory;
|
2016-12-05 17:45:34 +00:00
|
|
|
|
|
|
|
class InitImageDataJob extends Job {
|
2023-10-15 12:18:57 +00:00
|
|
|
/** @var LBFactory */
|
|
|
|
private $lbFactory;
|
|
|
|
|
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
|
2023-10-15 12:18:57 +00:00
|
|
|
* @param LBFactory $lbFactory
|
2017-12-06 22:44:34 +00:00
|
|
|
*/
|
2023-10-15 12:18:57 +00:00
|
|
|
public function __construct(
|
|
|
|
Title $title,
|
|
|
|
array $params,
|
|
|
|
LBFactory $lbFactory
|
|
|
|
) {
|
2016-12-05 17:45:34 +00:00
|
|
|
parent::__construct( 'InitImageDataJob', $title, $params );
|
2023-10-15 12:18:57 +00:00
|
|
|
$this->lbFactory = $lbFactory;
|
2016-12-05 17:45:34 +00:00
|
|
|
}
|
|
|
|
|
2017-12-06 22:44:34 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2016-12-05 17:45:34 +00:00
|
|
|
public function run() {
|
|
|
|
foreach ( $this->params['page_ids'] as $id ) {
|
|
|
|
try {
|
|
|
|
RefreshLinks::fixLinksFromArticle( $id );
|
2023-10-15 12:18:57 +00:00
|
|
|
$this->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
|
|
|
}
|
|
|
|
}
|