Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 45 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
WebInstallerUpgrade | |
0.00% |
0 / 45 |
|
0.00% |
0 / 3 |
156 | |
0.00% |
0 / 1 |
isSlow | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 28 |
|
0.00% |
0 / 1 |
72 | |||
showDoneMessage | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
12 |
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 | * @ingroup Installer |
20 | */ |
21 | |
22 | namespace MediaWiki\Installer; |
23 | |
24 | class WebInstallerUpgrade extends WebInstallerPage { |
25 | |
26 | /** |
27 | * @return bool Always true. |
28 | */ |
29 | public function isSlow() { |
30 | return true; |
31 | } |
32 | |
33 | /** |
34 | * @return string|null |
35 | */ |
36 | public function execute() { |
37 | if ( $this->getVar( '_UpgradeDone' ) ) { |
38 | // Allow regeneration of LocalSettings.php, unless we are working |
39 | // from a pre-existing LocalSettings.php file and we want to avoid |
40 | // leaking its contents |
41 | if ( $this->parent->request->wasPosted() && !$this->getVar( '_ExistingDBSettings' ) ) { |
42 | // Done message acknowledged |
43 | return 'continue'; |
44 | } |
45 | // Back button click |
46 | // Show the done message again |
47 | // Make them click back again if they want to do the upgrade again |
48 | $this->showDoneMessage(); |
49 | |
50 | return 'output'; |
51 | } |
52 | |
53 | // wgDBtype is generally valid here because otherwise the previous page |
54 | // (connect) wouldn't have declared its happiness |
55 | $type = $this->getVar( 'wgDBtype' ); |
56 | $installer = $this->parent->getDBInstaller( $type ); |
57 | |
58 | if ( !$installer->needsUpgrade() ) { |
59 | return 'skip'; |
60 | } |
61 | |
62 | if ( $this->parent->request->wasPosted() ) { |
63 | $installer->preUpgrade(); |
64 | |
65 | $this->startLiveBox(); |
66 | $result = $installer->doUpgrade(); |
67 | $this->endLiveBox(); |
68 | |
69 | if ( $result ) { |
70 | // If they're going to possibly regenerate LocalSettings, we |
71 | // need to create the upgrade/secret keys. T28481 |
72 | if ( !$this->getVar( '_ExistingDBSettings' ) ) { |
73 | $this->parent->generateKeys(); |
74 | } |
75 | $this->setVar( '_UpgradeDone', true ); |
76 | $this->showDoneMessage(); |
77 | } else { |
78 | $this->startForm(); |
79 | $this->parent->showError( 'config-upgrade-error' ); |
80 | $this->endForm(); |
81 | } |
82 | |
83 | return 'output'; |
84 | } |
85 | |
86 | $this->startForm(); |
87 | $this->addHTML( $this->parent->getInfoBox( |
88 | wfMessage( 'config-can-upgrade', MW_VERSION )->plain() ) ); |
89 | $this->endForm(); |
90 | |
91 | return null; |
92 | } |
93 | |
94 | public function showDoneMessage() { |
95 | $this->startForm(); |
96 | $regenerate = !$this->getVar( '_ExistingDBSettings' ); |
97 | if ( $regenerate ) { |
98 | $msg = 'config-upgrade-done'; |
99 | } else { |
100 | $msg = 'config-upgrade-done-no-regenerate'; |
101 | } |
102 | $this->parent->disableLinkPopups(); |
103 | $this->addHTML( |
104 | $this->parent->getInfoBox( |
105 | wfMessage( $msg, |
106 | $this->getVar( 'wgServer' ) . |
107 | $this->getVar( 'wgScriptPath' ) . '/index.php' |
108 | )->plain(), 'tick-32.png' |
109 | ) |
110 | ); |
111 | $this->parent->restoreLinkPopups(); |
112 | $this->endForm( $regenerate ? 'regenerate' : false, false ); |
113 | } |
114 | |
115 | } |