Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
CacheUpdateJob
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 run
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace Cognate;
4
5use HTMLCacheUpdateJob;
6use Job;
7use MediaWiki\MediaWikiServices;
8use MediaWiki\Title\Title;
9
10/**
11 * A job that runs on local wikis queuing HTMLCacheUpdateJob internally.
12 *
13 * The creation of the HTMLCacheUpdateJob makes the assumption that when this
14 * job is constructed on the local wiki the Title object contained within has
15 * the pageId for the local wiki and not the wiki that this job was originally
16 * queued from.
17 *
18 * @license GPL-2.0-or-later
19 * @author Addshore
20 */
21class CacheUpdateJob extends Job {
22
23    /**
24     * @param Title $title
25     * @param array $params
26     */
27    public function __construct( Title $title, array $params ) {
28        parent::__construct( 'CognateCacheUpdateJob', $title, $params );
29    }
30
31    public function run(): bool {
32        $title = $this->getTitle();
33
34        $coreJob = new HTMLCacheUpdateJob(
35            $title,
36            [
37                'pages' => [ $title->getArticleID() => [ $title->getNamespace(), $title->getDBkey() ] ],
38            ]
39        );
40
41        MediaWikiServices::getInstance()
42            ->getJobQueueGroup()
43            ->push( $coreJob );
44        return true;
45    }
46
47}