Ensure that attachments are not used in preview when deleting, so we do not encounter integrity violations.

This fixes issue #50.
This commit is contained in:
Jan Böhmer 2020-05-13 20:46:13 +02:00
parent 7b108f8d4b
commit c0b4172f22
2 changed files with 25 additions and 0 deletions

View file

@ -111,6 +111,11 @@ abstract class AttachmentContainingDBElement extends AbstractNamedDBElement impl
{
$this->attachments->removeElement($attachment);
//Check if this is the master attachment -> remove it from master attachment too, or it can not be deleted from DB...
if ($attachment === $this->getMasterPictureAttachment()) {
$this->setMasterPictureAttachment(null);
}
return $this;
}
}