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:
@@ -221,11 +221,6 @@ class Application {
|
||||
* and request the deletion of linked elements.
|
||||
*/
|
||||
function delete($bSilent=false)
|
||||
{
|
||||
$sQuery = "DELETE FROM appFamily
|
||||
WHERE appId = ".$this->iAppId."
|
||||
LIMIT 1";
|
||||
if($hResult = query_appdb($sQuery))
|
||||
{
|
||||
foreach($this->aVersionsIds as $iVersionId)
|
||||
{
|
||||
@@ -244,7 +239,15 @@ class Application {
|
||||
{
|
||||
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)))
|
||||
{
|
||||
addmsg("Error deleting application!", "red");
|
||||
}
|
||||
|
||||
if(!$bSilent)
|
||||
$this->mailSupermaintainers("delete");
|
||||
}
|
||||
|
||||
@@ -230,11 +230,7 @@ class Version {
|
||||
*/
|
||||
function delete($bSilent=false)
|
||||
{
|
||||
$sQuery = "DELETE FROM appVersion
|
||||
WHERE versionId = ".$this->iVersionId."
|
||||
LIMIT 1";
|
||||
if($hResult = query_appdb($sQuery))
|
||||
{
|
||||
/* remove all of the items this version contains */
|
||||
foreach($this->aNotesIds as $iNoteId)
|
||||
{
|
||||
$oNote = new Note($iNoteId);
|
||||
@@ -262,7 +258,16 @@ class Version {
|
||||
{
|
||||
addmsg("Error removing version maintainers for the deleted version!", "red");
|
||||
}
|
||||
|
||||
/* now delete the version */
|
||||
$sQuery = "DELETE FROM appVersion
|
||||
WHERE versionId = ".$this->iVersionId."
|
||||
LIMIT 1";
|
||||
if(!($hResult = query_appdb($sQuery)))
|
||||
{
|
||||
addmsg("Error removing the deleted version!", "red");
|
||||
}
|
||||
|
||||
if(!$bSilent)
|
||||
$this->mailMaintainers("delete");
|
||||
|
||||
@@ -348,7 +353,7 @@ class Version {
|
||||
addmsg("Version modified.", "green");
|
||||
break;
|
||||
case "delete":
|
||||
$sSubject = "Version '".$this->sName." of ".$oApp->sName."' has been deleted by ".$_SESSION['current']->sRealname;
|
||||
$sSubject = "Version '".$this->sName."' of '".$oApp->sName."' has been deleted by ".$_SESSION['current']->sRealname;
|
||||
|
||||
/* if replyText is set we should report the reason the application was deleted */
|
||||
if($_REQUEST['replyText'])
|
||||
|
||||
Reference in New Issue
Block a user