From 63b84a95d4fd6a6820213a696e8a793fd62a85ca Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Thu, 11 Aug 2005 11:33:18 +0000 Subject: [PATCH] * (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 --- RELEASE-NOTES | 3 +++ includes/Database.php | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index aaf49805a9..321e2fe9b6 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/Database.php b/includes/Database.php index 543d4caf65..2b986a668f 100644 --- a/includes/Database.php +++ b/includes/Database.php @@ -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)"; } /** -- 2.20.1