* (bug 3056) MySQL 3 compatibility fix: USE INDEX instead of FORCE INDEX
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 11 Aug 2005 11:33:18 +0000 (11:33 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 11 Aug 2005 11:33:18 +0000 (11:33 +0000)
* PHP 4.1 compatibility fix: don't use new_link parameter to mysql_connect
  if running prior to 4.2.0 as it causes the call to fail

RELEASE-NOTES
includes/Database.php

index aaf4980..321e2fe 100644 (file)
@@ -13,6 +13,9 @@ Misc work going on.....
 * Rearranged Special:Movepage form to reduce confusion between destination
   title and reason input boxes
 * (bug 2527) Always set destination filename when new file is selected
+* (bug 3056) MySQL 3 compatibility fix: USE INDEX instead of FORCE INDEX
+* PHP 4.1 compatibility fix: don't use new_link parameter to mysql_connect
+  if running prior to 4.2.0 as it causes the call to fail
 
 
 === Caveats ===
index 543d4ca..2b986a6 100644 (file)
@@ -53,7 +53,7 @@ class Database {
         */
        var $mLastQuery = '';
 
-       var $mServer, $mUser, $mPassword, $mConn, $mDBname;
+       var $mServer, $mUser, $mPassword, $mConn = null, $mDBname;
        var $mOut, $mOpened = false;
 
        var $mFailFunction;
@@ -231,7 +231,14 @@ class Database {
                        @/**/$this->mConn = mysql_pconnect( $server, $user, $password );
                } else {
                        # Create a new connection...
-                       @/**/$this->mConn = mysql_connect( $server, $user, $password, true );
+                       if( version_compare( PHP_VERSION, '4.2.0', 'ge' ) ) {
+                               @/**/$this->mConn = mysql_connect( $server, $user, $password, true );
+                       } else {
+                               # On PHP 4.1 the new_link parameter is not available. We cannot
+                               # guarantee that we'll actually get a new connection, and this
+                               # may cause some operations to fail possibly.
+                               @/**/$this->mConn = mysql_connect( $server, $user, $password );
+                       }
                }
 
                if ( $dbName != '' ) {
@@ -1151,7 +1158,10 @@ class Database {
         * PostgreSQL doesn't have them and returns ""
         */
        function useIndexClause( $index ) {
-               return "FORCE INDEX ($index)";
+               global $wgDBmysql4;
+               return $wgDBmysql4
+                       ? "FORCE INDEX ($index)"
+                       : "USE INDEX ($index)";
        }
 
        /**