var $installSteps = array(
'database',
- 'user',
'tables',
'interwiki',
'secretkey',
*/
abstract function setupDatabase();
- /**
- * Create a new non-root user for the database and return a Status
- * object indicating success or failure. A default implementation
- * that returns a good status is supplied for those databases that
- * don't need to set up users.
- *
- * @return Status
- */
- function setupUser() {
- return Status::newGood();
- }
-
/**
* Create database tables from scratch
* @return \type Status
function getName() {
return 'mysql';
}
+
+ function __construct( $parent ) {
+ parent::__construct( $parent );
+
+ # Add our user callback to installSteps, right before the tables are created.
+ $where_tables = array_search( "tables", $this->parent->installSteps );
+ $callback = array(
+ array(
+ 'name' => 'user',
+ 'callback' => array( &$this, 'setupUser' ),
+ )
+ );
+ array_splice( $this->parent->installSteps, $where_tables, 0, $callback );
+ }
function isCompiled() {
return $this->checkExtension( 'mysql' );
}
$this->startForm();
$this->addHTML("<ul>");
- foreach( $this->parent->getInstallSteps() as $step ) {
+ foreach( $this->parent->getInstallSteps() as $stepObj ) {
+ $step = is_array( $stepObj ) ? $stepObj['name'] : $stepObj;
$this->startStage( "config-install-$step" );
- $func = 'install' . ucfirst( $step );
- $status = $this->parent->{$func}();
+ $status = null;
+
+ # Call our working function
+ if ( is_array( $step ) ) {
+ # A custom callaback
+ $callback = $stepObj['callback'];
+ $status = call_user_func_array( $callback, array() );
+ } else {
+ # Boring implicitly named callback
+ $func = 'install' . ucfirst( $step );
+ $status = $this->parent->{$func}();
+ }
+
$ok = $status->isGood();
if ( !$ok ) {
$this->parent->showStatusErrorBox( $status );