Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
LocalCacheUpdateJob
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 2
12
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 / 6
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2/**
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15 */
16
17namespace MediaWiki\GlobalUserPage;
18
19use MediaWiki\Cache\HTMLCacheUpdater;
20use MediaWiki\JobQueue\Job;
21use MediaWiki\Page\PageReferenceValue;
22use MediaWiki\Title\Title;
23
24/**
25 * A job that runs on local wikis to purge squid and possibly
26 * queue local HTMLCacheUpdate jobs
27 */
28class LocalCacheUpdateJob extends Job {
29    /**
30     * @param array $params Should have 'username' and 'touch' keys
31     */
32    public function __construct(
33        array $params,
34        private readonly HTMLCacheUpdater $htmlCacheUpdater,
35    ) {
36        parent::__construct( 'LocalGlobalUserPageCacheUpdateJob', $params );
37    }
38
39    /** @inheritDoc */
40    public function run() {
41        $title = Title::makeTitleSafe( NS_USER, $this->params['username'] );
42        // We want to purge the cache of the talk page so the tabs change colors
43        $other = PageReferenceValue::localReference( NS_USER_TALK, $this->params['username'] );
44        $this->htmlCacheUpdater->purgeTitleUrls( [ $title, $other ], HTMLCacheUpdater::PURGE_INTENT_TXROUND_REFLECTED );
45        if ( $this->params['touch'] ) {
46            $title->touchLinks();
47        }
48        return true;
49    }
50}