Fix maintainer listing for versions. getMaintainersForAppIdVersionId() did not check that

additional entries had a superMaintainer = 1 so a maintainer of one version would be listed
as the maintainer for all versions of the application. Correct that issue and update the
unit test.
This commit is contained in:
Alexander Nicolaysen Sørnes
2007-04-16 23:19:44 +00:00
committed by WineHQ
parent 46df59f063
commit b584fe1df7
2 changed files with 28 additions and 5 deletions

View File

@@ -396,9 +396,19 @@ class maintainer
if($iVersionId) if($iVersionId)
{ {
$hResult = query_parameters("SELECT userId from appMaintainers, appVersion $hResult = query_parameters("SELECT userId from appMaintainers, appVersion
WHERE appMaintainers.queued = 'false' AND appVersion.versionId = '?' WHERE
AND ((appMaintainers.versionId = appVersion.versionId) OR appMaintainers.queued = 'false'
(appMaintainers.appId = appVersion.appId))", $iVersionId); AND
appVersion.versionId = '?'
AND
(
appMaintainers.versionId = appVersion.versionId
OR
(
appMaintainers.appId = appVersion.appId
AND superMaintainer = '1'
)
)", $iVersionId);
} }
/* /*
* If versionId was not supplied we fetch supermaintainers of application and maintainer of all versions. * If versionId was not supplied we fetch supermaintainers of application and maintainer of all versions.

View File

@@ -461,6 +461,10 @@ function test_maintainer_getMaintainersForAppIdVersionId()
$oUser->addPriv("admin"); $oUser->addPriv("admin");
$oSecondUser = new user();
$oSecondUser->iUserId = $oUser->iUserId + 1;
$oSecondUser->addPriv("admin");
$oApp = new application(); $oApp = new application();
$oApp->create(); $oApp->create();
$oFirstVersion = new version(); $oFirstVersion = new version();
@@ -519,6 +523,15 @@ function test_maintainer_getMaintainersForAppIdVersionId()
$oFirstVersionMaintainer->iUserId = $oUser->iUserId; $oFirstVersionMaintainer->iUserId = $oUser->iUserId;
$oFirstVersionMaintainer->create(); $oFirstVersionMaintainer->create();
/* Become a maintainer for the other version */
$oSecondVersionMaintainer = new maintainer();
$oSecondVersionMaintainer->sMaintainReason = "I need it";
$oSecondVersionMaintainer->iVersionId = $oSecondVersion->iVersionId;
$oSecondVersionMaintainer->iAppId = $oFirstVersion->iAppId;
$oSecondVersionMaintainer->bSuperMaintainer = FALSE;
$oSecondVersionMaintainer->iUserId = $oSecondUser->iUserId;
$oSecondVersionMaintainer->create();
if(!$hResult = maintainer::getMaintainersForAppIdVersionId(null, if(!$hResult = maintainer::getMaintainersForAppIdVersionId(null,
$oFirstVersion->iVersionId)) $oFirstVersion->iVersionId))
{ {
@@ -542,8 +555,8 @@ function test_maintainer_getMaintainersForAppIdVersionId()
return FALSE; return FALSE;
} }
/* The second version should not have any maintainers */ /* The second version should have 1 maintainer */
$iExpected = 0; $iExpected = 1;
$iReceived = mysql_num_rows($hResult); $iReceived = mysql_num_rows($hResult);
if($iExpected != $iReceived) if($iExpected != $iReceived)
{ {