http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72166

Revision: 72166
Author:   leonsp
Date:     2010-09-01 21:06:42 +0000 (Wed, 01 Sep 2010)

Log Message:
-----------
Completed removal of $wgDBport_db2 in favour of regular $wgDBport begun by 
platonides in r69918.
Removed $wgDBcataloged based on discussion with platonides for r45755. All DB2 
connections are now uncataloged. There is no performance difference.
Now using DB2 persistent connections.
Removed uniqueness constraint on user_groups table index in DB2 schema.

Modified Paths:
--------------
    trunk/phase3/config/Installer.php
    trunk/phase3/includes/db/DatabaseIbm_db2.php
    trunk/phase3/maintenance/ibm_db2/tables.sql

Modified: trunk/phase3/config/Installer.php
===================================================================
--- trunk/phase3/config/Installer.php   2010-09-01 21:05:53 UTC (rev 72165)
+++ trunk/phase3/config/Installer.php   2010-09-01 21:06:42 UTC (rev 72166)
@@ -644,9 +644,6 @@
        $conf->SQLiteDataDir = importPost( "SQLiteDataDir", "$IP/../data" );
 
        ## DB2 specific:
-       // New variable in order to have a different default port number
-       $conf->DBport_db2   = importPost( "DBport_db2",      "50000" );
-       $conf->DBcataloged  = importPost( "DBcataloged",  "cataloged" );
        $conf->DBdb2schema  = importPost( "DBdb2schema",  "mediawiki" );
 
        // Oracle specific
@@ -837,7 +834,6 @@
                }
 
                ## DB2 specific:
-               $wgDBcataloged = $conf->DBcataloged;
 
                $wgCommandLineMode = true;
                if (! defined ( 'STDERR' ) )
@@ -1711,16 +1707,14 @@
        
        <?php database_switcher($ourdb, 'ibm_db2'); ?>
        <div class="config-input"><?php
-               aField( $conf, "DBport_db2", "Database port:" );
+               aField( $conf, "DBport", "Database port:" );
        ?></div>
+       <div class="config-desc">
+               <p>50000 is the usual DB2 port.</p>
+       </div>
        <div class="config-input"><?php
                aField( $conf, "DBdb2schema", "Schema for mediawiki:" );
        ?></div>
-       <div>Select one:</div>
-               <ul class="plain">
-               <li><?php aField( $conf, "DBcataloged", "Cataloged (DB2 
installed locally)", "radio", "cataloged" ); ?></li>
-               <li><?php aField( $conf, "DBcataloged", "Uncataloged (remote 
DB2 through ODBC)", "radio", "uncataloged" ); ?></li>
-               </ul>
        <div class="config-desc">
                <p>If you need to share one database between multiple wikis, or
                between MediaWiki and another web application, you may specify
