r15094 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r15093‎ | r15094 | r15095 >
Date:16:11, 27 June 2006
Author:brion
Status:old
Tags:
Comment:
Revert to r15092; massive breakage, unable to connect to MySQL at all
Modified paths:
  • /trunk/phase3/config/index.php (modified) (history)
  • /trunk/phase3/includes/Database.php (modified) (history)
  • /trunk/phase3/includes/DatabaseOracle.php (modified) (history)
  • /trunk/phase3/includes/DatabasePostgres.php (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Setup.php (modified) (history)
  • /trunk/phase3/maintenance/convertLinks.inc (modified) (history)
  • /trunk/phase3/maintenance/rebuildall.php (modified) (history)
  • /trunk/phase3/maintenance/rebuildtextindex.php (modified) (history)
  • /trunk/phase3/maintenance/tables.sql (modified) (history)
  • /trunk/phase3/maintenance/update.php (modified) (history)
  • /trunk/phase3/tests/LocalTestSettings.sample (modified) (history)
  • /trunk/phase3/tests/RunTests.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/update.php
@@ -32,7 +32,7 @@
3333
3434 # Attempt to connect to the database as a privileged user
3535 # This will vomit up an error if there are permissions problems
36 -$wgDatabase = $dbc->newFromParams( $wgDBserver, $wgDBport, $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1 );
 36+$wgDatabase = $dbc->newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1 );
3737
3838 if( !$wgDatabase->isOpen() ) {
3939 # Appears to have failed
Index: trunk/phase3/maintenance/rebuildall.php
@@ -15,7 +15,7 @@
1616 require_once( "rebuildtextindex.inc" );
1717 require_once( "rebuildrecentchanges.inc" );
1818
19 -$database = Database::newFromParams( $wgDBserver, $wgDBport, wgDBadminuser, $wgDBadminpassword, $wgDBname );
 19+$database = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname );
2020
2121 print "** Rebuilding fulltext search index (if you abort this will break searching; run this script again to fix):\n";
2222 dropTextIndex( $database );
Index: trunk/phase3/maintenance/rebuildtextindex.php
@@ -13,7 +13,7 @@
1414 require_once( "rebuildtextindex.inc" );
1515 $wgTitle = Title::newFromText( "Rebuild text index script" );
1616
17 -$database = Database::newFromParams( $wgDBserver, $wgDBport, $wgDBadminuser, $wgDBadminpassword, $wgDBname );
 17+$database = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname );
