Skip to content

Purge parent collections in inheritance cases #7042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 4.1
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/Symfony/Doctrine/EventListener/PurgeHttpCacheListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public function onFlush(OnFlushEventArgs $eventArgs): void

foreach ($uow->getScheduledEntityInsertions() as $entity) {
$this->gatherResourceAndItemTags($entity, false);
$this->gatherParentResourceTags($em, $entity);
$this->gatherRelationTags($em, $entity);
}

Expand Down Expand Up @@ -122,6 +123,25 @@ private function gatherResourceAndItemTags(object $entity, bool $purgeItem): voi
}
}

private function gatherParentResourceTags(EntityManagerInterface $em, object $entity): void
{
$classMetadata = $em->getClassMetadata($entity::class);

if ($classMetadata->isInheritanceTypeNone()) {
return;
}

foreach ($classMetadata->parentClasses as $parentClass) {
if ($this->resourceClassResolver->isResourceClass($parentClass)) {
try {
$iri = $this->iriConverter->getIriFromResource($parentClass, UrlGeneratorInterface::ABS_PATH, new GetCollection());
$this->tags[$iri] = $iri;
} catch (OperationNotFoundException|InvalidArgumentException) {
}
}
}
}

private function gatherRelationTags(EntityManagerInterface $em, object $entity): void
{
$associationMappings = $em->getClassMetadata($entity::class)->getAssociationMappings();
Expand Down
Loading