s7eph4n /
PurgePage
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 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 Parser; |
||
| 29 | use ParserOptions; |
||
| 30 | use PoolWorkArticleView; |
||
| 31 | use Title; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Class PageParseJob |
||
| 35 | * |
||
| 36 | * @package PurgePage |
||
| 37 | * @ingroup ExtensionManager |
||
| 38 | */ |
||
| 39 | class PageParseJob extends Job { |
||
| 40 | |||
| 41 | private $mParserOptions; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Callers should use DuplicateJob::newFromJob() instead |
||
| 45 | * |
||
| 46 | * @param Title $title |
||
| 47 | * @param array $params Job parameters |
||
| 48 | */ |
||
| 49 | function __construct( Title $title, array $params ) { |
||
|
0 ignored issues
–
show
|
|||
| 50 | parent::__construct( 'pageParse', $title, $params ); |
||
| 51 | |||
| 52 | $this->mParserOptions = isset( $params[ 'parseroptions' ] ) ? $params[ 'parseroptions' ] : new ParserOptions(); |
||
| 53 | |||
| 54 | // this does NOT protect against recursion, it only discards duplicate |
||
| 55 | // calls to {{#purge}} on the same page |
||
| 56 | $this->removeDuplicates = true; |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Run the job |
||
| 61 | * @return bool Success |
||
| 62 | */ |
||
| 63 | public function run() { |
||
| 64 | |||
| 65 | $title = $this->getTitle(); |
||
| 66 | |||
| 67 | if ( $title->isContentPage() && $title->exists() ) { |
||
| 68 | |||
| 69 | $wikiPage = \WikiPage::factory( $title ); |
||
| 70 | $pool = new PoolWorkArticleView( $wikiPage, $this->mParserOptions, $wikiPage->getLatest(), false ); |
||
| 71 | $pool->execute(); |
||
| 72 | } |
||
| 73 | |||
| 74 | return true; |
||
| 75 | } |
||
| 76 | } |
||
| 77 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.