1818
1919 dropTextIndex( $database );
2020 rebuildTextIndex( $database );
Index: trunk/phase3/maintenance/convertLinks.inc
@@ -8,14 +8,14 @@
99 /** */
1010 function convertLinks() {
1111 global $wgDBtype;
12 - if( $wgDBtype == 'Postgres' ) {
 12+ if( $wgDBtype == 'PostgreSQL' ) {
1313 print "Links table already ok on PostgreSQL.\n";
1414 return;
1515 }
1616
1717 print "Converting links table to ID-ID...\n";
1818
19 - global $wgLang, $wgDBserver, $wgDBport, $wgDBadminuser, $wgDBadminpassword, $wgDBname;
 19+ global $wgLang, $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname;
2020 global $noKeys, $logPerformance, $fh;
2121
2222 $numRows = $tuplesAdded = $numBadLinks = $curRowsRead = 0; #counters etc
@@ -147,7 +147,7 @@
148148 #--------------------------------------------------------------------
149149
150150 if ( $overwriteLinksTable ) {
151 - $dbConn = Database::newFromParams( $wgDBserver, $wgDBport, $wgDBadminuser, $wgDBadminpassword, $wgDBname );
 151+ $dbConn = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname );
152152 if (!($dbConn->isOpen())) {
153153 print "Opening connection to database failed.\n";
154154 return;
@@ -174,9 +174,9 @@
175175 #--------------------------------------------------------------------
176176
177177 function createTempTable() {
178 - global $wgDBserver, $wgDBport, $wgDBadminuser, $wgDBadminpassword, $wgDBname;
 178+ global $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname;
179179 global $noKeys;
180 - $dbConn = Database::newFromParams( $wgDBserver, $wgDBport, $wgDBadminuser, $wgDBadminpassword, $wgDBname );
 180+ $dbConn = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname );
181181
182182 if (!($dbConn->isOpen())) {
183183 print "Opening connection to database failed.\n";
Index: trunk/phase3/maintenance/tables.sql
@@ -995,4 +995,4 @@
996996
997997 UNIQUE KEY ( qci_type )
998998
999 -) TYPE=InnoDB;
 999+) TYPE=InnoDB;
\ No newline at end of file
Index: trunk/phase3/tests/LocalTestSettings.sample
@@ -12,19 +12,16 @@
1313 $testOptions = array(
1414 'mysql3' => array(
1515 'server' => null,
16 - 'port' => null,
1716 'user' => null,
1817 'password' => null,
1918 'database' => null ),
2019 'mysql4' => array(
2120 'server' => null,
22 - 'port' => null,
2321 'user' => null,
2422 'password' => null,
2523 'database' => null ),
2624 'postgres' => array(
2725 'server' => null,
28 - 'port' => null,
2926 'user' => null,
3027 'password' => null,
3128 'database' => null ),
Index: trunk/phase3/tests/RunTests.php
@@ -14,15 +14,13 @@
1515
1616 $testOptions = array(
1717 'mysql4' => array(
18 - 'server' => null,
19 - 'port' => null,
20 - 'user' => null,
 18+ 'server' => null,
 19+ 'user' => null,
2120 'password' => null,
2221 'database' => null ),
2322 'postgres' => array(
24 - 'server' => null,
25 - 'port' => null
26 - 'user' => null,
 23+ 'server' => null,
 24+ 'user' => null,
2725 'password' => null,
2826 'database' => null ),
2927 );
Index: trunk/phase3/config/index.php
@@ -476,13 +476,13 @@
477477
478478 <?php
479479 $conf->DBserver = importPost( "DBserver", "localhost" );
480 - $conf->DBport = importPost( "DBport", "5432" );
481480 $conf->DBname = importPost( "DBname", "wikidb" );
482481 $conf->DBuser = importPost( "DBuser", "wikiuser" );
483482 $conf->DBpassword = importPost( "DBpassword" );
484483 $conf->DBpassword2 = importPost( "DBpassword2" );
485484 $conf->DBprefix = importPost( "DBprefix" );
486485 $conf->DBschema = importPost( "DBschema", "mediawiki" );
 486+ $conf->DBport = importPost( "DBport", "5432" );
487487 $conf->DBmysql5 = (importPost( "DBmysql5" ) == "true") ? "true" : "false";
488488 $conf->RootUser = importPost( "RootUser", "root" );
489489 $conf->RootPW = importPost( "RootPW", "-" );
@@ -620,7 +620,7 @@
621621
622622 # Attempt to connect
623623 echo( "<li>Attempting to connect to database server as $db_user..." );
624 - $wgDatabase = Database::newFromParams( $wgDBserver, $wgDBport, $db_user, $db_pass, '', 1 );
 624+ $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
625625
626626 # Check the connection and respond to errors
627627 if( $wgDatabase->isOpen() ) {
@@ -664,7 +664,7 @@
665665
666666 } else /* not mysql */ {
667667 echo( "<li>Attempting to connect to database server as $wgDBuser..." );
668 - $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBport, $wgDBuser, $wgDBpassword, $wgDBname, 1);
 668+ $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1);
669669 if (!$wgDatabase->isOpen()) {
670670 print " error: " . $wgDatabase->lastError() . "</li>\n";
671671 } else {
@@ -728,7 +728,7 @@
729729
730730 # Create user if required
731731 if ( $conf->Root ) {
732 - $conn = $dbc->newFromParams( $wgDBserver, $wgDBport, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
 732+ $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
733733 if ( $conn->isOpen() ) {
734734 print "<li>DB user account ok</li>\n";
735735 $conn->close();
@@ -785,7 +785,7 @@
786786 # Set up the "regular user" account *if we can, and if we need to*
787787 if( $conf->Root ) {
788788 # See if we need to
789 - $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBport, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
 789+ $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
790790 if( $wgDatabase2->isOpen() ) {
791791 # Nope, just close the test connection and continue
792792 $wgDatabase2->close();
@@ -1340,7 +1340,6 @@
13411341 \$wgEmailAuthentication = $eauthent;
13421342
13431343 \$wgDBserver = \"{$slconf['DBserver']}\";
1344 -\$wgDBport = \"{$slconf['DBport']}\";
13451344 \$wgDBname = \"{$slconf['DBname']}\";
13461345 \$wgDBuser = \"{$slconf['DBuser']}\";
13471346 \$wgDBpassword = \"{$slconf['DBpassword']}\";
Index: trunk/phase3/includes/DatabaseOracle.php
@@ -40,7 +40,7 @@
4141 Database::Database( $server, $user, $password, $dbName, $failFunction, $flags, $tablePrefix );
4242 }
4343
44 - /* static */ function newFromParams( $server = false, $port = false, $user = false, $password = false, $dbName = false,
 44+ /* static */ function newFromParams( $server = false, $user = false, $password = false, $dbName = false,
4545 $failFunction = false, $flags = 0, $tablePrefix = 'get from global' )
4646 {
4747 return new DatabaseOracle( $server, $user, $password, $dbName, $failFunction, $flags, $tablePrefix );
Index: trunk/phase3/includes/Setup.php
@@ -147,7 +147,6 @@
148148 if ( !$wgDBservers ) {
149149 $wgDBservers = array(array(
150150 'host' => $wgDBserver,
151 - 'port' => $wgDBport,
152151 'user' => $wgDBuser,
153152 'password' => $wgDBpassword,
154153 'dbname' => $wgDBname,
Index: trunk/phase3/includes/DatabasePostgres.php
@@ -7,6 +7,9 @@
88 * than MySQL ones, some of them should be moved to parent
99 * Database class.
1010 *
 11+ * STATUS: Working PG implementation of MediaWiki
 12+ * TODO: Installer support
 13+ *
1114 * @package MediaWiki
1215 */
1316
@@ -15,28 +18,31 @@
1619 */
1720 require_once( 'Database.php' );
1821
 22+/**
 23+ *
 24+ * @package MediaWiki
 25+ */
1926 class DatabasePostgres extends Database {
2027 var $mInsertId = NULL;
2128 var $mLastResult = NULL;
2229
23 - function DatabasePostgres($server = false, $port = false, $user = false, $password = false, $dbName = false,
 30+ function DatabasePostgres($server = false, $user = false, $password = false, $dbName = false,
2431 $failFunction = false, $flags = 0 )
2532 {
26 - Database::__construct( $server, $port, $user, $password, $dbName, $failFunction, $flags );
 33+ Database::__construct( $server, $user, $password, $dbName, $failFunction, $flags );
2734 }
2835
29 - static function newFromParams( $server = false, $port = false, $user = false, $password = false, $dbName = false,
 36+ static function newFromParams( $server = false, $user = false, $password = false, $dbName = false,
3037 $failFunction = false, $flags = 0)
3138 {
32 - return new DatabasePostgres( $server, $port, $user, $password, $dbName, $failFunction, $flags );
 39+ return new DatabasePostgres( $server, $user, $password, $dbName, $failFunction, $flags );
3340 }
3441
3542 /**
3643 * Usually aborts on failure
3744 * If the failFunction is set to a non-zero integer, returns success
3845 */
39 - function open( $server, $port, $user, $password, $dbName ) {
40 -
 46+ function open( $server, $user, $password, $dbName ) {
4147 # Test for PostgreSQL support, to avoid suppressed fatal error
4248 if ( !function_exists( 'pg_connect' ) ) {
4349 throw new DBConnectionError( $this, "PostgreSQL functions missing, have you compiled PHP with the --with-pgsql option?\n" );
@@ -50,7 +56,6 @@
5157 $this->mPassword = $password;
5258 $this->mDBname = $dbName;
5359 $this->mSchemas = array($wgDBschema,'public');
54 - $this->mPort = $port;
5560
5661 $success = false;
5762
@@ -60,9 +65,6 @@
6166 if ($server!=false && $server!="") {
6267 $hstring="host=$server ";
6368 }
64 - if ($port!=false && $port != '') {
65 - $hstring .= "port=$port ";
66 - }
6769
6870 @$this->mConn = pg_connect("$hstring dbname=$dbName user=$user password=$password");
6971 if ( $this->mConn == false ) {
@@ -195,7 +197,7 @@
196198 $n = pg_num_fields( $res );
197199 for( $i = 0; $i < $n; $i++ ) {
198200 // FIXME
199 - throw new DBUnexpectedError($this, "Database::fieldInfo() error : mysql_fetch_field() not implemented for postgres" );
 201+ throw new DBUnexpectedError($this, "Database::fieldInfo() error : mysql_fetch_field() not implemented for postgre" );
200202 $meta = mysql_fetch_field( $res, $i );
201203 if( $field == $meta->name ) {
202204 return $meta;
@@ -437,44 +439,6 @@
438440 $searchpath=$this->makeList($schemas,LIST_NAMES);
439441 $this->query("SET search_path = $searchpath");
440442 }
441 -
442 -
443 - /**
444 - * Query whether a given table exists
445 - */
446 - function tableExists( $table ) {
447 - global $wgDBschema;
448 - $safetable = preg_replace("/'/", "''", $table);
449 - $SQL = "SELECT 1 FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n WHERE c.relnamespace = n.oid "
450 - . "AND c.relname = '$safetable' AND n.nspname = '$wgDBschema'";
451 - $res = $this->query($SQL);
452 - if( $res ) {
453 - $this->freeResult( $res );
454 - return true;
455 - } else {
456 - return false;
457 - }
458 - }
459 -
460 - function fieldExists( $table, $field, $fname = 'DatabasePostgres::fieldExists' ) {
461 - global $wgDBschema;
462 - $safetable = preg_replace("/'/", "''", $table);
463 - $safecol = preg_replace("/'/", "''", $field);
464 - $SQL = "SELECT 1 FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n, pg_attribute a "
465 - . "WHERE c.relnamespace = n.oid AND c.relname = '$safetable' AND n.nspname = '$wgDBschema' "
466 - . "AND a.attrelid = c.oid AND a.attname = '$safecol'";
467 - $res = $this->query($SQL, $fname);
468 - if( $res ) {
469 - $this->freeResult( $res );
470 - return true;
471 - } else {
472 - return false;
473 - }
474 - }
475 -
476 -
477 -
478 -
479443 }
480444
481445 ?>
Index: trunk/phase3/includes/DefaultSettings.php
@@ -433,13 +433,12 @@
434434 $wgDBserver = 'localhost';
435435 /** name of the database */
436436 $wgDBname = 'wikidb';
437 -/** port number for databases that use them (e.g. postgres) */
438 -$wgDBport = 5432;
439437 /** */
440438 $wgDBconnection = '';
441439 /** Database username */
442440 $wgDBuser = 'wikiuser';
443441 /** Database type
 442+ * "mysql" for working code and "PostgreSQL" for development/broken code
444443 */
445444 $wgDBtype = "mysql";
446445 /** Search type
Index: trunk/phase3/includes/Database.php
@@ -240,7 +240,7 @@
241241
242242 protected $mLastQuery = '';
243243
244 - protected $mServer, $mPort, $mUser, $mPassword, $mConn = null, $mDBname;
 244+ protected $mServer, $mUser, $mPassword, $mConn = null, $mDBname;
245245 protected $mOut, $mOpened = false;
246246
247247 protected $mFailFunction;
@@ -371,7 +371,6 @@
372372
373373 /**@{{
374374 * @param string $server database server host
375 - * @param string $port database server port
376375 * @param string $user database user name
377376 * @param string $password database user password
378377 * @param string $dbname database name
@@ -382,8 +381,8 @@
383382 * @param $flags
384383 * @param $tablePrefix String: database table prefixes. By default use the prefix gave in LocalSettings.php
385384 */
386 - function __construct( $server = false, $port = false, $user = false, $password = false, $dbName = false,
387 - $failFunction = false, $flags = 0, $tablePrefix = 'get from global') {
 385+ function __construct( $server = false, $user = false, $password = false, $dbName = false,
 386+ $failFunction = false, $flags = 0, $tablePrefix = 'get from global' ) {
388387
389388 global $wgOut, $wgDBprefix, $wgCommandLineMode;
390389 # Can't get a reference if it hasn't been set yet
@@ -417,8 +416,8 @@
418417 $this->mTablePrefix = $tablePrefix;
419418 }
420419
421 - if ( $server or $port) {
422 - $this->open( $server, $port, $user, $password, $dbName );
 420+ if ( $server ) {
 421+ $this->open( $server, $user, $password, $dbName );
423422 }
424423 }
425424
@@ -427,17 +426,17 @@
428427 * @param failFunction
429428 * @param $flags
430429 */
431 - static function newFromParams( $server, $port, $user, $password, $dbName,
 430+ static function newFromParams( $server, $user, $password, $dbName,
432431 $failFunction = false, $flags = 0 )
433432 {
434 - return new Database( $server, $port, $user, $password, $dbName, $failFunction, $flags );
 433+ return new Database( $server, $user, $password, $dbName, $failFunction, $flags );
435434 }
436435
437436 /**
438437 * Usually aborts on failure
439438 * If the failFunction is set to a non-zero integer, returns success
440439 */
441 - function open( $server, $port, $user, $password, $dbName ) {
 440+ function open( $server, $user, $password, $dbName ) {
442441 global $wguname;
443442
444443 # Test for missing mysql.so
@@ -1924,7 +1923,7 @@
19251924 */
19261925 protected function replaceVars( $ins ) {
19271926 $varnames = array(
1928 - 'wgDBserver', 'wgDBport', 'wgDBname', 'wgDBintlname', 'wgDBuser',
 1927+ 'wgDBserver', 'wgDBname', 'wgDBintlname', 'wgDBuser',
19291928 'wgDBpassword', 'wgDBsqluser', 'wgDBsqlpassword',
19301929 'wgDBadminuser', 'wgDBadminpassword',
19311930 );

Follow-up revisions

RevisionCommit summaryAuthorDate
r80892* Cleanup massive duplication across Database constructors. Default implement...demon18:36, 24 January 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r15092Final "postgres" name changes.greg15:09, 27 June 2006