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