Index: trunk/phase3/includes/installer/CoreInstaller.php |
— | — | @@ -345,45 +345,37 @@ |
346 | 346 | array( 'name' => 'sysop', 'callback' => array( $this, 'createSysop' ) ), |
347 | 347 | array( 'name' => 'mainpage', 'callback' => array( $this, 'createMainpage' ) ), |
348 | 348 | ); |
| 349 | + |
| 350 | + // Build the array of install steps starting from the core install list, |
| 351 | + // then adding any callbacks that wanted to attach after a given step |
| 352 | + foreach( $coreInstallSteps as $step ) { |
| 353 | + $this->installSteps[] = $step; |
| 354 | + if( isset( $this->extraInstallSteps[ $step['name'] ] ) ) { |
| 355 | + $this->installSteps = array_merge( |
| 356 | + $this->installSteps, |
| 357 | + $this->extraInstallSteps[ $step['name'] ] |
| 358 | + ); |
| 359 | + } |
| 360 | + } |
| 361 | + |
| 362 | + // Prepend any steps that want to be at the beginning |
| 363 | + if( isset( $this->extraInstallSteps['BEGINNING'] ) ) { |
| 364 | + $this->installSteps = array_merge( |
| 365 | + $this->extraInstallSteps['BEGINNING'], |
| 366 | + $this->installSteps |
| 367 | + ); |
| 368 | + } |
| 369 | + |
| 370 | + // Extensions should always go first, chance to tie into hooks and such |
349 | 371 | if( count( $this->getVar( '_Extensions' ) ) ) { |
350 | | - array_unshift( $coreInstallSteps, |
| 372 | + array_unshift( $this->installSteps, |
351 | 373 | array( 'name' => 'extensions', 'callback' => array( $this, 'includeExtensions' ) ) |
352 | 374 | ); |
353 | 375 | } |
354 | | - $this->installSteps = $coreInstallSteps; |
355 | | - foreach( $this->extraInstallSteps as $step ) { |
356 | | - // Put the step at the beginning |
357 | | - if( !strval( $step['position' ] ) ) { |
358 | | - array_unshift( $this->installSteps, $step['callback'] ); |
359 | | - continue; |
360 | | - } else { |
361 | | - // Walk the $coreInstallSteps array to see if we can modify |
362 | | - // $this->installSteps with a callback that wants to attach after |
363 | | - // a given step |
364 | | - array_walk( |
365 | | - $coreInstallSteps, |
366 | | - array( $this, 'installStepCallback' ), |
367 | | - $step |
368 | | - ); |
369 | | - } |
370 | | - } |
371 | 376 | return $this->installSteps; |
372 | 377 | } |
373 | 378 | |
374 | 379 | /** |
375 | | - * Callback for getInstallSteps() - used for finding if a given $insertableStep |
376 | | - * should be inserted after the current $coreStep in question |
377 | | - */ |
378 | | - private function installStepCallback( $coreStep, $key, $insertableStep ) { |
379 | | - if( $coreStep['name'] == $insertableStep['position'] ) { |
380 | | - $front = array_slice( $this->installSteps, 0, $key + 1 ); |
381 | | - $front[] = $insertableStep['callback']; |
382 | | - $back = array_slice( $this->installSteps, $key + 1 ); |
383 | | - $this->installSteps = array_merge( $front, $back ); |
384 | | - } |
385 | | - } |
386 | | - |
387 | | - /** |
388 | 380 | * Actually perform the installation. |
389 | 381 | * |
390 | 382 | * @param $startCB A callback array for the beginning of each step |
— | — | @@ -593,9 +585,7 @@ |
594 | 586 | * array( 'name' => 'some-unique-name', 'callback' => array( $obj, 'function' ) ); |
595 | 587 | * @param $findStep String the step to find. Omit to put the step at the beginning |
596 | 588 | */ |
597 | | - public function addInstallStep( $callback, $findStep = '' ) { |
598 | | - $this->extraInstallSteps[] = array( |
599 | | - 'position' => $findStep, 'callback' => $callback |
600 | | - ); |
| 589 | + public function addInstallStep( $callback, $findStep = 'BEGINNING' ) { |
| 590 | + $this->extraInstallSteps[$findStep][] = $callback; |
601 | 591 | } |
602 | 592 | } |
Index: trunk/phase3/includes/installer/Installer.i18n.php |
— | — | @@ -451,6 +451,7 @@ |
452 | 452 | 'config-install-pg-schema-failed' => 'Tables creation failed. |
453 | 453 | Make sure that the user "$1" can write to the schema "$2".', |
454 | 454 | 'config-install-pg-commit' => 'Committing changes', |
| 455 | + 'config-pg-plpgsql' => 'Checking for language PL/pgSQL', |
455 | 456 | 'config-pg-no-plpgsql' => 'You need to install the language PL/pgSQL in the database $1', |
456 | 457 | 'config-install-pg-ts2' => 'Checking for tsearch2', |
457 | 458 | 'config-install-pg-ts2-failed' => "'''FAILED''' tsearch2 must be installed in the database $1. |
Index: trunk/phase3/includes/installer/PostgresInstaller.php |
— | — | @@ -201,9 +201,14 @@ |
202 | 202 | 'name' => 'pg-ts2', |
203 | 203 | 'callback' => array( $this, 'setupTs2' ), |
204 | 204 | ); |
| 205 | + $plpgCB = array( |
| 206 | + 'name' => 'pg-plpgsql', |
| 207 | + 'callback' => array( $this, 'setupPLpgSQL' ), |
| 208 | + ); |
205 | 209 | $this->parent->addInstallStep( $commitCB, 'interwiki' ); |
206 | 210 | $this->parent->addInstallStep( $userCB ); |
207 | | - $this->parent->addInstallStep( $ts2CB, 'setupDatabase' ); |
| 211 | + $this->parent->addInstallStep( $ts2CB, 'database' ); |
| 212 | + $this->parent->addInstallStep( $plpgCB, 'database' ); |
208 | 213 | } |
209 | 214 | |
210 | 215 | function setupDatabase() { |
— | — | @@ -269,6 +274,11 @@ |
270 | 275 | * @return Status |
271 | 276 | */ |
272 | 277 | function setupTs2() { |
| 278 | + $status = $this->getConnection(); |
| 279 | + if ( !$status->isOK() ) { |
| 280 | + return $status; |
| 281 | + } |
| 282 | + |
273 | 283 | if( version_compare( $this->db->getServerVersion(), $this->ts2MaxVersion, '<' ) ) { |
274 | 284 | if ( !$this->db->tableExists( 'pg_ts_cfg', $wgDBts2schema ) ) { |
275 | 285 | return Status::newFatal( |
— | — | @@ -335,23 +345,28 @@ |
336 | 346 | $wgDBpassword = $this->getVar( '_InstallPassword' ); |
337 | 347 | } |
338 | 348 | |
339 | | - private function setupPLpgSQL() { |
340 | | - $rows = $this->numRows( |
| 349 | + public function setupPLpgSQL() { |
| 350 | + $status = $this->getConnection(); |
| 351 | + if ( !$status->isOK() ) { |
| 352 | + return $status; |
| 353 | + } |
| 354 | + |
| 355 | + $rows = $this->db->numRows( |
341 | 356 | $this->db->query( "SELECT 1 FROM pg_catalog.pg_language WHERE lanname = 'plpgsql'" ) |
342 | 357 | ); |
343 | 358 | if ( $rows < 1 ) { |
344 | 359 | // plpgsql is not installed, but if we have a pg_pltemplate table, we should be able to create it |
345 | 360 | $SQL = "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace) ". |
346 | 361 | "WHERE relname = 'pg_pltemplate' AND nspname='pg_catalog'"; |
347 | | - $rows = $this->numRows( $this->db->query( $SQL ) ); |
348 | | - global $wgDBname; |
| 362 | + $rows = $this->db->numRows( $this->db->query( $SQL ) ); |
| 363 | + $dbName = $this->getVar( 'wgDBname' ); |
349 | 364 | if ( $rows >= 1 ) { |
350 | 365 | $result = $this->db->query( 'CREATE LANGUAGE plpgsql' ); |
351 | 366 | if ( !$result ) { |
352 | | - return Status::newFatal( 'config-pg-no-plpgsql', $wgDBname ); |
| 367 | + return Status::newFatal( 'config-pg-no-plpgsql', $dbName ); |
353 | 368 | } |
354 | 369 | } else { |
355 | | - return Status::newFatal( 'config-pg-no-plpgsql', $wgDBname ); |
| 370 | + return Status::newFatal( 'config-pg-no-plpgsql', $dbName ); |
356 | 371 | } |
357 | 372 | } |
358 | 373 | return Status::newGood(); |