Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 35
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
WebInstallerUpgrade
0.00% covered (danger)
0.00%
0 / 35
0.00% covered (danger)
0.00%
0 / 3
132
0.00% covered (danger)
0.00%
0 / 1
 isSlow
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 execute
0.00% covered (danger)
0.00%
0 / 22
0.00% covered (danger)
0.00%
0 / 1
56
 showDoneMessage
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2/**
3 * @license GPL-2.0-or-later
4 * @file
5 * @ingroup Installer
6 */
7
8namespace MediaWiki\Installer;
9
10class WebInstallerUpgrade extends WebInstallerPage {
11
12    /**
13     * @return bool Always true.
14     */
15    public function isSlow() {
16        return true;
17    }
18
19    /**
20     * @return string|null
21     */
22    public function execute() {
23        if ( $this->getVar( '_UpgradeDone' ) ) {
24            // Allow regeneration of LocalSettings.php, unless we are working
25            // from a pre-existing LocalSettings.php file and we want to avoid
26            // leaking its contents
27            if ( $this->parent->request->wasPosted() && !$this->getVar( '_ExistingDBSettings' ) ) {
28                // Done message acknowledged
29                return 'continue';
30            }
31            // Back button click
32            // Show the done message again
33            // Make them click back again if they want to do the upgrade again
34            $this->showDoneMessage();
35
36            return 'output';
37        }
38
39        if ( !$this->parent->needsUpgrade() ) {
40            return 'skip';
41        }
42
43        if ( $this->parent->request->wasPosted() ) {
44            $this->startLiveBox();
45            $result = $this->parent->doUpgrade();
46            $this->endLiveBox();
47
48            if ( $result ) {
49                $this->showDoneMessage();
50            } else {
51                $this->startForm();
52                $this->parent->showError( 'config-upgrade-error' );
53                $this->endForm();
54            }
55
56            return 'output';
57        }
58
59        $this->startForm();
60        $this->addHTML( $this->parent->getInfoBox(
61            wfMessage( 'config-can-upgrade', MW_VERSION )->plain() ) );
62        $this->endForm();
63
64        return null;
65    }
66
67    public function showDoneMessage() {
68        $this->startForm();
69        $regenerate = !$this->getVar( '_ExistingDBSettings' );
70        if ( $regenerate ) {
71            $msg = 'config-upgrade-done';
72        } else {
73            $msg = 'config-upgrade-done-no-regenerate';
74        }
75        $this->parent->disableLinkPopups();
76        $this->parent->showSuccess(
77            $msg,
78            $this->getVar( 'wgServer' ) . $this->getVar( 'wgScriptPath' ) . '/index.php'
79        );
80        $this->parent->restoreLinkPopups();
81        $this->endForm( $regenerate ? 'regenerate' : false, false );
82    }
83
84}