When deleting a version or application the first thing deleted was the version

or application. Then each of the sub-objects like comments, notes etc were
deleted. This order is bad because it makes the database inconsistent, we
never want a comment/note/etc for a version that doesn't exist. Delete the
sub objects first and then the parent object.
This commit is contained in:
Chris Morgan
2005-06-30 01:59:32 +00:00
committed by WineHQ
parent e8218999f3
commit 6ae3aa98fd
2 changed files with 55 additions and 47 deletions

View File

@@ -222,29 +222,32 @@ class Application {
*/
function delete($bSilent=false)
{
foreach($this->aVersionsIds as $iVersionId)
{
$oVersion = new Version($iVersionId);
$oVersion->delete($bSilent);
}
foreach($this->aUrlsIds as $iUrlId)
{
$oUrl = new Url($iUrlId);
$oUrl->delete($bSilent);
}
// remove any supermaintainers for this application so we don't orphan them
$sQuery = "DELETE from appMaintainers WHERE appId='".$this->iAppId."';";
if(!($hResult = query_appdb($sQuery)))
{
addmsg("Error removing app maintainers for the deleted application!", "red");
}
$sQuery = "DELETE FROM appFamily
WHERE appId = ".$this->iAppId."
LIMIT 1";
if($hResult = query_appdb($sQuery))
if(!($hResult = query_appdb($sQuery)))
{
foreach($this->aVersionsIds as $iVersionId)
{
$oVersion = new Version($iVersionId);
$oVersion->delete($bSilent);
}
foreach($this->aUrlsIds as $iUrlId)
{
$oUrl = new Url($iUrlId);
$oUrl->delete($bSilent);
}
// remove any supermaintainers for this application so we don't orphan them
$sQuery = "DELETE from appMaintainers WHERE appId='".$this->iAppId."';";
if(!($hResult = query_appdb($sQuery)))
{
addmsg("Error removing app maintainers for the deleted application!", "red");
}
addmsg("Error deleting application!", "red");
}
if(!$bSilent)
$this->mailSupermaintainers("delete");
}