From: Brion Vibber Date: Tue, 27 Jun 2006 16:11:47 +0000 (+0000) Subject: Revert to r15092; massive breakage, unable to connect to MySQL at all X-Git-Tag: 1.31.0-rc.0~56573 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=908c51e1273588b97afe6a218952cfde20a4fe7d;p=lhc%2Fweb%2Fwiklou.git Revert to r15092; massive breakage, unable to connect to MySQL at all --- diff --git a/config/index.php b/config/index.php index 04bccf928a..5deff4df54 100644 --- a/config/index.php +++ b/config/index.php @@ -476,13 +476,13 @@ print "
  • Environment check DBserver = importPost( "DBserver", "localhost" ); - $conf->DBport = importPost( "DBport", "5432" ); $conf->DBname = importPost( "DBname", "wikidb" ); $conf->DBuser = importPost( "DBuser", "wikiuser" ); $conf->DBpassword = importPost( "DBpassword" ); $conf->DBpassword2 = importPost( "DBpassword2" ); $conf->DBprefix = importPost( "DBprefix" ); $conf->DBschema = importPost( "DBschema", "mediawiki" ); + $conf->DBport = importPost( "DBport", "5432" ); $conf->DBmysql5 = (importPost( "DBmysql5" ) == "true") ? "true" : "false"; $conf->RootUser = importPost( "RootUser", "root" ); $conf->RootPW = importPost( "RootPW", "-" ); @@ -620,7 +620,7 @@ error_reporting( E_ALL ); # Attempt to connect echo( "
  • Attempting to connect to database server as $db_user..." ); - $wgDatabase = Database::newFromParams( $wgDBserver, $wgDBport, $db_user, $db_pass, '', 1 ); + $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 ); # Check the connection and respond to errors if( $wgDatabase->isOpen() ) { @@ -664,7 +664,7 @@ error_reporting( E_ALL ); } else /* not mysql */ { echo( "
  • Attempting to connect to database server as $wgDBuser..." ); - $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBport, $wgDBuser, $wgDBpassword, $wgDBname, 1); + $wgDatabase = $dbc->newFromParams($wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1); if (!$wgDatabase->isOpen()) { print " error: " . $wgDatabase->lastError() . "
  • \n"; } else { @@ -728,7 +728,7 @@ error_reporting( E_ALL ); # Create user if required if ( $conf->Root ) { - $conn = $dbc->newFromParams( $wgDBserver, $wgDBport, $wgDBuser, $wgDBpassword, $wgDBname, 1 ); + $conn = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 ); if ( $conn->isOpen() ) { print "
  • DB user account ok
  • \n"; $conn->close(); @@ -785,7 +785,7 @@ error_reporting( E_ALL ); # Set up the "regular user" account *if we can, and if we need to* if( $conf->Root ) { # See if we need to - $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBport, $wgDBuser, $wgDBpassword, $wgDBname, 1 ); + $wgDatabase2 = $dbc->newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 ); if( $wgDatabase2->isOpen() ) { # Nope, just close the test connection and continue $wgDatabase2->close(); @@ -1340,7 +1340,6 @@ if ( \$wgCommandLineMode ) { \$wgEmailAuthentication = $eauthent; \$wgDBserver = \"{$slconf['DBserver']}\"; -\$wgDBport = \"{$slconf['DBport']}\"; \$wgDBname = \"{$slconf['DBname']}\"; \$wgDBuser = \"{$slconf['DBuser']}\"; \$wgDBpassword = \"{$slconf['DBpassword']}\"; diff --git a/includes/Database.php b/includes/Database.php index 8af3ce146b..fc2d67d77e 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -240,7 +240,7 @@ class Database { protected $mLastQuery = ''; - protected $mServer, $mPort, $mUser, $mPassword, $mConn = null, $mDBname; + protected $mServer, $mUser, $mPassword, $mConn = null, $mDBname; protected $mOut, $mOpened = false; protected $mFailFunction; @@ -371,7 +371,6 @@ class Database { /**@{{ * @param string $server database server host - * @param string $port database server port * @param string $user database user name * @param string $password database user password * @param string $dbname database name @@ -382,8 +381,8 @@ class Database { * @param $flags * @param $tablePrefix String: database table prefixes. By default use the prefix gave in LocalSettings.php */ - function __construct( $server = false, $port = false, $user = false, $password = false, $dbName = false, - $failFunction = false, $flags = 0, $tablePrefix = 'get from global') { + function __construct( $server = false, $user = false, $password = false, $dbName = false, + $failFunction = false, $flags = 0, $tablePrefix = 'get from global' ) { global $wgOut, $wgDBprefix, $wgCommandLineMode; # Can't get a reference if it hasn't been set yet @@ -417,8 +416,8 @@ class Database { $this->mTablePrefix = $tablePrefix; } - if ( $server or $port) { - $this->open( $server, $port, $user, $password, $dbName ); + if ( $server ) { + $this->open( $server, $user, $password, $dbName ); } } @@ -427,17 +426,17 @@ class Database { * @param failFunction * @param $flags */ - static function newFromParams( $server, $port, $user, $password, $dbName, + static function newFromParams( $server, $user, $password, $dbName, $failFunction = false, $flags = 0 ) { - return new Database( $server, $port, $user, $password, $dbName, $failFunction, $flags ); + return new Database( $server, $user, $password, $dbName, $failFunction, $flags ); } /** * Usually aborts on failure * If the failFunction is set to a non-zero integer, returns success */ - function open( $server, $port, $user, $password, $dbName ) { + function open( $server, $user, $password, $dbName ) { global $wguname; # Test for missing mysql.so @@ -1924,7 +1923,7 @@ class Database { */ protected function replaceVars( $ins ) { $varnames = array( - 'wgDBserver', 'wgDBport', 'wgDBname', 'wgDBintlname', 'wgDBuser', + 'wgDBserver', 'wgDBname', 'wgDBintlname', 'wgDBuser', 'wgDBpassword', 'wgDBsqluser', 'wgDBsqlpassword', 'wgDBadminuser', 'wgDBadminpassword', ); diff --git a/includes/DatabaseOracle.php b/includes/DatabaseOracle.php index 8e2b542d2a..d5d7379dc6 100644 --- a/includes/DatabaseOracle.php +++ b/includes/DatabaseOracle.php @@ -40,7 +40,7 @@ class DatabaseOracle extends Database { Database::Database( $server, $user, $password, $dbName, $failFunction, $flags, $tablePrefix ); } - /* static */ function newFromParams( $server = false, $port = false, $user = false, $password = false, $dbName = false, + /* static */ function newFromParams( $server = false, $user = false, $password = false, $dbName = false, $failFunction = false, $flags = 0, $tablePrefix = 'get from global' ) { return new DatabaseOracle( $server, $user, $password, $dbName, $failFunction, $flags, $tablePrefix ); diff --git a/includes/DatabasePostgres.php b/includes/DatabasePostgres.php index 0635847ae7..e904949aab 100644 --- a/includes/DatabasePostgres.php +++ b/includes/DatabasePostgres.php @@ -7,6 +7,9 @@ * than MySQL ones, some of them should be moved to parent * Database class. * + * STATUS: Working PG implementation of MediaWiki + * TODO: Installer support + * * @package MediaWiki */ @@ -15,28 +18,31 @@ */ require_once( 'Database.php' ); +/** + * + * @package MediaWiki + */ class DatabasePostgres extends Database { var $mInsertId = NULL; var $mLastResult = NULL; - function DatabasePostgres($server = false, $port = false, $user = false, $password = false, $dbName = false, + function DatabasePostgres($server = false, $user = false, $password = false, $dbName = false, $failFunction = false, $flags = 0 ) { - Database::__construct( $server, $port, $user, $password, $dbName, $failFunction, $flags ); + Database::__construct( $server, $user, $password, $dbName, $failFunction, $flags ); } - static function newFromParams( $server = false, $port = false, $user = false, $password = false, $dbName = false, + static function newFromParams( $server = false, $user = false, $password = false, $dbName = false, $failFunction = false, $flags = 0) { - return new DatabasePostgres( $server, $port, $user, $password, $dbName, $failFunction, $flags ); + return new DatabasePostgres( $server, $user, $password, $dbName, $failFunction, $flags ); } /** * Usually aborts on failure * If the failFunction is set to a non-zero integer, returns success */ - function open( $server, $port, $user, $password, $dbName ) { - + function open( $server, $user, $password, $dbName ) { # Test for PostgreSQL support, to avoid suppressed fatal error if ( !function_exists( 'pg_connect' ) ) { throw new DBConnectionError( $this, "PostgreSQL functions missing, have you compiled PHP with the --with-pgsql option?\n" ); @@ -50,7 +56,6 @@ class DatabasePostgres extends Database { $this->mPassword = $password; $this->mDBname = $dbName; $this->mSchemas = array($wgDBschema,'public'); - $this->mPort = $port; $success = false; @@ -60,9 +65,6 @@ class DatabasePostgres extends Database { if ($server!=false && $server!="") { $hstring="host=$server "; } - if ($port!=false && $port != '') { - $hstring .= "port=$port "; - } @$this->mConn = pg_connect("$hstring dbname=$dbName user=$user password=$password"); if ( $this->mConn == false ) { @@ -195,7 +197,7 @@ class DatabasePostgres extends Database { $n = pg_num_fields( $res ); for( $i = 0; $i < $n; $i++ ) { // FIXME - throw new DBUnexpectedError($this, "Database::fieldInfo() error : mysql_fetch_field() not implemented for postgres" ); + throw new DBUnexpectedError($this, "Database::fieldInfo() error : mysql_fetch_field() not implemented for postgre" ); $meta = mysql_fetch_field( $res, $i ); if( $field == $meta->name ) { return $meta; @@ -437,44 +439,6 @@ class DatabasePostgres extends Database { $searchpath=$this->makeList($schemas,LIST_NAMES); $this->query("SET search_path = $searchpath"); } - - - /** - * Query whether a given table exists - */ - function tableExists( $table ) { - global $wgDBschema; - $safetable = preg_replace("/'/", "''", $table); - $SQL = "SELECT 1 FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n WHERE c.relnamespace = n.oid " - . "AND c.relname = '$safetable' AND n.nspname = '$wgDBschema'"; - $res = $this->query($SQL); - if( $res ) { - $this->freeResult( $res ); - return true; - } else { - return false; - } - } - - function fieldExists( $table, $field, $fname = 'DatabasePostgres::fieldExists' ) { - global $wgDBschema; - $safetable = preg_replace("/'/", "''", $table); - $safecol = preg_replace("/'/", "''", $field); - $SQL = "SELECT 1 FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n, pg_attribute a " - . "WHERE c.relnamespace = n.oid AND c.relname = '$safetable' AND n.nspname = '$wgDBschema' " - . "AND a.attrelid = c.oid AND a.attname = '$safecol'"; - $res = $this->query($SQL, $fname); - if( $res ) { - $this->freeResult( $res ); - return true; - } else { - return false; - } - } - - - - } ?> diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 132b9374b2..b5ec472b19 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -433,13 +433,12 @@ $wgSMTP = false; $wgDBserver = 'localhost'; /** name of the database */ $wgDBname = 'wikidb'; -/** port number for databases that use them (e.g. postgres) */ -$wgDBport = 5432; /** */ $wgDBconnection = ''; /** Database username */ $wgDBuser = 'wikiuser'; /** Database type + * "mysql" for working code and "PostgreSQL" for development/broken code */ $wgDBtype = "mysql"; /** Search type diff --git a/includes/Setup.php b/includes/Setup.php index 5c7ae1b8e5..ea70968df1 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -147,7 +147,6 @@ wfProfileIn( $fname.'-database' ); if ( !$wgDBservers ) { $wgDBservers = array(array( 'host' => $wgDBserver, - 'port' => $wgDBport, 'user' => $wgDBuser, 'password' => $wgDBpassword, 'dbname' => $wgDBname, diff --git a/maintenance/convertLinks.inc b/maintenance/convertLinks.inc index df682f115f..f0d2c439fe 100644 --- a/maintenance/convertLinks.inc +++ b/maintenance/convertLinks.inc @@ -8,14 +8,14 @@ /** */ function convertLinks() { global $wgDBtype; - if( $wgDBtype == 'Postgres' ) { + if( $wgDBtype == 'PostgreSQL' ) { print "Links table already ok on PostgreSQL.\n"; return; } print "Converting links table to ID-ID...\n"; - global $wgLang, $wgDBserver, $wgDBport, $wgDBadminuser, $wgDBadminpassword, $wgDBname; + global $wgLang, $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname; global $noKeys, $logPerformance, $fh; $numRows = $tuplesAdded = $numBadLinks = $curRowsRead = 0; #counters etc @@ -147,7 +147,7 @@ function convertLinks() { #-------------------------------------------------------------------- if ( $overwriteLinksTable ) { - $dbConn = Database::newFromParams( $wgDBserver, $wgDBport, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); + $dbConn = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); if (!($dbConn->isOpen())) { print "Opening connection to database failed.\n"; return; @@ -174,9 +174,9 @@ function convertLinks() { #-------------------------------------------------------------------- function createTempTable() { - global $wgDBserver, $wgDBport, $wgDBadminuser, $wgDBadminpassword, $wgDBname; + global $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname; global $noKeys; - $dbConn = Database::newFromParams( $wgDBserver, $wgDBport, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); + $dbConn = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); if (!($dbConn->isOpen())) { print "Opening connection to database failed.\n"; diff --git a/maintenance/rebuildall.php b/maintenance/rebuildall.php index 5765465d95..7c44e30028 100644 --- a/maintenance/rebuildall.php +++ b/maintenance/rebuildall.php @@ -15,7 +15,7 @@ require_once( "refreshLinks.inc" ); require_once( "rebuildtextindex.inc" ); require_once( "rebuildrecentchanges.inc" ); -$database = Database::newFromParams( $wgDBserver, $wgDBport, wgDBadminuser, $wgDBadminpassword, $wgDBname ); +$database = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); print "** Rebuilding fulltext search index (if you abort this will break searching; run this script again to fix):\n"; dropTextIndex( $database ); diff --git a/maintenance/rebuildtextindex.php b/maintenance/rebuildtextindex.php index dc8bd102eb..54672d21d5 100644 --- a/maintenance/rebuildtextindex.php +++ b/maintenance/rebuildtextindex.php @@ -13,7 +13,7 @@ require_once( "commandLine.inc" ); require_once( "rebuildtextindex.inc" ); $wgTitle = Title::newFromText( "Rebuild text index script" ); -$database = Database::newFromParams( $wgDBserver, $wgDBport, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); +$database = Database::newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); dropTextIndex( $database ); rebuildTextIndex( $database ); diff --git a/maintenance/tables.sql b/maintenance/tables.sql index fca4d974e5..5dd851f530 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -995,4 +995,4 @@ CREATE TABLE /*$wgDBprefix*/querycache_info ( UNIQUE KEY ( qci_type ) -) TYPE=InnoDB; +) TYPE=InnoDB; \ No newline at end of file diff --git a/maintenance/update.php b/maintenance/update.php index a73cf5e60b..8643aa7927 100644 --- a/maintenance/update.php +++ b/maintenance/update.php @@ -32,7 +32,7 @@ if( !isset( $wgDBadminuser ) || !isset( $wgDBadminpassword ) ) { # Attempt to connect to the database as a privileged user # This will vomit up an error if there are permissions problems -$wgDatabase = $dbc->newFromParams( $wgDBserver, $wgDBport, $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1 ); +$wgDatabase = $dbc->newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1 ); if( !$wgDatabase->isOpen() ) { # Appears to have failed diff --git a/tests/LocalTestSettings.sample b/tests/LocalTestSettings.sample index d915feda5a..7ada2fda91 100644 --- a/tests/LocalTestSettings.sample +++ b/tests/LocalTestSettings.sample @@ -12,19 +12,16 @@ ini_set('include_path',ini_get('include_path').':'.$IP); $testOptions = array( 'mysql3' => array( 'server' => null, - 'port' => null, 'user' => null, 'password' => null, 'database' => null ), 'mysql4' => array( 'server' => null, - 'port' => null, 'user' => null, 'password' => null, 'database' => null ), 'postgres' => array( 'server' => null, - 'port' => null, 'user' => null, 'password' => null, 'database' => null ), diff --git a/tests/RunTests.php b/tests/RunTests.php index 8b4f1c762e..ec04fc037f 100644 --- a/tests/RunTests.php +++ b/tests/RunTests.php @@ -14,15 +14,13 @@ require_once( 'PHPUnit.php' ); $testOptions = array( 'mysql4' => array( - 'server' => null, - 'port' => null, - 'user' => null, + 'server' => null, + 'user' => null, 'password' => null, 'database' => null ), 'postgres' => array( - 'server' => null, - 'port' => null - 'user' => null, + 'server' => null, + 'user' => null, 'password' => null, 'database' => null ), );