Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 27
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
FixProofreadPagePagesContentModel
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 3
20
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 doDBUpdates
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 1
6
 getUpdateKey
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
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 2 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 along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 */
20
21use ProofreadPage\ProofreadPage;
22
23$IP = getenv( 'MW_INSTALL_PATH' );
24if ( $IP === false ) {
25    $IP = __DIR__ . '/../../..';
26}
27require_once "$IP/maintenance/Maintenance.php";
28
29/**
30 * Set the content model type for Page: pages
31 *
32 * @ingroup ProofreadPage
33 */
34class FixProofreadPagePagesContentModel extends LoggedUpdateMaintenance {
35
36    public function __construct() {
37        parent::__construct();
38
39        $this->addDescription( 'Set the content model type for Page: pages' );
40
41        $this->requireExtension( 'ProofreadPage' );
42    }
43
44    /**
45     * @inheritDoc
46     */
47    public function doDBUpdates() {
48        $db = $this->getDB( DB_PRIMARY );
49        if ( !$db->fieldExists( 'page', 'page_content_model', __METHOD__ ) ) {
50            $this->error( 'page_content_model field of page table does not exists.' );
51            return false;
52        }
53
54        $db->newUpdateQueryBuilder()
55            ->update( 'page' )
56            ->set( [
57                'page_content_model' => CONTENT_MODEL_PROOFREAD_PAGE
58            ] )
59            ->where( [
60                'page_namespace' => ProofreadPage::getPageNamespaceId(),
61                'page_content_model' => CONTENT_MODEL_WIKITEXT
62            ] )
63            ->caller( __METHOD__ )
64            ->execute();
65
66        $this->output( "Update of the content model for Page: pages is done.\n" );
67
68        return true;
69    }
70
71    /**
72     * @inheritDoc
73     */
74    public function getUpdateKey() {
75        return 'FixPagePagesContentModel';
76    }
77
78}
79
80$maintClass = FixProofreadPagePagesContentModel::class;
81require_once RUN_MAINTENANCE_IF_MAIN;