Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 7 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| InitImageDataJob | |
0.00% |
0 / 7 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| run | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace PageImages\Job; |
| 4 | |
| 5 | use MediaWiki\Exception\MWExceptionHandler; |
| 6 | use MediaWiki\JobQueue\Job; |
| 7 | use RefreshLinks; |
| 8 | use Wikimedia\Rdbms\ILBFactory; |
| 9 | |
| 10 | class InitImageDataJob extends Job { |
| 11 | |
| 12 | /** |
| 13 | * @param array $params Parameters to the job, containing an array of |
| 14 | * page ids representing which pages to process |
| 15 | * @param ILBFactory $lbFactory |
| 16 | */ |
| 17 | public function __construct( |
| 18 | array $params, |
| 19 | private readonly ILBFactory $lbFactory, |
| 20 | ) { |
| 21 | parent::__construct( 'InitImageDataJob', $params ); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * @inheritDoc |
| 26 | */ |
| 27 | public function run() { |
| 28 | foreach ( $this->params['page_ids'] as $id ) { |
| 29 | try { |
| 30 | RefreshLinks::fixLinksFromArticle( $id ); |
| 31 | $this->lbFactory->waitForReplication(); |
| 32 | } catch ( \Exception $e ) { |
| 33 | // There are some broken pages out there that just don't parse. |
| 34 | // Log it and keep on trucking. |
| 35 | MWExceptionHandler::logException( $e ); |
| 36 | } |
| 37 | } |
| 38 | return true; |
| 39 | } |
| 40 | } |