@@ -1913,9 +1907,8 @@
        } elseif( $conf->DBtype == 'ibm_db2' ) {
                $dbsettings =
 "# DB2 specific settings
-\$wgDBport       = \"{$slconf['DBport_db2']}\";
-\$wgDBmwschema       = \"{$slconf['DBdb2schema']}\";
-\$wgDBcataloged      = \"{$slconf['DBcataloged']}\";";
+\$wgDBport       = \"{$slconf['DBport']}\";
+\$wgDBmwschema       = \"{$slconf['DBdb2schema']}\";";
        } elseif( $conf->DBtype == 'oracle' ) {
                $dbsettings =
 "# Oracle specific settings

Modified: trunk/phase3/includes/db/DatabaseIbm_db2.php
===================================================================
--- trunk/phase3/includes/db/DatabaseIbm_db2.php        2010-09-01 21:05:53 UTC 
(rev 72165)
+++ trunk/phase3/includes/db/DatabaseIbm_db2.php        2010-09-01 21:06:42 UTC 
(rev 72166)
@@ -122,10 +122,8 @@
         *
         */
        
-       /// Server port for uncataloged connections
+       /// Server port
        protected $mPort = null;
-       /// Whether connection is cataloged
-       protected $mCataloged = null;
        /// Schema for tables, stored procedures, triggers
        protected $mSchema = null;
        /// Whether the schema has been applied in this session
@@ -143,8 +141,6 @@
        public $mStmtOptions = array();
        
        
-       const CATALOGED = "cataloged";
-       const UNCATALOGED = "uncataloged";
        const USE_GLOBAL = "get from global";
        
        const NONE_OPTION = 0x00;
@@ -461,7 +457,7 @@
        private function installPrint($string) {
                wfDebug("$string\n");
                if ($this->mMode == self::INSTALL_MODE) {
-                       print "<li>$string</li>";
+                       print "<li><pre>$string</pre></li>";
                        flush();
                } 
        }
@@ -478,7 +474,7 @@
        public function open( $server, $user, $password, $dbName )
        {
                // Load the port number
-               global $wgDBport, $wgDBcataloged;
+               global $wgDBport;
                wfProfileIn( __METHOD__ );
                
                // Load IBM DB2 driver if missing
@@ -503,14 +499,9 @@
                $this->mUser = $user;
                $this->mPassword = $password;
                $this->mDBname = $dbName;
-               $this->mCataloged = $cataloged = $wgDBcataloged;
                
-               if ( $cataloged == self::CATALOGED ) {
-                       $this->openCataloged($dbName, $user, $password);
-               }
-               elseif ( $cataloged == self::UNCATALOGED ) {
-                       $this->openUncataloged($dbName, $user, $password, 
$server, $port);
-               }
+               $this->openUncataloged($dbName, $user, $password, $server, 
$port);
+               
                // Apply connection config
                db2_set_option($this->mConn, $this->mConnOptions, 1);
                // Not all MediaWiki code is transactional
@@ -536,7 +527,7 @@
         */
        protected function openCataloged( $dbName, $user, $password )
        {
-               @$this->mConn = db2_connect($dbName, $user, $password);
+               @$this->mConn = db2_pconnect($dbName, $user, $password);
        }
        
        /**
@@ -552,7 +543,7 @@
                $str .= "UID=$user;";
                $str .= "PWD=$password;";
                
-               @$this->mConn = db2_connect($str, $user, $password);
+               @$this->mConn = db2_pconnect($str, $user, $password);
        }
        
        /**
@@ -902,11 +893,11 @@
                                        $list .= ", $field = ?";
                                }
                                else {
-                                       $list .= "( $field = ?";
+                                       $list .= "$field = ?";
                                  $first = false;
                                }
                        }
-                       $list .= ')';
+                       $list .= '';
                        
                        return $list;
                }
@@ -1473,15 +1464,8 @@
                // db2_ping() doesn't exist
                // Emulate
                $this->close();
-               if ($this->mCataloged == null) {
-                       return false;
-               }
-               else if ($this->mCataloged) {
-                       $this->mConn = $this->openCataloged($this->mDBName, 
$this->mUser, $this->mPassword);
-               }
-               else if (!$this->mCataloged) {
-                       $this->mConn = $this->openUncataloged($this->mDBName, 
$this->mUser, $this->mPassword, $this->mServer, $this->mPort);
-               }
+               $this->mConn = $this->openUncataloged($this->mDBName, 
$this->mUser, $this->mPassword, $this->mServer, $this->mPort);
+               
                return false;
        }
        ######################################
@@ -1706,6 +1690,9 @@
                        array_shift( $args );
                }
                $res = db2_execute($prepared, $args);
+               if ( !$res ) {
+                       $this->installPrint(db2_stmt_errormsg());
+               }
                return $res;
        }
 

Modified: trunk/phase3/maintenance/ibm_db2/tables.sql
===================================================================
--- trunk/phase3/maintenance/ibm_db2/tables.sql 2010-09-01 21:05:53 UTC (rev 
72165)
+++ trunk/phase3/maintenance/ibm_db2/tables.sql 2010-09-01 21:06:42 UTC (rev 
72166)
@@ -48,11 +48,7 @@
   --    REFERENCES user(user_id) ON DELETE CASCADE,
   ug_group  VARCHAR(255)     NOT NULL
 );
-CREATE UNIQUE INDEX user_groups_unique ON user_groups (ug_user, ug_group);
---leonsp:
-CREATE UNIQUE INDEX user_groups_include_idx
-       ON user_groups(ug_user)
-       INCLUDE (ug_group);
+CREATE INDEX user_groups_unique ON user_groups (ug_user, ug_group);
 
 
 CREATE TABLE user_newtalk (



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to