1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-06-27 16:36:00 +00:00

Merge pull request #8248 from casimir/missing-entry-deleted-event

Dispatch EntryDeletedEvent when removing duplicated entries
This commit is contained in:
Jérémy Benoist 2025-06-13 09:19:42 +02:00 committed by GitHub
commit 540483c583
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,8 +9,9 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Wallabag\Entity\Entry;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Wallabag\Entity\User;
use Wallabag\Event\EntryDeletedEvent;
use Wallabag\Repository\EntryRepository;
use Wallabag\Repository\UserRepository;
@ -26,6 +27,7 @@ class CleanDuplicatesCommand extends Command
private readonly EntityManagerInterface $entityManager,
private readonly EntryRepository $entryRepository,
private readonly UserRepository $userRepository,
private readonly EventDispatcherInterface $eventDispatcher,
) {
parent::__construct();
}
@ -86,7 +88,12 @@ class CleanDuplicatesCommand extends Command
if (\in_array($url, $urls, true)) {
++$duplicatesCount;
$this->entityManager->remove($this->entryRepository->find($entry['id']));
$entryToDelete = $this->entryRepository->find($entry['id']);
// entry deleted, dispatch event about it!
$this->eventDispatcher->dispatch(new EntryDeletedEvent($entryToDelete), EntryDeletedEvent::NAME);
$this->entityManager->remove($entryToDelete);
$this->entityManager->flush(); // Flushing at the end of the loop would require the instance not being online
} else {
$urls[] = $entry['url'];