Replace direct mysql_xxx() calls with query_xxx() calls. Replace calls to mysql_insert_id()

with calls specific to the appdb or bugzilla database. Fixes a bug where a call to
mysql_insert_id() can potentially retrieve an id from either the bugzilla or appdb database,
depending on whichever database was last opened by mysql_connect().
This commit is contained in:
Chris Morgan
2007-08-03 23:27:25 +00:00
committed by WineHQ
parent 03dca3cabd
commit 6119246b51
54 changed files with 343 additions and 295 deletions

View File

@@ -117,7 +117,7 @@ class table_counts
{
$sQuery = "select count(*) as cnt from ?;";
$hResult = query_parameters($sQuery, $sTable);
$oRow = mysql_fetch_object($hResult);
$oRow = query_fetch_object($hResult);
$this->aTableCounts[] = $oRow->cnt;
}

View File

@@ -62,7 +62,7 @@ function test_application_delete()
if($hResult = query_parameters($sQuery, $iAppId))
{
$iRows = mysql_num_rows($hResult);
$iRows = query_num_rows($hResult);
if($iRows > 0)
{
echo "Found '".$iRows."' versions for this application left over!";

View File

@@ -555,7 +555,7 @@ function test_maintainer_getMaintainersForAppIdVersionId()
/* The application should have one maintainer */
$iExpected = 1;
$iReceived = mysql_num_rows($hResult);
$iReceived = query_num_rows($hResult);
if($iExpected != $iReceived)
{
error("Got super maintainer count of $iReceived instead of $iExpected!");
@@ -575,7 +575,7 @@ function test_maintainer_getMaintainersForAppIdVersionId()
/* The version should have one maintainer */
$iExpected = 1;
$iReceived = mysql_num_rows($hResult);
$iReceived = query_num_rows($hResult);
if($iExpected != $iReceived)
{
error("Got maintainer count of $iReceived instead of $iExpected!");
@@ -614,7 +614,7 @@ function test_maintainer_getMaintainersForAppIdVersionId()
/* The first version should have one maintainer */
$iExpected = 1;
$iReceived = mysql_num_rows($hResult);
$iReceived = query_num_rows($hResult);
if($iExpected != $iReceived)
{
error("Got maintainer count of $iReceived instead of $iExpected!");
@@ -634,7 +634,7 @@ function test_maintainer_getMaintainersForAppIdVersionId()
/* The second version should have 1 maintainer */
$iExpected = 1;
$iReceived = mysql_num_rows($hResult);
$iReceived = query_num_rows($hResult);
if($iExpected != $iReceived)
{
error("Got maintainer count of $iReceived instead of $iExpected!");

View File

@@ -130,7 +130,7 @@ class notifyContainer
{
$sQuery2 = "select * from appMaintainers where maintainerId = '?'";
$hResult = query_parameters($sQuery2, $this->oMaintainer->iMaintainerId);
$oObject = mysql_fetch_object($hResult);
$oObject = query_fetch_object($hResult);
print_r($oObject);
}
@@ -317,7 +317,7 @@ function test_maintainer_notifyLevel_2_to_3($bTestAsMaintainer)
// check to make sure the maintainer doesn't exist
$sQuery = "select count(*) as cnt from appMaintainers where maintainerId = '?'";
$hResult = query_parameters($sQuery, $oNotifyContainer->oMaintainer->iMaintainerId);
$oRow = mysql_fetch_object($hResult);
$oRow = query_fetch_object($hResult);
if($oRow->cnt != 0)
{
$bSuccess = false;

View File

@@ -54,15 +54,15 @@ function test_class($sClassName, $aTestMethods)
if(!$hResult)
{
error("Got '$hResult' instead of a valid MySQL handle");
error("Got '$hResult' instead of a valid query handle");
error("FAILED\t\t$sClassName::$sClassName");
$oTestObject->delete();
return FALSE;
}
if(!($oRow = mysql_fetch_object($hResult)))
if(!($oRow = query_fetch_object($hResult)))
{
error("Failed to fetch MySQL object");
error("Failed to fetch query object");
error("FAILED\t\t$sClassName::$sClassName");
$oTestObject->delete();
return FALSE;
@@ -111,7 +111,7 @@ function test_class($sClassName, $aTestMethods)
/* Should return 1 or more, since there may be entries present already */
$iExpected = 1;
$hResult = $oTestObject->objectGetEntries(false, false);
$iReceived = mysql_num_rows($hResult);
$iReceived = query_num_rows($hResult);
if($iExpected > $iReceived)
{
error("Got $iReceived instead of >= $iExpected");
@@ -223,7 +223,7 @@ function create_object($sClassName, $oUser)
error("FAILED\t\t$sClassName to create screenshot entry");
return FALSE;
}
$oTestObject->iScreenshotId = mysql_insert_id();
$oTestObject->iScreenshotId = query_appdb_insert_id();
}
return $oTestObject;

View File

@@ -30,7 +30,7 @@ function test_query_parameters()
return false;
}
$oRow = mysql_fetch_object($hResult);
$oRow = query_fetch_object($hResult);
$iUserCount = $oRow->count;
/* see that '~' strings are replaced with parameters */
@@ -41,7 +41,7 @@ function test_query_parameters()
$hResult = query_parameters($sQuery, "user_list", "1' OR 1='1");
if($hResult)
{
$oRow = mysql_fetch_object($hResult);
$oRow = query_fetch_object($hResult);
if($iUserCount != $oRow->count)
{
echo "sQuery of '".$sQuery."' returned ".$oRow->count." entries instead of the expected ".$iUserCount."\n";
@@ -88,7 +88,7 @@ function test_query_parameters()
* properly with slashes in the query, they were incorrectly being recognized
* as tokens that should be replaced with parameters
*/
$sQuery = "SELECT count(*) as count, '".mysql_real_escape_string("\r\n")."' as x from ?";
$sQuery = "SELECT count(*) as count, '".query_escape_string("\r\n")."' as x from ?";
$hResult = query_parameters($sQuery, "user_list");
if(!$hResult)
{

View File

@@ -19,13 +19,13 @@ function test_user_password_migration()
// generate the SHA1() of the users password
$sQuery = "select SHA1('?') as password;";
$hResult = query_parameters($sQuery, $sTestPassword);
$oRow = mysql_fetch_object($hResult);
$oRow = query_fetch_object($hResult);
$sTestUserPasswordSHA1 = $oRow->password;
// test that the user was created with the sha1 hash of their password
$sQuery = "select password from user_list where userid = '?';";
$hResult = query_parameters($sQuery, $oUser->iUserId);
$oRow = mysql_fetch_object($hResult);
$oRow = query_fetch_object($hResult);
if($sTestUserPasswordSHA1 != $oRow->password)
{
error("sTestUserPasswordSHA1 $sTestUserPasswordSHA1 doesn't match oRow->password of $oRow->password after user::create()");
@@ -56,7 +56,7 @@ function test_user_password_migration()
// after the user was logged in
$sQuery = "select password from user_list where userid = '?';";
$hResult = query_parameters($sQuery, $oUser->iUserId);
$oRow = mysql_fetch_object($hResult);
$oRow = query_fetch_object($hResult);
if($sTestUserPasswordSHA1 != $oRow->password)
{
error("sTestUserPasswordSHA1 $sTestUserPasswordSHA1 doesn't match oRow->password of $oRow->password");