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