Added release notes for 'ContentHandler::runLegacyHooks' removal
[mediawiki.git] / includes / installer / WebInstallerUpgrade.php
blob72973e7d2e14fb3607d52538f724d337f2454077
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.
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.
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
18 * @file
19 * @ingroup Deployment
22 class WebInstallerUpgrade extends WebInstallerPage {
24 /**
25 * @return bool Always true.
27 public function isSlow() {
28 return true;
31 /**
32 * @return string|null
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 } else {
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();
48 return 'output';
52 // wgDBtype is generally valid here because otherwise the previous page
53 // (connect) wouldn't have declared its happiness
54 $type = $this->getVar( 'wgDBtype' );
55 $installer = $this->parent->getDBInstaller( $type );
57 if ( !$installer->needsUpgrade() ) {
58 return 'skip';
61 if ( $this->parent->request->wasPosted() ) {
62 $installer->preUpgrade();
64 $this->startLiveBox();
65 $result = $installer->doUpgrade();
66 $this->endLiveBox();
68 if ( $result ) {
69 // If they're going to possibly regenerate LocalSettings, we
70 // need to create the upgrade/secret keys. Bug 26481
71 if ( !$this->getVar( '_ExistingDBSettings' ) ) {
72 $this->parent->generateKeys();
74 $this->setVar( '_UpgradeDone', true );
75 $this->showDoneMessage();
77 return 'output';
81 $this->startForm();
82 $this->addHTML( $this->parent->getInfoBox(
83 wfMessage( 'config-can-upgrade', $GLOBALS['wgVersion'] )->plain() ) );
84 $this->endForm();
86 return null;
89 public function showDoneMessage() {
90 $this->startForm();
91 $regenerate = !$this->getVar( '_ExistingDBSettings' );
92 if ( $regenerate ) {
93 $msg = 'config-upgrade-done';
94 } else {
95 $msg = 'config-upgrade-done-no-regenerate';
97 $this->parent->disableLinkPopups();
98 $this->addHTML(
99 $this->parent->getInfoBox(
100 wfMessage( $msg,
101 $this->getVar( 'wgServer' ) .
102 $this->getVar( 'wgScriptPath' ) . '/index.php'
103 )->plain(), 'tick-32.png'
106 $this->parent->restoreLinkPopups();
107 $this->endForm( $regenerate ? 'regenerate' : false, false );