Revert to r15092; massive breakage, unable to connect to MySQL at all
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 27 Jun 2006 16:11:47 +0000 (16:11 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 27 Jun 2006 16:11:47 +0000 (16:11 +0000)
13 files changed:
config/index.php
includes/Database.php
includes/DatabaseOracle.php
includes/DatabasePostgres.php
includes/DefaultSettings.php
includes/Setup.php
maintenance/convertLinks.inc
maintenance/rebuildall.php
maintenance/rebuildtextindex.php
maintenance/tables.sql
maintenance/update.php
tests/LocalTestSettings.sample
tests/RunTests.php

index 04bccf9..5deff4d 100644 (file)
@@ -476,13 +476,13 @@ print "<li style='font-weight:bold;color:green;font-size:110%'>Environment check
 
 <?php
        $conf->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( "<li>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( "<li>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() . "</li>\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 "<li>DB user account ok</li>\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']}\";
index 8af3ce1..fc2d67d 100644 (file)
@@ -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',
                );
index 8e2b542..d5d7379 100644 (file)
@@ -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 );
index 0635847..e904949 100644 (file)
@@ -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
  */
 
  */
 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;
-               }
-       }
-
-
-
-
 }
 
 ?>
index 132b937..b5ec472 100644 (file)
@@ -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
index 5c7ae1b..ea70968 100644 (file)
@@ -147,7 +147,6 @@ wfProfileIn( $fname.'-database' );
 if ( !$wgDBservers ) {
        $wgDBservers = array(array(
                'host' => $wgDBserver,
-               'port' => $wgDBport,
                'user' => $wgDBuser,
                'password' => $wgDBpassword,
                'dbname' => $wgDBname,
index df682f1..f0d2c43 100644 (file)
@@ -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";
index 5765465..7c44e30 100644 (file)
@@ -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 );
index dc8bd10..54672d2 100644 (file)
@@ -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 );
index fca4d97..5dd851f 100644 (file)
@@ -995,4 +995,4 @@ CREATE TABLE /*$wgDBprefix*/querycache_info (
 
        UNIQUE KEY ( qci_type )
 
-) TYPE=InnoDB;
+) TYPE=InnoDB;
\ No newline at end of file
index a73cf5e..8643aa7 100644 (file)
@@ -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
index d915fed..7ada2fd 100644 (file)
@@ -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 ),
index 8b4f1c7..ec04fc0 100644 (file)
@@ -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 ),
        );