Index: trunk/phase3/includes/installer/MysqlInstaller.php |
— | — | @@ -396,10 +396,8 @@ |
397 | 397 | public function preInstall() { |
398 | 398 | # Add our user callback to installSteps, right before the tables are created. |
399 | 399 | $callback = array( |
400 | | - array( |
401 | | - 'name' => 'user', |
402 | | - 'callback' => array( $this, 'setupUser' ), |
403 | | - ) |
| 400 | + 'name' => 'user', |
| 401 | + 'callback' => array( $this, 'setupUser' ), |
404 | 402 | ); |
405 | 403 | $this->parent->addInstallStepFollowing( "tables", $callback ); |
406 | 404 | } |
Index: trunk/phase3/includes/installer/Installer.php |
— | — | @@ -337,24 +337,6 @@ |
338 | 338 | * |
339 | 339 | * @return Status |
340 | 340 | */ |
341 | | - public function installDatabase( DatabaseInstaller &$installer ) { |
342 | | - if( !$installer ) { |
343 | | - $type = $this->getVar( 'wgDBtype' ); |
344 | | - $status = Status::newFatal( "config-no-db", $type ); |
345 | | - } else { |
346 | | - $status = $installer->setupDatabase(); |
347 | | - } |
348 | | - |
349 | | - return $status; |
350 | | - } |
351 | | - |
352 | | - /** |
353 | | - * TODO: document |
354 | | - * |
355 | | - * @param $installer DatabaseInstaller |
356 | | - * |
357 | | - * @return Status |
358 | | - */ |
359 | 341 | public function installTables( DatabaseInstaller &$installer ) { |
360 | 342 | $status = $installer->createTables(); |
361 | 343 | |
— | — | @@ -366,17 +348,6 @@ |
367 | 349 | } |
368 | 350 | |
369 | 351 | /** |
370 | | - * TODO: document |
371 | | - * |
372 | | - * @param $installer DatabaseInstaller |
373 | | - * |
374 | | - * @return Status |
375 | | - */ |
376 | | - public function installInterwiki( DatabaseInstaller &$installer ) { |
377 | | - return $installer->populateInterwikiTable(); |
378 | | - } |
379 | | - |
380 | | - /** |
381 | 352 | * Exports all wg* variables stored by the installer into global scope. |
382 | 353 | */ |
383 | 354 | public function exportVars() { |
Index: trunk/phase3/includes/installer/CoreInstaller.php |
— | — | @@ -88,18 +88,11 @@ |
89 | 89 | ); |
90 | 90 | |
91 | 91 | /** |
92 | | - * Steps for installation. |
| 92 | + * Extra steps for installation, for things like DatabaseInstallers to modify |
93 | 93 | * |
94 | 94 | * @var array |
95 | 95 | */ |
96 | | - protected $installSteps = array( |
97 | | - 'database', |
98 | | - 'tables', |
99 | | - 'interwiki', |
100 | | - 'secretkey', |
101 | | - 'sysop', |
102 | | - 'mainpage', |
103 | | - ); |
| 96 | + protected $extraInstallSteps = array(); |
104 | 97 | |
105 | 98 | /** |
106 | 99 | * Known object cache types and the functions used to test for their existence. |
— | — | @@ -288,12 +281,9 @@ |
289 | 282 | /** |
290 | 283 | * Installs the auto-detected extensions. |
291 | 284 | * |
292 | | - * @TODO: this only requires them? That's all it's supposed to do. Poorly |
293 | | - * named step. |
294 | | - * |
295 | 285 | * @return Status |
296 | 286 | */ |
297 | | - protected function installExtensions() { |
| 287 | + protected function includeExtensions() { |
298 | 288 | $exts = $this->getVar( '_Extensions' ); |
299 | 289 | $path = $this->getVar( 'IP' ) . '/extensions'; |
300 | 290 | |
— | — | @@ -308,13 +298,31 @@ |
309 | 299 | * Get an array of install steps. These could be a plain key like the defaults |
310 | 300 | * in $installSteps, or could be an array with a name and a specific callback |
311 | 301 | * |
| 302 | + * @param $installer DatabaseInstaller so we can make callbacks |
312 | 303 | * @return array |
313 | 304 | */ |
314 | | - protected function getInstallSteps() { |
| 305 | + protected function getInstallSteps( DatabaseInstaller &$installer ) { |
| 306 | + $installSteps = array( |
| 307 | + array( 'name' => 'database', 'callback' => array( $installer, 'setupDatabase' ) ), |
| 308 | + array( 'name' => 'tables', 'callback' => array( $this, 'installTables' ) ), |
| 309 | + array( 'name' => 'interwiki', 'callback' => array( $installer, 'populateInterwikiTable' ) ), |
| 310 | + array( 'name' => 'secretkey', 'callback' => array( $this, 'generateSecretKey' ) ), |
| 311 | + array( 'name' => 'sysop', 'callback' => array( $this, 'createSysop' ) ), |
| 312 | + array( 'name' => 'mainpage', 'callback' => array( $this, 'createMainpage' ) ), |
| 313 | + ); |
315 | 314 | if( count( $this->getVar( '_Extensions' ) ) ) { |
316 | | - array_unshift( $this->installSteps, 'extensions' ); |
| 315 | + array_unshift( $installSteps, |
| 316 | + array( 'extensions', array( $this, 'includeExtensions' ) ) |
| 317 | + ); |
317 | 318 | } |
318 | | - return $this->installSteps; |
| 319 | + foreach( $installSteps as $idx => $stepObj ) { |
| 320 | + if( isset( $this->extraInstallSteps[ $stepObj['name'] ] ) ) { |
| 321 | + $tmp = array_slice( $installSteps, 0, $idx ); |
| 322 | + $tmp[] = $this->extraInstallSteps[ $stepObj['name'] ]; |
| 323 | + $installSteps = array_merge( $tmp, array_slice( $installSteps, $idx ) ); |
| 324 | + } |
| 325 | + } |
| 326 | + return $installSteps; |
319 | 327 | } |
320 | 328 | |
321 | 329 | /** |
— | — | @@ -329,37 +337,27 @@ |
330 | 338 | $installResults = array(); |
331 | 339 | $installer = $this->getDBInstaller(); |
332 | 340 | $installer->preInstall(); |
| 341 | + $steps = $this->getInstallSteps( $installer ); |
| 342 | + foreach( $steps as $stepObj ) { |
| 343 | + $name = $stepObj['name']; |
| 344 | + call_user_func_array( $startCB, array( $name ) ); |
333 | 345 | |
334 | | - foreach( $this->getInstallSteps() as $stepObj ) { |
335 | | - $step = is_array( $stepObj ) ? $stepObj['name'] : $stepObj; |
336 | | - call_user_func_array( $startCB, array( $step ) ); |
| 346 | + // Perform the callback step |
| 347 | + $status = call_user_func_array( $stepObj['callback'], array( &$installer ) ); |
337 | 348 | |
338 | | - # Call our working function |
339 | | - if ( is_array( $stepObj ) ) { |
340 | | - # A custom callaback |
341 | | - $callback = $stepObj['callback']; |
342 | | - $status = call_user_func_array( $callback, array( $installer ) ); |
343 | | - } else { |
344 | | - # Boring implicitly named callback |
345 | | - $func = 'install' . ucfirst( $step ); |
346 | | - $status = $this->{$func}( $installer ); |
347 | | - } |
| 349 | + // Output and save the results |
| 350 | + call_user_func_array( $endCB, array( $name, $status ) ); |
| 351 | + $installResults[$name] = $status; |
348 | 352 | |
349 | | - call_user_func_array( $endCB, array( $step, $status ) ); |
350 | | - $installResults[$step] = $status; |
351 | | - |
352 | 353 | // If we've hit some sort of fatal, we need to bail. |
353 | 354 | // Callback already had a chance to do output above. |
354 | 355 | if( !$status->isOk() ) { |
355 | 356 | break; |
356 | 357 | } |
357 | | - |
358 | 358 | } |
359 | | - |
360 | 359 | if( $status->isOk() ) { |
361 | 360 | $this->setVar( '_InstallDone', true ); |
362 | 361 | } |
363 | | - |
364 | 362 | return $installResults; |
365 | 363 | } |
366 | 364 | |
— | — | @@ -369,7 +367,7 @@ |
370 | 368 | * |
371 | 369 | * @return Status |
372 | 370 | */ |
373 | | - protected function installSecretKey() { |
| 371 | + protected function generateSecretKey() { |
374 | 372 | if ( wfIsWindows() ) { |
375 | 373 | $file = null; |
376 | 374 | } else { |
— | — | @@ -403,7 +401,7 @@ |
404 | 402 | * |
405 | 403 | * @return Status |
406 | 404 | */ |
407 | | - protected function installSysop() { |
| 405 | + protected function createSysop() { |
408 | 406 | $name = $this->getVar( '_AdminName' ); |
409 | 407 | $user = User::newFromName( $name ); |
410 | 408 | |
— | — | @@ -434,7 +432,7 @@ |
435 | 433 | * |
436 | 434 | * @return Status |
437 | 435 | */ |
438 | | - public function installMainpage( DatabaseInstaller &$installer ) { |
| 436 | + protected function createMainpage( DatabaseInstaller &$installer ) { |
439 | 437 | $status = Status::newGood(); |
440 | 438 | try { |
441 | 439 | $article = new Article( Title::newMainPage() ); |
— | — | @@ -480,16 +478,9 @@ |
481 | 479 | * Add an installation step following the given step. |
482 | 480 | * |
483 | 481 | * @param $findStep String the step to find. Use NULL to put the step at the beginning. |
484 | | - * @param $callback array |
| 482 | + * @param $callback array A valid callback array, with name and callback given |
485 | 483 | */ |
486 | 484 | public function addInstallStepFollowing( $findStep, $callback ) { |
487 | | - $where = 0; |
488 | | - |
489 | | - if( $findStep !== null ) { |
490 | | - $where = array_search( $findStep, $this->installSteps ); |
491 | | - } |
492 | | - |
493 | | - array_splice( $this->installSteps, $where, 0, $callback ); |
| 485 | + $this->extraInstallSteps[$findStep] = $callback; |
494 | 486 | } |
495 | | - |
496 | 487 | } |