r79066 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79065‎ | r79066 | r79067 >
Date:15:41, 27 December 2010
Author:demon
Status:resolved (Comments)
Tags:
Comment:
Move setup_plpgsql() to PostgresInstaller and make it use status objects for when the rest of this is moved over too
Modified paths:
  • /trunk/phase3/includes/db/DatabasePostgres.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/db/DatabasePostgres.php
@@ -537,36 +537,6 @@
538538 }
539539 }
540540
541 - function setup_plpgsql() {
542 - print '<li>Checking for PL/pgSQL ...';
543 - $SQL = "SELECT 1 FROM pg_catalog.pg_language WHERE lanname = 'plpgsql'";
544 - $rows = $this->numRows( $this->doQuery( $SQL ) );
545 - if ( $rows < 1 ) {
546 - // plpgsql is not installed, but if we have a pg_pltemplate table, we should be able to create it
547 - print 'not installed. Attempting to install PL/pgSQL ...';
548 - $SQL = "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace) ".
549 - "WHERE relname = 'pg_pltemplate' AND nspname='pg_catalog'";
550 - $rows = $this->numRows( $this->doQuery( $SQL ) );
551 - global $wgDBname;
552 - if ( $rows >= 1 ) {
553 - $olde = error_reporting( 0 );
554 - error_reporting( $olde - E_WARNING );
555 - $result = $this->doQuery( 'CREATE LANGUAGE plpgsql' );
556 - error_reporting( $olde );
557 - if ( !$result ) {
558 - print '<b>FAILED</b>. You need to install the language PL/pgSQL in the database <tt>' .
559 - htmlspecialchars( $wgDBname ) . '</tt></li>';
560 - dieout( );
561 - }
562 - } else {
563 - print '<b>FAILED</b>. You need to install the language PL/pgSQL in the database <tt>' .
564 - htmlspecialchars( $wgDBname ) . '</tt></li>';
565 - dieout( );
566 - }
567 - }
568 - print "OK</li>\n";
569 - }
570 -
571541 /**
572542 * Closes a database connection, if it is open
573543 * Returns success, true if already closed
Index: trunk/phase3/includes/installer/Installer.i18n.php
@@ -449,6 +449,7 @@
450450 'config-install-pg-schema-failed' => 'Tables creation failed.
451451 Make sure that the user "$1" can write to the schema "$2".',
452452 'config-install-pg-commit' => 'Committing changes',
 453+ 'config-pg-no-plpgsql' => 'You need to install the language PL/pgSQL in the database $1',
453454 'config-install-user' => 'Creating database user',
454455 'config-install-user-failed' => 'Granting permission to user "$1" failed: $2',
455456 'config-install-tables' => 'Creating tables',
Index: trunk/phase3/includes/installer/PostgresInstaller.php
@@ -166,4 +166,26 @@
167167 $wgDBuser = $this->getVar( '_InstallUser' );
168168 $wgDBpassword = $this->getVar( '_InstallPassword' );
169169 }
 170+
 171+ private function setupPLpgSQL() {
 172+ $rows = $this->numRows(
 173+ $this->db->query( "SELECT 1 FROM pg_catalog.pg_language WHERE lanname = 'plpgsql'" )
 174+ );
 175+ if ( $rows < 1 ) {
 176+ // plpgsql is not installed, but if we have a pg_pltemplate table, we should be able to create it
 177+ $SQL = "SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON (n.oid = c.relnamespace) ".
 178+ "WHERE relname = 'pg_pltemplate' AND nspname='pg_catalog'";
 179+ $rows = $this->numRows( $this->db->query( $SQL ) );
 180+ global $wgDBname;
 181+ if ( $rows >= 1 ) {
 182+ $result = $this->db->query( 'CREATE LANGUAGE plpgsql' );
 183+ if ( !$result ) {
 184+ return Status::newFatal( 'pg-no-plpgsql', $wgDBname );
 185+ }
 186+ } else {
 187+ return Status::newFatal( 'pg-no-plpgsql', $wgDBname );
 188+ }
 189+ }
 190+ return Status::newGood();
 191+ }
170192 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r801901.17: MFT first batch of installer changes: r78043, r78231, r78259, r78300, r...catrope20:47, 13 January 2011

Comments

#Comment by Reedy (talk | contribs)   22:46, 6 January 2011

Typo'd keys resolved in r79768

Status & tagging log