MediaWiki REL1_39
WebInstallerUpgrade.php
Go to the documentation of this file.
1<?php
23
27 public function isSlow() {
28 return true;
29 }
30
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', MW_VERSION )->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}
const MW_VERSION
The running version of MediaWiki.
Definition Defines.php:36
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Abstract class to define pages for the web installer.
setVar( $name, $value)
endForm( $continue='continue', $back='back')
getVar( $var, $default=null)
startLiveBox()
Opens a textarea used to display the progress of a long operation.
endLiveBox()
Opposite to WebInstallerPage::startLiveBox.