Index: trunk/phase3/includes/installer/Installer.i18n.php |
— | — | @@ -301,6 +301,8 @@ |
302 | 302 | |
303 | 303 | '''MyISAM''' may be faster in single-user or read-only installations. |
304 | 304 | MyISAM databases tend to get corrupted more often than InnoDB databases.", |
| 305 | + 'config-mysql-egine-mismatch' => "'''Warning:''' you requested the $1 storage engine, but the existing database uses the $2 engine. |
| 306 | +This upgrade script can't convert it, so it will remain $2.", |
305 | 307 | 'config-mysql-charset' => 'Database character set:', |
306 | 308 | 'config-mysql-binary' => 'Binary', |
307 | 309 | 'config-mysql-utf8' => 'UTF-8', |
— | — | @@ -308,6 +310,8 @@ |
309 | 311 | This is more efficient than MySQL's UTF-8 mode, and allows you to use the full range of Unicode characters. |
310 | 312 | |
311 | 313 | In '''UTF-8 mode''', MySQL will know what character set your data is in, and can present and convert it appropriately, but it will not let you store characters above the [http://en.wikipedia.org/wiki/Mapping_of_Unicode_character_planes Basic Multilingual Plane].", |
| 314 | + 'config-mysql-charset-mismatch' => "'''Warning:''' you requested the $1 schema, but the existing database has the $2 schema. |
| 315 | + This upgrade script can't convert it, so it will remain $2.", |
312 | 316 | 'config-site-name' => 'Name of wiki:', |
313 | 317 | 'config-site-name-help' => "This will appear in the title bar of the browser and in various other places.", |
314 | 318 | 'config-site-name-blank' => 'Enter a site name.', |
Index: trunk/phase3/includes/installer/SqliteInstaller.php |
— | — | @@ -210,5 +210,4 @@ |
211 | 211 | "# SQLite-specific settings |
212 | 212 | \$wgSQLiteDataDir = \"{$dir}\";"; |
213 | 213 | } |
214 | | - |
215 | 214 | } |
\ No newline at end of file |
Index: trunk/phase3/includes/installer/DatabaseInstaller.php |
— | — | @@ -123,11 +123,10 @@ |
124 | 124 | |
125 | 125 | /** |
126 | 126 | * Perform database upgrades |
127 | | - * @todo make abstract |
| 127 | + * |
| 128 | + * @return Boolean |
128 | 129 | */ |
129 | | - /*abstract*/ function doUpgrade() { |
130 | | - return false; |
131 | | - } |
| 130 | + public abstract function doUpgrade(); |
132 | 131 | |
133 | 132 | /** |
134 | 133 | * Allow DB installers a chance to make last-minute changes before installation |
— | — | @@ -139,6 +138,13 @@ |
140 | 139 | } |
141 | 140 | |
142 | 141 | /** |
| 142 | + * Allow DB installers a chance to make checks before upgrade. |
| 143 | + */ |
| 144 | + public function preUpgrade() { |
| 145 | + |
| 146 | + } |
| 147 | + |
| 148 | + /** |
143 | 149 | * Get an array of MW configuration globals that will be configured by this class. |
144 | 150 | */ |
145 | 151 | public function getGlobalNames() { |
Index: trunk/phase3/includes/installer/MysqlInstaller.php |
— | — | @@ -130,13 +130,14 @@ |
131 | 131 | return $status; |
132 | 132 | } |
133 | 133 | |
134 | | - public function doUpgrade() { |
| 134 | + public function preUpgrade() { |
135 | 135 | $status = $this->getConnection(); |
136 | 136 | if ( !$status->isOK() ) { |
137 | 137 | $this->parent->showStatusError( $status ); |
138 | 138 | return; |
139 | 139 | } |
140 | 140 | $conn = $status->value; |
| 141 | + $conn->selectDB( $this->getVar( 'wgDBname' ) ); |
141 | 142 | |
142 | 143 | # Determine existing default character set |
143 | 144 | if ( $conn->tableExists( "revision" ) ) { |
— | — | @@ -164,12 +165,56 @@ |
165 | 166 | $existingEngine = $row->Type; |
166 | 167 | } |
167 | 168 | } |
| 169 | + } else { |
| 170 | + $existingSchema = false; |
| 171 | + $existingEngine = false; |
168 | 172 | } |
169 | | - |
170 | | - // TODO |
| 173 | + |
| 174 | + if ( $existingSchema && $existingSchema != $this->getVar( '_MysqlCharset' ) ) { |
| 175 | + $this->parent->showMessage( 'config-mysql-charset-mismatch', $this->getVar( '_MysqlCharset' ), $existingSchema ); |
| 176 | + $this->setVar( '_MysqlCharset', $existingSchema ); |
| 177 | + } |
| 178 | + if ( $existingEngine && $existingEngine != $this->getVar( '_MysqlEngine' ) ) { |
| 179 | + $this->parent->showMessage( 'config-mysql-egine-mismatch', $this->getVar( '_MysqlEngine' ), $existingEngine ); |
| 180 | + $this->setVar( '_MysqlEngine', $existingEngine ); |
| 181 | + } |
171 | 182 | } |
172 | 183 | |
173 | 184 | /** |
| 185 | + * @todo FIXME: this code is just pure crap for compatibility between |
| 186 | + * old and new code. |
| 187 | + */ |
| 188 | + public function doUpgrade() { |
| 189 | + global $wgDatabase, $wgDBuser, $wgDBpassword; |
| 190 | + |
| 191 | + # Some maintenance scripts like wfGetDB() |
| 192 | + LBFactory::enableBackend(); |
| 193 | + # For do_all_updates() |
| 194 | + $wgDatabase = $this->db; |
| 195 | + # Normal user and password are selected after this step, so for now |
| 196 | + # just copy these two |
| 197 | + $wgDBuser = $this->getVar( '_InstallUser' ); |
| 198 | + $wgDBpassword = $this->getVar( '_InstallPassword' ); |
| 199 | + |
| 200 | + $ret = true; |
| 201 | + |
| 202 | + ob_start( array( __CLASS__, 'outputHandler' ) ); |
| 203 | + try { |
| 204 | + do_all_updates( false, true ); |
| 205 | + } catch ( MWException $e ) { |
| 206 | + echo "\nAn error occured:\n"; |
| 207 | + echo $e->getText(); |
| 208 | + $ret = false; |
| 209 | + } |
| 210 | + ob_end_flush(); |
| 211 | + return $ret; |
| 212 | + } |
| 213 | + |
| 214 | + public static function outputHandler( $string ) { |
| 215 | + return htmlspecialchars( $string ); |
| 216 | + } |
| 217 | + |
| 218 | + /** |
174 | 219 | * Get a list of storage engines that are available and supported |
175 | 220 | */ |
176 | 221 | public function getEngines() { |
Index: trunk/phase3/includes/installer/OracleInstaller.php |
— | — | @@ -115,5 +115,9 @@ |
116 | 116 | "# Oracle specific settings |
117 | 117 | \$wgDBprefix = \"{$prefix}\";"; |
118 | 118 | } |
119 | | - |
| 119 | + |
| 120 | + public function doUpgrade() { |
| 121 | + // TODO |
| 122 | + return false; |
| 123 | + } |
120 | 124 | } |
\ No newline at end of file |
Index: trunk/phase3/includes/installer/PostgresInstaller.php |
— | — | @@ -149,4 +149,9 @@ |
150 | 150 | \$wgDBmwschema = \"{$schema}\"; |
151 | 151 | \$wgDBts2schema = \"{$ts2}\";"; |
152 | 152 | } |
| 153 | + |
| 154 | + public function doUpgrade() { |
| 155 | + // TODO |
| 156 | + return false; |
| 157 | + } |
153 | 158 | } |
Index: trunk/phase3/includes/installer/WebInstallerPage.php |
— | — | @@ -293,6 +293,7 @@ |
294 | 294 | } |
295 | 295 | |
296 | 296 | if ( $this->parent->request->wasPosted() ) { |
| 297 | + $installer->preUpgrade(); |
297 | 298 | $this->addHTML( |
298 | 299 | '<div id="config-spinner" style="display:none;"><img src="../skins/common/images/ajax-loader.gif" /></div>' . |
299 | 300 | '<script>jQuery( "#config-spinner" )[0].style.display = "block";</script>' . |