mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Remove preview image attachment during if the attachment got deleted during cloning
This fixes issue #559
This commit is contained in:
parent
a792a140f7
commit
945fb9384e
2 changed files with 21 additions and 0 deletions
|
@ -24,6 +24,7 @@ namespace App\Controller\AdminPages;
|
|||
|
||||
use App\DataTables\LogDataTable;
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Attachments\AttachmentContainingDBElement;
|
||||
use App\Entity\Attachments\AttachmentUpload;
|
||||
use App\Entity\Base\AbstractDBElement;
|
||||
use App\Entity\Base\AbstractNamedDBElement;
|
||||
|
@ -190,6 +191,13 @@ abstract class BaseAdminController extends AbstractController
|
|||
}
|
||||
}
|
||||
|
||||
//Ensure that the master picture is still part of the attachments
|
||||
if ($entity instanceof AttachmentContainingDBElement) {
|
||||
if ($entity->getMasterPictureAttachment() !== null && !$entity->getAttachments()->contains($entity->getMasterPictureAttachment())) {
|
||||
$entity->setMasterPictureAttachment(null);
|
||||
}
|
||||
}
|
||||
|
||||
$this->commentHelper->setMessage($form['log_comment']->getData());
|
||||
|
||||
$em->persist($entity);
|
||||
|
@ -273,6 +281,14 @@ abstract class BaseAdminController extends AbstractController
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
//Ensure that the master picture is still part of the attachments
|
||||
if ($new_entity instanceof AttachmentContainingDBElement) {
|
||||
if ($new_entity->getMasterPictureAttachment() !== null && !$new_entity->getAttachments()->contains($new_entity->getMasterPictureAttachment())) {
|
||||
$new_entity->setMasterPictureAttachment(null);
|
||||
}
|
||||
}
|
||||
|
||||
$this->commentHelper->setMessage($form['log_comment']->getData());
|
||||
$em->persist($new_entity);
|
||||
$em->flush();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue