1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* File containing the PageParseJob class |
4
|
|
|
* |
5
|
|
|
* @copyright (C) 2016, Stephan Gambke |
6
|
|
|
* @license GNU General Public License, version 2 (or any later version) |
7
|
|
|
* |
8
|
|
|
* This software is free software; you can redistribute it and/or |
9
|
|
|
* modify it under the terms of the GNU General Public License |
10
|
|
|
* as published by the Free Software Foundation; either version 2 |
11
|
|
|
* of the License, or (at your option) any later version. |
12
|
|
|
* |
13
|
|
|
* This software is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
* GNU General Public License for more details. |
17
|
|
|
* |
18
|
|
|
* You should have received a copy of the GNU General Public License |
19
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>. |
20
|
|
|
* |
21
|
|
|
* @file |
22
|
|
|
* @ingroup ExtensionManager |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
namespace PurgePage; |
26
|
|
|
|
27
|
|
|
use Job; |
28
|
|
|
use Language; |
29
|
|
|
use ParserOptions; |
30
|
|
|
use PoolWorkArticleView; |
31
|
|
|
use Title; |
32
|
|
|
use WikiPage; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Class PageParseJob |
36
|
|
|
* |
37
|
|
|
* @package PurgePage |
38
|
|
|
* @ingroup ExtensionManager |
39
|
|
|
*/ |
40
|
|
|
class PageParseJob extends Job { |
41
|
|
|
|
42
|
|
|
private $user; |
43
|
|
|
private $language; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Callers should use DuplicateJob::newFromJob() instead |
47
|
|
|
* |
48
|
|
|
* @param Title $title |
49
|
|
|
* @param array $params Job parameters |
50
|
|
|
*/ |
51
|
|
|
public function __construct( Title $title, array $params ) { |
52
|
|
|
parent::__construct( 'parsePage', $title, $params ); |
53
|
|
|
|
54
|
|
|
$this->user = isset( $params[ 'user' ] ) ? $params[ 'user' ] : null; |
55
|
|
|
$this->language = isset( $params[ 'lang' ] ) ? Language::factory( $params[ 'lang' ] ) : null; |
56
|
|
|
|
57
|
|
|
// this does NOT protect against recursion, it only discards duplicate |
58
|
|
|
// calls to {{#purge}} on the same page |
59
|
|
|
$this->removeDuplicates = true; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Run the job |
64
|
|
|
* @return bool Success |
65
|
|
|
*/ |
66
|
|
|
public function run() { |
67
|
|
|
|
68
|
|
|
$title = $this->getTitle(); |
69
|
|
|
|
70
|
|
|
if ( $title !== null && $title->isContentPage() && $title->exists() ) { |
71
|
|
|
|
72
|
|
|
$wikiPage = WikiPage::factory( $title ); |
73
|
|
|
$parserOptions = new ParserOptions( $this->user, $this->language ); |
74
|
|
|
|
75
|
|
|
$pool = new PoolWorkArticleView( $wikiPage, $parserOptions, $wikiPage->getLatest(), false ); |
76
|
|
|
$pool->execute(); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
return true; |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|