Skip to content

Commit 80ca680

Browse files
fix(httpcache): generating iri cache tag for collection operation with path parameter
1 parent 79edced commit 80ca680

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/Symfony/Doctrine/EventListener/PurgeHttpCacheListener.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,13 @@ public function postFlush(): void
111111
private function gatherResourceAndItemTags(object $entity, bool $purgeItem): void
112112
{
113113
try {
114-
$resourceClass = $this->resourceClassResolver->getResourceClass($entity);
115-
$iri = $this->iriConverter->getIriFromResource($resourceClass, UrlGeneratorInterface::ABS_PATH, new GetCollection());
114+
$iri = $this->iriConverter->getIriFromResource($entity, UrlGeneratorInterface::ABS_PATH, new GetCollection());
116115
$this->tags[$iri] = $iri;
117116

118117
if ($purgeItem) {
119118
$this->addTagForItem($entity);
120119
}
121-
} catch (OperationNotFoundException|InvalidArgumentException) {
120+
} catch (OperationNotFoundException|InvalidArgumentException|InvalidArgumentException) {
122121
}
123122
}
124123

src/Symfony/Routing/IriConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function getIriFromResource(object|string $resource, int $referenceType =
121121
$operation = $this->operationMetadataFactory->create($context['item_uri_template']);
122122
}
123123

124-
$localOperationCacheKey = ($operation?->getName() ?? '').$resourceClass.(\is_string($resource) ? '_c' : '_i');
124+
$localOperationCacheKey = ($operation?->getName() ?? '').$resourceClass.(($operation instanceof CollectionOperationInterface) ? '_c' : '_i');
125125
if ($operation && isset($this->localOperationCache[$localOperationCacheKey])) {
126126
return $this->generateSymfonyRoute($resource, $referenceType, $this->localOperationCache[$localOperationCacheKey], $context, $this->localIdentifiersExtractorOperationCache[$localOperationCacheKey] ?? null);
127127
}

0 commit comments

Comments
 (0)