array( 'name' => 'sysop', 'callback' => array( $this, 'createSysop' ) ),
array( 'name' => 'mainpage', 'callback' => array( $this, 'createMainpage' ) ),
);
- if( count( $this->getVar( '_Extensions' ) ) ) {
- array_unshift( $coreInstallSteps,
- array( 'name' => 'extensions', 'callback' => array( $this, 'includeExtensions' ) )
- );
- }
- $this->installSteps = $coreInstallSteps;
- foreach( $this->extraInstallSteps as $step ) {
- // Put the step at the beginning
- if( !strval( $step['position' ] ) ) {
- array_unshift( $this->installSteps, $step['callback'] );
- continue;
- } else {
- // Walk the $coreInstallSteps array to see if we can modify
- // $this->installSteps with a callback that wants to attach after
- // a given step
- array_walk(
- $coreInstallSteps,
- array( $this, 'installStepCallback' ),
- $step
+
+ // Build the array of install steps starting from the core install list,
+ // then adding any callbacks that wanted to attach after a given step
+ foreach( $coreInstallSteps as $step ) {
+ $this->installSteps[] = $step;
+ if( isset( $this->extraInstallSteps[ $step['name'] ] ) ) {
+ $this->installSteps = array_merge(
+ $this->installSteps,
+ $this->extraInstallSteps[ $step['name'] ]
);
}
}
- return $this->installSteps;
- }
- /**
- * Callback for getInstallSteps() - used for finding if a given $insertableStep
- * should be inserted after the current $coreStep in question
- */
- private function installStepCallback( $coreStep, $key, $insertableStep ) {
- if( $coreStep['name'] == $insertableStep['position'] ) {
- $front = array_slice( $this->installSteps, 0, $key + 1 );
- $front[] = $insertableStep['callback'];
- $back = array_slice( $this->installSteps, $key + 1 );
- $this->installSteps = array_merge( $front, $back );
+ // Prepend any steps that want to be at the beginning
+ if( isset( $this->extraInstallSteps['BEGINNING'] ) ) {
+ $this->installSteps = array_merge(
+ $this->extraInstallSteps['BEGINNING'],
+ $this->installSteps
+ );
}
+
+ // Extensions should always go first, chance to tie into hooks and such
+ if( count( $this->getVar( '_Extensions' ) ) ) {
+ array_unshift( $this->installSteps,
+ array( 'name' => 'extensions', 'callback' => array( $this, 'includeExtensions' ) )
+ );
+ }
+ return $this->installSteps;
}
/**
* array( 'name' => 'some-unique-name', 'callback' => array( $obj, 'function' ) );
* @param $findStep String the step to find. Omit to put the step at the beginning
*/
- public function addInstallStep( $callback, $findStep = '' ) {
- $this->extraInstallSteps[] = array(
- 'position' => $findStep, 'callback' => $callback
- );
+ public function addInstallStep( $callback, $findStep = 'BEGINNING' ) {
+ $this->extraInstallSteps[$findStep][] = $callback;
}
}
'name' => 'pg-ts2',
'callback' => array( $this, 'setupTs2' ),
);
+ $plpgCB = array(
+ 'name' => 'pg-plpgsql',
+ 'callback' => array( $this, 'setupPLpgSQL' ),
+ );
$this->parent->addInstallStep( $commitCB, 'interwiki' );
$this->parent->addInstallStep( $userCB );
- $this->parent->addInstallStep( $ts2CB, 'setupDatabase' );
+ $this->parent->addInstallStep( $ts2CB, 'database' );
+ $this->parent->addInstallStep( $plpgCB, 'database' );
}
function setupDatabase() {
* @return Status
*/
function setupTs2() {
+ $status = $this->getConnection();
+ if ( !$status->isOK() ) {
+ return $status;
+ }
+
if( version_compare( $this->db->getServerVersion(), $this->ts2MaxVersion, '<' ) ) {
if ( !$this->db->tableExists( 'pg_ts_cfg', $wgDBts2schema ) ) {
return Status::newFatal(
$wgDBpassword = $this->getVar( '_InstallPassword' );
}
- private function setupPLpgSQL() {
- $rows = $this->numRows(
+ public function setupPLpgSQL() {
+ $status = $this->getConnection();
+ if ( !$status->isOK() ) {
+ return $status;
+ }
+
+ $rows = $this->db->numRows(
$this->db->query( "SELECT 1 FROM pg_catalog.pg_language WHERE lanname = 'plpgsql'" )
);
if ( $rows < 1 ) {
// plpgsql is not installed, but if we have a pg_pltemplate table, we should be able to create it
$SQL = "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace) ".
"WHERE relname = 'pg_pltemplate' AND nspname='pg_catalog'";
- $rows = $this->numRows( $this->db->query( $SQL ) );
- global $wgDBname;
+ $rows = $this->db->numRows( $this->db->query( $SQL ) );
+ $dbName = $this->getVar( 'wgDBname' );
if ( $rows >= 1 ) {
$result = $this->db->query( 'CREATE LANGUAGE plpgsql' );
if ( !$result ) {
- return Status::newFatal( 'config-pg-no-plpgsql', $wgDBname );
+ return Status::newFatal( 'config-pg-no-plpgsql', $dbName );
}
} else {
- return Status::newFatal( 'config-pg-no-plpgsql', $wgDBname );
+ return Status::newFatal( 'config-pg-no-plpgsql', $dbName );
}
}
return Status::newGood();