r80013 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80012‎ | r80013 | r80014 >
Date:15:02, 11 January 2011
Author:demon
Status:ok
Tags:
Comment:
Fix callbacks for the final time so it actually works per documentation.
Other minor postgres fixes
Modified paths:
  • /trunk/phase3/includes/installer/CoreInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/Installer.i18n.php (modified) (history)
  • /trunk/phase3/includes/installer/PostgresInstaller.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/CoreInstaller.php
@@ -345,45 +345,37 @@
346346 array( 'name' => 'sysop', 'callback' => array( $this, 'createSysop' ) ),
347347 array( 'name' => 'mainpage', 'callback' => array( $this, 'createMainpage' ) ),
348348 );
 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
349371 if( count( $this->getVar( '_Extensions' ) ) ) {
350 - array_unshift( $coreInstallSteps,
 372+ array_unshift( $this->installSteps,
351373 array( 'name' => 'extensions', 'callback' => array( $this, 'includeExtensions' ) )
352374 );
353375 }
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 - }
371376 return $this->installSteps;
372377 }
373378
374379 /**
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 - /**
388380 * Actually perform the installation.
389381 *
390382 * @param $startCB A callback array for the beginning of each step
@@ -593,9 +585,7 @@
594586 * array( 'name' => 'some-unique-name', 'callback' => array( $obj, 'function' ) );
595587 * @param $findStep String the step to find. Omit to put the step at the beginning
596588 */
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;
601591 }
602592 }
Index: trunk/phase3/includes/installer/Installer.i18n.php
@@ -451,6 +451,7 @@
452452 'config-install-pg-schema-failed' => 'Tables creation failed.
453453 Make sure that the user "$1" can write to the schema "$2".',
454454 'config-install-pg-commit' => 'Committing changes',
 455+ 'config-pg-plpgsql' => 'Checking for language PL/pgSQL',
455456 'config-pg-no-plpgsql' => 'You need to install the language PL/pgSQL in the database $1',
456457 'config-install-pg-ts2' => 'Checking for tsearch2',
457458 '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 @@
202202 'name' => 'pg-ts2',
203203 'callback' => array( $this, 'setupTs2' ),
204204 );
 205+ $plpgCB = array(
 206+ 'name' => 'pg-plpgsql',
 207+ 'callback' => array( $this, 'setupPLpgSQL' ),
 208+ );
205209 $this->parent->addInstallStep( $commitCB, 'interwiki' );
206210 $this->parent->addInstallStep( $userCB );
207 - $this->parent->addInstallStep( $ts2CB, 'setupDatabase' );
 211+ $this->parent->addInstallStep( $ts2CB, 'database' );
 212+ $this->parent->addInstallStep( $plpgCB, 'database' );
208213 }
209214
210215 function setupDatabase() {
@@ -269,6 +274,11 @@
270275 * @return Status
271276 */
272277 function setupTs2() {
 278+ $status = $this->getConnection();
 279+ if ( !$status->isOK() ) {
 280+ return $status;
 281+ }
 282+
273283 if( version_compare( $this->db->getServerVersion(), $this->ts2MaxVersion, '<' ) ) {
274284 if ( !$this->db->tableExists( 'pg_ts_cfg', $wgDBts2schema ) ) {
275285 return Status::newFatal(
@@ -335,23 +345,28 @@
336346 $wgDBpassword = $this->getVar( '_InstallPassword' );
337347 }
338348
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(
341356 $this->db->query( "SELECT 1 FROM pg_catalog.pg_language WHERE lanname = 'plpgsql'" )
342357 );
343358 if ( $rows < 1 ) {
344359 // plpgsql is not installed, but if we have a pg_pltemplate table, we should be able to create it
345360 $SQL = "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace) ".
346361 "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' );
349364 if ( $rows >= 1 ) {
350365 $result = $this->db->query( 'CREATE LANGUAGE plpgsql' );
351366 if ( !$result ) {
352 - return Status::newFatal( 'config-pg-no-plpgsql', $wgDBname );
 367+ return Status::newFatal( 'config-pg-no-plpgsql', $dbName );
353368 }
354369 } else {
355 - return Status::newFatal( 'config-pg-no-plpgsql', $wgDBname );
 370+ return Status::newFatal( 'config-pg-no-plpgsql', $dbName );
356371 }
357372 }
358373 return Status::newGood();

Follow-up revisions

RevisionCommit summaryAuthorDate
r81182MFT a bunch of installer fixes. r80238, r80128, r80124, r80083, r80080, r800...demon01:59, 29 January 2011

Status & tagging log