Index: trunk/phase3/includes/installer/CoreInstaller.php |
— | — | @@ -89,6 +89,13 @@ |
90 | 90 | ); |
91 | 91 | |
92 | 92 | /** |
| 93 | + * The actual list of installation steps. This will be initialized by getInstallSteps() |
| 94 | + * |
| 95 | + * @var array |
| 96 | + */ |
| 97 | + private $installSteps = array(); |
| 98 | + |
| 99 | + /** |
93 | 100 | * Extra steps for installation, for things like DatabaseInstallers to modify |
94 | 101 | * |
95 | 102 | * @var array |
— | — | @@ -296,40 +303,66 @@ |
297 | 304 | } |
298 | 305 | |
299 | 306 | /** |
300 | | - * Get an array of install steps. These could be a plain key like the defaults |
301 | | - * in $installSteps, or could be an array with a name and a specific callback |
302 | | - * There must be a config-install-$step message defined per step, which will |
| 307 | + * Get an array of install steps. Should always be in the format of |
| 308 | + * array( |
| 309 | + * 'name' => 'someuniquename', |
| 310 | + * 'callback' => array( $obj, 'method' ), |
| 311 | + * ) |
| 312 | + * There must be a config-install-$name message defined per step, which will |
303 | 313 | * be shown on install. |
304 | 314 | * |
305 | 315 | * @param $installer DatabaseInstaller so we can make callbacks |
306 | 316 | * @return array |
307 | 317 | */ |
308 | 318 | protected function getInstallSteps( DatabaseInstaller &$installer ) { |
309 | | - $installSteps = array( |
310 | | - array( 'name' => 'database', 'callback' => array( $installer, 'setupDatabase' ) ), |
311 | | - array( 'name' => 'tables', 'callback' => array( $this, 'installTables' ) ), |
312 | | - array( 'name' => 'interwiki', 'callback' => array( $installer, 'populateInterwikiTable' ) ), |
313 | | - array( 'name' => 'secretkey', 'callback' => array( $this, 'generateSecretKey' ) ), |
| 319 | + $coreInstallSteps = array( |
| 320 | + array( 'name' => 'database', 'callback' => array( $installer, 'setupDatabase' ) ), |
| 321 | + array( 'name' => 'tables', 'callback' => array( $this, 'installTables' ) ), |
| 322 | + array( 'name' => 'interwiki', 'callback' => array( $installer, 'populateInterwikiTable' ) ), |
| 323 | + array( 'name' => 'secretkey', 'callback' => array( $this, 'generateSecretKey' ) ), |
314 | 324 | array( 'name' => 'upgradekey', 'callback' => array( $this, 'generateUpgradeKey' ) ), |
315 | | - array( 'name' => 'sysop', 'callback' => array( $this, 'createSysop' ) ), |
316 | | - array( 'name' => 'mainpage', 'callback' => array( $this, 'createMainpage' ) ), |
| 325 | + array( 'name' => 'sysop', 'callback' => array( $this, 'createSysop' ) ), |
| 326 | + array( 'name' => 'mainpage', 'callback' => array( $this, 'createMainpage' ) ), |
317 | 327 | ); |
318 | 328 | if( count( $this->getVar( '_Extensions' ) ) ) { |
319 | | - array_unshift( $installSteps, |
| 329 | + array_unshift( $coreInstallSteps, |
320 | 330 | array( 'name' => 'extensions', 'callback' => array( $this, 'includeExtensions' ) ) |
321 | 331 | ); |
322 | 332 | } |
323 | | - foreach( $installSteps as $idx => $stepObj ) { |
324 | | - if( isset( $this->extraInstallSteps[ $stepObj['name'] ] ) ) { |
325 | | - $tmp = array_slice( $installSteps, 0, $idx ); |
326 | | - $tmp[] = $this->extraInstallSteps[ $stepObj['name'] ]; |
327 | | - $installSteps = array_merge( $tmp, array_slice( $installSteps, $idx ) ); |
| 333 | + $this->installSteps = $coreInstallSteps; |
| 334 | + foreach( $this->extraInstallSteps as $step ) { |
| 335 | + // Put the step at the beginning |
| 336 | + if( !strval( $step['position' ] ) ) { |
| 337 | + array_unshift( $installSteps, $step['callback'] ); |
| 338 | + continue; |
| 339 | + } else { |
| 340 | + // Walk the $coreInstallSteps array to see if we can modify |
| 341 | + // $this->installSteps with a callback that wants to attach after |
| 342 | + // a given step |
| 343 | + array_walk( |
| 344 | + $coreInstallSteps, |
| 345 | + array( $this, 'installStepCallback' ), |
| 346 | + $step |
| 347 | + ); |
328 | 348 | } |
329 | 349 | } |
330 | | - return $installSteps; |
| 350 | + return $this->installSteps; |
331 | 351 | } |
332 | 352 | |
333 | 353 | /** |
| 354 | + * Callback for getInstallSteps() - used for finding if a given $insertableStep |
| 355 | + * should be inserted after the current $coreStep in question |
| 356 | + */ |
| 357 | + private function installStepCallback( $coreStep, $key, $insertableStep ) { |
| 358 | + if( $coreStep['name'] == $insertableStep['position'] ) { |
| 359 | + $front = array_slice( $this->installSteps, 0, $key + 1 ); |
| 360 | + $front[] = $insertableStep['callback']; |
| 361 | + $back = array_slice( $this->installSteps, $key + 1 ); |
| 362 | + $this->installSteps = array_merge( $front, $back ); |
| 363 | + } |
| 364 | + } |
| 365 | + |
| 366 | + /** |
334 | 367 | * Actually perform the installation. |
335 | 368 | * |
336 | 369 | * @param $startCB A callback array for the beginning of each step |
— | — | @@ -506,10 +539,12 @@ |
507 | 540 | /** |
508 | 541 | * Add an installation step following the given step. |
509 | 542 | * |
510 | | - * @param $findStep String the step to find. Use NULL to put the step at the beginning. |
511 | | - * @param $callback array A valid callback array, with name and callback given |
| 543 | + * @param $callback Array A valid callback array, with name and callback given |
| 544 | + * @param $findStep String the step to find. Omit to put the step at the beginning |
512 | 545 | */ |
513 | | - public function addInstallStepFollowing( $findStep, $callback ) { |
514 | | - $this->extraInstallSteps[$findStep] = $callback; |
| 546 | + public function addInstallStep( $callback, $findStep = '' ) { |
| 547 | + $this->extraInstallSteps[] = array( |
| 548 | + 'position' => $findStep, 'callback' => $callback |
| 549 | + ); |
515 | 550 | } |
516 | 551 | } |
Index: trunk/phase3/includes/installer/MysqlInstaller.php |
— | — | @@ -366,7 +366,7 @@ |
367 | 367 | if ( !$create ) { |
368 | 368 | // Test the web account |
369 | 369 | try { |
370 | | - new Database( |
| 370 | + new DatabaseMysql( |
371 | 371 | $this->getVar( 'wgDBserver' ), |
372 | 372 | $this->getVar( 'wgDBuser' ), |
373 | 373 | $this->getVar( 'wgDBpassword' ), |
— | — | @@ -399,7 +399,7 @@ |
400 | 400 | 'name' => 'user', |
401 | 401 | 'callback' => array( $this, 'setupUser' ), |
402 | 402 | ); |
403 | | - $this->parent->addInstallStepFollowing( "tables", $callback ); |
| 403 | + $this->parent->addInstallStep( $callback, 'tables' ); |
404 | 404 | } |
405 | 405 | |
406 | 406 | public function setupDatabase() { |