Index: trunk/phase3/includes/installer/WebInstaller.php |
— | — | @@ -163,7 +163,15 @@ |
164 | 164 | # Get the page name. |
165 | 165 | $pageName = $this->request->getVal( 'page' ); |
166 | 166 | |
167 | | - if ( in_array( $pageName, $this->otherPages ) ) { |
| 167 | + # Check LocalSettings status |
| 168 | + $localSettings = $this->getLocalSettingsStatus(); |
| 169 | + |
| 170 | + if( !$localSettings->isGood() && $this->getVar( '_LocalSettingsLocked' ) ) { |
| 171 | + $pageName = 'Locked'; |
| 172 | + $pageId = false; |
| 173 | + $page = $this->getPageByName( $pageName ); |
| 174 | + $page->setLocalSettingsStatus( $localSettings ); |
| 175 | + } elseif ( in_array( $pageName, $this->otherPages ) ) { |
168 | 176 | # Out of sequence |
169 | 177 | $pageId = false; |
170 | 178 | $page = $this->getPageByName( $pageName ); |
— | — | @@ -212,14 +220,8 @@ |
213 | 221 | # Execute the page. |
214 | 222 | $this->currentPageName = $page->getName(); |
215 | 223 | $this->startPageWrapper( $pageName ); |
216 | | - $localSettings = $this->getLocalSettingsStatus(); |
217 | 224 | |
218 | | - if( !$localSettings->isGood() ) { |
219 | | - $this->showStatusBox( $localSettings ); |
220 | | - $result = 'output'; |
221 | | - } else { |
222 | | - $result = $page->execute(); |
223 | | - } |
| 225 | + $result = $page->execute(); |
224 | 226 | |
225 | 227 | $this->endPageWrapper(); |
226 | 228 | |
Index: trunk/phase3/includes/installer/Installer.php |
— | — | @@ -230,10 +230,13 @@ |
231 | 231 | wfRestoreWarnings(); |
232 | 232 | |
233 | 233 | if( $ls ) { |
234 | | - if( $this->getDBInstaller()->needsUpgrade() ) { |
| 234 | + $wgCacheEpoch = $wgCommandLineMode = false; |
| 235 | + require_once( "$IP/LocalSettings.php" ); |
| 236 | + $vars = get_defined_vars(); |
| 237 | + if( isset( $vars['wgUpgradeKey'] ) && $vars['wgUpgradeKey'] ) { |
235 | 238 | $status->warning( 'config-localsettings-upgrade' ); |
236 | | - } |
237 | | - else { |
| 239 | + $this->setVar( '_UpgradeKey', $vars['wgUpgradeKey' ] ); |
| 240 | + } else { |
238 | 241 | $status->fatal( 'config-localsettings-noupgrade' ); |
239 | 242 | } |
240 | 243 | } |
Index: trunk/phase3/includes/installer/CoreInstaller.php |
— | — | @@ -83,6 +83,8 @@ |
84 | 84 | '_Extensions' => array(), |
85 | 85 | '_MemCachedServers' => '', |
86 | 86 | '_ExternalHTTP' => false, |
| 87 | + '_LocalSettingsLocked' => true, |
| 88 | + '_UpgradeKey' => '', |
87 | 89 | ); |
88 | 90 | |
89 | 91 | /** |
Index: trunk/phase3/includes/installer/Installer.i18n.php |
— | — | @@ -16,8 +16,9 @@ |
17 | 17 | 'config-title' => 'MediaWiki $1 installation', |
18 | 18 | 'config-information' => 'Information', |
19 | 19 | 'config-localsettings-upgrade' => "'''Warning''': A <code>LocalSettings.php</code> file has been detected. |
20 | | -Your software is able to upgrade. |
21 | | -Please move <code>LocalSettings.php</code> to somewhere safe and then run the installer again.", |
| 20 | +Your software is able to upgrade. Please fill in the value of <code>\$wgUpgradeKey.php</code> in the box", |
| 21 | + 'config-localsettings-key' => 'Upgrade key:', |
| 22 | + 'config-localsettings-badkey' => 'The key you provided is incorrect', |
22 | 23 | 'config-localsettings-noupgrade' => "'''Error''': A <code>LocalSettings.php</code> file has been detected. |
23 | 24 | Your software is not able to upgrade at this time. |
24 | 25 | The installer has been disabled for security reasons.", |
— | — | @@ -51,6 +52,7 @@ |
52 | 53 | 'config-page-releasenotes' => 'Release notes', |
53 | 54 | 'config-page-copying' => 'Copying', |
54 | 55 | 'config-page-upgradedoc' => 'Upgrading', |
| 56 | + 'config-page-locked' => 'Permission denied', |
55 | 57 | 'config-help-restart' => 'Do you want to clear all saved data that you have entered and restart the installation process?', |
56 | 58 | 'config-restart' => 'Yes, restart it', |
57 | 59 | 'config-welcome' => "=== Environmental checks === |
Index: trunk/phase3/includes/installer/WebInstallerPage.php |
— | — | @@ -102,6 +102,56 @@ |
103 | 103 | |
104 | 104 | } |
105 | 105 | |
| 106 | +class WebInstaller_Locked extends WebInstallerPage { |
| 107 | + |
| 108 | + // The status of Installer::getLocalSettingsStatus() |
| 109 | + private $status; |
| 110 | + |
| 111 | + public function setLocalSettingsStatus( Status $s ) { |
| 112 | + $this->status = $s; |
| 113 | + } |
| 114 | + |
| 115 | + public function execute() { |
| 116 | + $r = $this->parent->request; |
| 117 | + if( !$r->wasPosted() || !$this->status->isOK() ) { |
| 118 | + $this->display(); |
| 119 | + return 'output'; |
| 120 | + } else { |
| 121 | + $key = $r->getText( 'config_wpUpgradeKey' ); |
| 122 | + if( !$key || $key !== $this->getVar( '_UpgradeKey' ) ) { |
| 123 | + $this->display( true ); |
| 124 | + return 'output'; |
| 125 | + } else { |
| 126 | + $this->setVar( '_LocalSettingsLocked', false ); |
| 127 | + return 'continue'; |
| 128 | + } |
| 129 | + } |
| 130 | + } |
| 131 | + |
| 132 | + /** |
| 133 | + * Display stuff to the end user |
| 134 | + * @param $badKey bool Whether the key input by the user was bad |
| 135 | + */ |
| 136 | + private function display( $badKey = false ) { |
| 137 | + $this->startForm(); |
| 138 | + if( $this->status->isOK() && !$this->status->isGood() ) { |
| 139 | + if( $badKey ) { |
| 140 | + $this->parent->showError( 'config-localsettings-badkey' ); |
| 141 | + } |
| 142 | + $this->parent->output->addWikiText( wfMsg( 'config-localsettings-upgrade' ) ); |
| 143 | + $this->addHTML( "<br />" . |
| 144 | + $this->parent->getTextBox( array( |
| 145 | + 'var' => 'wpUpgradeKey', |
| 146 | + 'label' => 'config-localsettings-key', |
| 147 | + ) ) |
| 148 | + ); |
| 149 | + } else { |
| 150 | + $this->parent->showStatusBox( $this->status ); |
| 151 | + } |
| 152 | + $this->endForm(); |
| 153 | + } |
| 154 | +} |
| 155 | + |
106 | 156 | class WebInstaller_Language extends WebInstallerPage { |
107 | 157 | |
108 | 158 | public function execute() { |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -3988,7 +3988,7 @@ |
3989 | 3989 | */ |
3990 | 3990 | $wgReadOnly = null; |
3991 | 3991 | |
3992 | | -/*** |
| 3992 | +/** |
3993 | 3993 | * If this lock file exists (size > 0), the wiki will be forced into read-only mode. |
3994 | 3994 | * Its contents will be shown to users as part of the read-only warning |
3995 | 3995 | * message. |
— | — | @@ -3997,6 +3997,12 @@ |
3998 | 3998 | */ |
3999 | 3999 | $wgReadOnlyFile = false; |
4000 | 4000 | |
| 4001 | +/** |
| 4002 | + * If this is set to some string, this opens up config/index.php for upgrades |
| 4003 | + * when needed. You will need to provide this key to use it |
| 4004 | + */ |
| 4005 | +$wgUpgradeKey = false; |
| 4006 | + |
4001 | 4007 | /** @} */ # End of maintenance } |
4002 | 4008 | |
4003 | 4009 | /************************************************************************//** |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -75,6 +75,8 @@ |
76 | 76 | available as input for other configuration items, either. |
77 | 77 | * Remove $wgRemoteUploads. It was not well supported and superseded by |
78 | 78 | $wgUploadNavigationUrl. |
| 79 | +* $wgUpgradeKey allows unlocking the web installer for upgrades without having |
| 80 | + to move LocalSettings.php |
79 | 81 | |
80 | 82 | === New features in 1.17 === |
81 | 83 | * (bug 10183) Users can now add personal styles and scripts to all skins via |