Index: trunk/phase3/maintenance/update.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | |
34 | 34 | # Attempt to connect to the database as a privileged user |
35 | 35 | # 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 ); |
37 | 37 | |
38 | 38 | if( !$wgDatabase->isOpen() ) { |
39 | 39 | # Appears to have failed |
Index: trunk/phase3/maintenance/rebuildall.php |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | require_once( "rebuildtextindex.inc" ); |
17 | 17 | require_once( "rebuildrecentchanges.inc" ); |
18 | 18 | |
19 | | -$database = Database::newFromParams( $wgDBserver, $wgDBport, wgDBadminuser, $wgDBadminpassword, $wgDBname ); |
| 19 | +$database = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); |
20 | 20 | |
21 | 21 | print "** Rebuilding fulltext search index (if you abort this will break searching; run this script again to fix):\n"; |
22 | 22 | dropTextIndex( $database ); |
Index: trunk/phase3/maintenance/rebuildtextindex.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | require_once( "rebuildtextindex.inc" ); |
15 | 15 | $wgTitle = Title::newFromText( "Rebuild text index script" ); |
16 | 16 | |
17 | | -$database = Database::newFromParams( $wgDBserver, $wgDBport, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); |
| 17 | +$database = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); |
18 | 18 | |
19 | 19 | dropTextIndex( $database ); |
20 | 20 | rebuildTextIndex( $database ); |
Index: trunk/phase3/maintenance/convertLinks.inc |
— | — | @@ -8,14 +8,14 @@ |
9 | 9 | /** */ |
10 | 10 | function convertLinks() { |
11 | 11 | global $wgDBtype; |
12 | | - if( $wgDBtype == 'Postgres' ) { |
| 12 | + if( $wgDBtype == 'PostgreSQL' ) { |
13 | 13 | print "Links table already ok on PostgreSQL.\n"; |
14 | 14 | return; |
15 | 15 | } |
16 | 16 | |
17 | 17 | print "Converting links table to ID-ID...\n"; |
18 | 18 | |
19 | | - global $wgLang, $wgDBserver, $wgDBport, $wgDBadminuser, $wgDBadminpassword, $wgDBname; |
| 19 | + global $wgLang, $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname; |
20 | 20 | global $noKeys, $logPerformance, $fh; |
21 | 21 | |
22 | 22 | $numRows = $tuplesAdded = $numBadLinks = $curRowsRead = 0; #counters etc |
— | — | @@ -147,7 +147,7 @@ |
148 | 148 | #-------------------------------------------------------------------- |
149 | 149 | |
150 | 150 | if ( $overwriteLinksTable ) { |
151 | | - $dbConn = Database::newFromParams( $wgDBserver, $wgDBport, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); |
| 151 | + $dbConn = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); |
152 | 152 | if (!($dbConn->isOpen())) { |
153 | 153 | print "Opening connection to database failed.\n"; |
154 | 154 | return; |
— | — | @@ -174,9 +174,9 @@ |
175 | 175 | #-------------------------------------------------------------------- |
176 | 176 | |
177 | 177 | function createTempTable() { |
178 | | - global $wgDBserver, $wgDBport, $wgDBadminuser, $wgDBadminpassword, $wgDBname; |
| 178 | + global $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname; |
179 | 179 | global $noKeys; |
180 | | - $dbConn = Database::newFromParams( $wgDBserver, $wgDBport, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); |
| 180 | + $dbConn = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); |
181 | 181 | |
182 | 182 | if (!($dbConn->isOpen())) { |
183 | 183 | print "Opening connection to database failed.\n"; |
Index: trunk/phase3/maintenance/tables.sql |
— | — | @@ -995,4 +995,4 @@ |
996 | 996 | |
997 | 997 | UNIQUE KEY ( qci_type ) |
998 | 998 | |
999 | | -) TYPE=InnoDB; |
| 999 | +) TYPE=InnoDB; |
\ No newline at end of file |
Index: trunk/phase3/tests/LocalTestSettings.sample |
— | — | @@ -12,19 +12,16 @@ |
13 | 13 | $testOptions = array( |
14 | 14 | 'mysql3' => array( |
15 | 15 | 'server' => null, |
16 | | - 'port' => null, |
17 | 16 | 'user' => null, |
18 | 17 | 'password' => null, |
19 | 18 | 'database' => null ), |
20 | 19 | 'mysql4' => array( |
21 | 20 | 'server' => null, |
22 | | - 'port' => null, |
23 | 21 | 'user' => null, |
24 | 22 | 'password' => null, |
25 | 23 | 'database' => null ), |
26 | 24 | 'postgres' => array( |
27 | 25 | 'server' => null, |
28 | | - 'port' => null, |
29 | 26 | 'user' => null, |
30 | 27 | 'password' => null, |
31 | 28 | 'database' => null ), |
Index: trunk/phase3/tests/RunTests.php |
— | — | @@ -14,15 +14,13 @@ |
15 | 15 | |
16 | 16 | $testOptions = array( |
17 | 17 | 'mysql4' => array( |
18 | | - 'server' => null, |
19 | | - 'port' => null, |
20 | | - 'user' => null, |
| 18 | + 'server' => null, |
| 19 | + 'user' => null, |
21 | 20 | 'password' => null, |
22 | 21 | 'database' => null ), |
23 | 22 | 'postgres' => array( |
24 | | - 'server' => null, |
25 | | - 'port' => null |
26 | | - 'user' => null, |
| 23 | + 'server' => null, |
| 24 | + 'user' => null, |
27 | 25 | 'password' => null, |
28 | 26 | 'database' => null ), |
29 | 27 | ); |
Index: trunk/phase3/config/index.php |
— | — | @@ -476,13 +476,13 @@ |
477 | 477 | |
478 | 478 | <?php |
479 | 479 | $conf->DBserver = importPost( "DBserver", "localhost" ); |
480 | | - $conf->DBport = importPost( "DBport", "5432" ); |
481 | 480 | $conf->DBname = importPost( "DBname", "wikidb" ); |
482 | 481 | $conf->DBuser = importPost( "DBuser", "wikiuser" ); |
483 | 482 | $conf->DBpassword = importPost( "DBpassword" ); |
484 | 483 | $conf->DBpassword2 = importPost( "DBpassword2" ); |
485 | 484 | $conf->DBprefix = importPost( "DBprefix" ); |
486 | 485 | $conf->DBschema = importPost( "DBschema", "mediawiki" ); |
| 486 | + $conf->DBport = importPost( "DBport", "5432" ); |
487 | 487 | $conf->DBmysql5 = (importPost( "DBmysql5" ) == "true") ? "true" : "false"; |
488 | 488 | $conf->RootUser = importPost( "RootUser", "root" ); |
489 | 489 | $conf->RootPW = importPost( "RootPW", "-" ); |
— | — | @@ -620,7 +620,7 @@ |
621 | 621 | |
622 | 622 | # Attempt to connect |
623 | 623 | 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 ); |
625 | 625 | |
626 | 626 | # Check the connection and respond to errors |
627 | 627 | if( $wgDatabase->isOpen() ) { |
— | — | @@ -664,7 +664,7 @@ |
665 | 665 | |
666 | 666 | } else /* not mysql */ { |
667 | 667 | 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); |
669 | 669 | if (!$wgDatabase->isOpen()) { |
670 | 670 | print " error: " . $wgDatabase->lastError() . "</li>\n"; |
671 | 671 | } else { |
— | — | @@ -728,7 +728,7 @@ |
729 | 729 | |
730 | 730 | # Create user if required |
731 | 731 | if ( $conf->Root ) { |
732 | | - $conn = $dbc->newFromParams( $wgDBserver, $wgDBport, $wgDBuser, $wgDBpassword, $wgDBname, 1 ); |
| 732 | + $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 ); |
733 | 733 | if ( $conn->isOpen() ) { |
734 | 734 | print "<li>DB user account ok</li>\n"; |
735 | 735 | $conn->close(); |
— | — | @@ -785,7 +785,7 @@ |
786 | 786 | # Set up the "regular user" account *if we can, and if we need to* |
787 | 787 | if( $conf->Root ) { |
788 | 788 | # See if we need to |
789 | | - $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBport, $wgDBuser, $wgDBpassword, $wgDBname, 1 ); |
| 789 | + $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 ); |
790 | 790 | if( $wgDatabase2->isOpen() ) { |
791 | 791 | # Nope, just close the test connection and continue |
792 | 792 | $wgDatabase2->close(); |
— | — | @@ -1340,7 +1340,6 @@ |
1341 | 1341 | \$wgEmailAuthentication = $eauthent; |
1342 | 1342 | |
1343 | 1343 | \$wgDBserver = \"{$slconf['DBserver']}\"; |
1344 | | -\$wgDBport = \"{$slconf['DBport']}\"; |
1345 | 1344 | \$wgDBname = \"{$slconf['DBname']}\"; |
1346 | 1345 | \$wgDBuser = \"{$slconf['DBuser']}\"; |
1347 | 1346 | \$wgDBpassword = \"{$slconf['DBpassword']}\"; |
Index: trunk/phase3/includes/DatabaseOracle.php |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | Database::Database( $server, $user, $password, $dbName, $failFunction, $flags, $tablePrefix ); |
42 | 42 | } |
43 | 43 | |
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, |
45 | 45 | $failFunction = false, $flags = 0, $tablePrefix = 'get from global' ) |
46 | 46 | { |
47 | 47 | return new DatabaseOracle( $server, $user, $password, $dbName, $failFunction, $flags, $tablePrefix ); |
Index: trunk/phase3/includes/Setup.php |
— | — | @@ -147,7 +147,6 @@ |
148 | 148 | if ( !$wgDBservers ) { |
149 | 149 | $wgDBservers = array(array( |
150 | 150 | 'host' => $wgDBserver, |
151 | | - 'port' => $wgDBport, |
152 | 151 | 'user' => $wgDBuser, |
153 | 152 | 'password' => $wgDBpassword, |
154 | 153 | 'dbname' => $wgDBname, |
Index: trunk/phase3/includes/DatabasePostgres.php |
— | — | @@ -7,6 +7,9 @@ |
8 | 8 | * than MySQL ones, some of them should be moved to parent |
9 | 9 | * Database class. |
10 | 10 | * |
| 11 | + * STATUS: Working PG implementation of MediaWiki |
| 12 | + * TODO: Installer support |
| 13 | + * |
11 | 14 | * @package MediaWiki |
12 | 15 | */ |
13 | 16 | |
— | — | @@ -15,28 +18,31 @@ |
16 | 19 | */ |
17 | 20 | require_once( 'Database.php' ); |
18 | 21 | |
| 22 | +/** |
| 23 | + * |
| 24 | + * @package MediaWiki |
| 25 | + */ |
19 | 26 | class DatabasePostgres extends Database { |
20 | 27 | var $mInsertId = NULL; |
21 | 28 | var $mLastResult = NULL; |
22 | 29 | |
23 | | - function DatabasePostgres($server = false, $port = false, $user = false, $password = false, $dbName = false, |
| 30 | + function DatabasePostgres($server = false, $user = false, $password = false, $dbName = false, |
24 | 31 | $failFunction = false, $flags = 0 ) |
25 | 32 | { |
26 | | - Database::__construct( $server, $port, $user, $password, $dbName, $failFunction, $flags ); |
| 33 | + Database::__construct( $server, $user, $password, $dbName, $failFunction, $flags ); |
27 | 34 | } |
28 | 35 | |
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, |
30 | 37 | $failFunction = false, $flags = 0) |
31 | 38 | { |
32 | | - return new DatabasePostgres( $server, $port, $user, $password, $dbName, $failFunction, $flags ); |
| 39 | + return new DatabasePostgres( $server, $user, $password, $dbName, $failFunction, $flags ); |
33 | 40 | } |
34 | 41 | |
35 | 42 | /** |
36 | 43 | * Usually aborts on failure |
37 | 44 | * If the failFunction is set to a non-zero integer, returns success |
38 | 45 | */ |
39 | | - function open( $server, $port, $user, $password, $dbName ) { |
40 | | - |
| 46 | + function open( $server, $user, $password, $dbName ) { |
41 | 47 | # Test for PostgreSQL support, to avoid suppressed fatal error |
42 | 48 | if ( !function_exists( 'pg_connect' ) ) { |
43 | 49 | throw new DBConnectionError( $this, "PostgreSQL functions missing, have you compiled PHP with the --with-pgsql option?\n" ); |
— | — | @@ -50,7 +56,6 @@ |
51 | 57 | $this->mPassword = $password; |
52 | 58 | $this->mDBname = $dbName; |
53 | 59 | $this->mSchemas = array($wgDBschema,'public'); |
54 | | - $this->mPort = $port; |
55 | 60 | |
56 | 61 | $success = false; |
57 | 62 | |
— | — | @@ -60,9 +65,6 @@ |
61 | 66 | if ($server!=false && $server!="") { |
62 | 67 | $hstring="host=$server "; |
63 | 68 | } |
64 | | - if ($port!=false && $port != '') { |
65 | | - $hstring .= "port=$port "; |
66 | | - } |
67 | 69 | |
68 | 70 | @$this->mConn = pg_connect("$hstring dbname=$dbName user=$user password=$password"); |
69 | 71 | if ( $this->mConn == false ) { |
— | — | @@ -195,7 +197,7 @@ |
196 | 198 | $n = pg_num_fields( $res ); |
197 | 199 | for( $i = 0; $i < $n; $i++ ) { |
198 | 200 | // 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" ); |
200 | 202 | $meta = mysql_fetch_field( $res, $i ); |
201 | 203 | if( $field == $meta->name ) { |
202 | 204 | return $meta; |
— | — | @@ -437,44 +439,6 @@ |
438 | 440 | $searchpath=$this->makeList($schemas,LIST_NAMES); |
439 | 441 | $this->query("SET search_path = $searchpath"); |
440 | 442 | } |
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 | | - |
479 | 443 | } |
480 | 444 | |
481 | 445 | ?> |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -433,13 +433,12 @@ |
434 | 434 | $wgDBserver = 'localhost'; |
435 | 435 | /** name of the database */ |
436 | 436 | $wgDBname = 'wikidb'; |
437 | | -/** port number for databases that use them (e.g. postgres) */ |
438 | | -$wgDBport = 5432; |
439 | 437 | /** */ |
440 | 438 | $wgDBconnection = ''; |
441 | 439 | /** Database username */ |
442 | 440 | $wgDBuser = 'wikiuser'; |
443 | 441 | /** Database type |
| 442 | + * "mysql" for working code and "PostgreSQL" for development/broken code |
444 | 443 | */ |
445 | 444 | $wgDBtype = "mysql"; |
446 | 445 | /** Search type |
Index: trunk/phase3/includes/Database.php |
— | — | @@ -240,7 +240,7 @@ |
241 | 241 | |
242 | 242 | protected $mLastQuery = ''; |
243 | 243 | |
244 | | - protected $mServer, $mPort, $mUser, $mPassword, $mConn = null, $mDBname; |
| 244 | + protected $mServer, $mUser, $mPassword, $mConn = null, $mDBname; |
245 | 245 | protected $mOut, $mOpened = false; |
246 | 246 | |
247 | 247 | protected $mFailFunction; |
— | — | @@ -371,7 +371,6 @@ |
372 | 372 | |
373 | 373 | /**@{{ |
374 | 374 | * @param string $server database server host |
375 | | - * @param string $port database server port |
376 | 375 | * @param string $user database user name |
377 | 376 | * @param string $password database user password |
378 | 377 | * @param string $dbname database name |
— | — | @@ -382,8 +381,8 @@ |
383 | 382 | * @param $flags |
384 | 383 | * @param $tablePrefix String: database table prefixes. By default use the prefix gave in LocalSettings.php |
385 | 384 | */ |
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' ) { |
388 | 387 | |
389 | 388 | global $wgOut, $wgDBprefix, $wgCommandLineMode; |
390 | 389 | # Can't get a reference if it hasn't been set yet |
— | — | @@ -417,8 +416,8 @@ |
418 | 417 | $this->mTablePrefix = $tablePrefix; |
419 | 418 | } |
420 | 419 | |
421 | | - if ( $server or $port) { |
422 | | - $this->open( $server, $port, $user, $password, $dbName ); |
| 420 | + if ( $server ) { |
| 421 | + $this->open( $server, $user, $password, $dbName ); |
423 | 422 | } |
424 | 423 | } |
425 | 424 | |
— | — | @@ -427,17 +426,17 @@ |
428 | 427 | * @param failFunction |
429 | 428 | * @param $flags |
430 | 429 | */ |
431 | | - static function newFromParams( $server, $port, $user, $password, $dbName, |
| 430 | + static function newFromParams( $server, $user, $password, $dbName, |
432 | 431 | $failFunction = false, $flags = 0 ) |
433 | 432 | { |
434 | | - return new Database( $server, $port, $user, $password, $dbName, $failFunction, $flags ); |
| 433 | + return new Database( $server, $user, $password, $dbName, $failFunction, $flags ); |
435 | 434 | } |
436 | 435 | |
437 | 436 | /** |
438 | 437 | * Usually aborts on failure |
439 | 438 | * If the failFunction is set to a non-zero integer, returns success |
440 | 439 | */ |
441 | | - function open( $server, $port, $user, $password, $dbName ) { |
| 440 | + function open( $server, $user, $password, $dbName ) { |
442 | 441 | global $wguname; |
443 | 442 | |
444 | 443 | # Test for missing mysql.so |
— | — | @@ -1924,7 +1923,7 @@ |
1925 | 1924 | */ |
1926 | 1925 | protected function replaceVars( $ins ) { |
1927 | 1926 | $varnames = array( |
1928 | | - 'wgDBserver', 'wgDBport', 'wgDBname', 'wgDBintlname', 'wgDBuser', |
| 1927 | + 'wgDBserver', 'wgDBname', 'wgDBintlname', 'wgDBuser', |
1929 | 1928 | 'wgDBpassword', 'wgDBsqluser', 'wgDBsqlpassword', |
1930 | 1929 | 'wgDBadminuser', 'wgDBadminpassword', |
1931 | 1930 | ); |