Skip to content

Commit

Permalink
don't catch InvalidArgumentException|OperationNotFoundException in Pu…
Browse files Browse the repository at this point in the history
…rgeHttpCacheListener
  • Loading branch information
usu committed May 21, 2024
1 parent fd99973 commit dd199d7
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions api/src/HttpCache/PurgeHttpCacheListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use ApiPlatform\Api\IriConverterInterface as LegacyIriConverterInterface;
use ApiPlatform\Api\ResourceClassResolverInterface as LegacyResourceClassResolverInterface;
use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\Exception\OperationNotFoundException;
use ApiPlatform\Exception\RuntimeException;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
Expand Down Expand Up @@ -126,22 +125,19 @@ private function getOriginalEntity($entity, $em) {
* (e.g. for updating period on a ScheduleEntry and the IRI changes from /periods/1/schedule_entries to /periods/2/schedule_entries)
*/
private function gatherResourceTags(object $entity, ?object $oldEntity = null): void {
try {
$resourceClass = $this->resourceClassResolver->getResourceClass($entity);
$resourceMetadataCollection = $this->resourceMetadataCollectionFactory->create($resourceClass);
$resourceIterator = $resourceMetadataCollection->getIterator();
while ($resourceIterator->valid()) {
/** @var ApiResource $metadata */
$metadata = $resourceIterator->current();

foreach ($metadata->getOperations() ?? [] as $operation) {
if ($operation instanceof GetCollection) {
$this->invalidateCollection($operation, $entity, $oldEntity);
}
$resourceClass = $this->resourceClassResolver->getResourceClass($entity);
$resourceMetadataCollection = $this->resourceMetadataCollectionFactory->create($resourceClass);
$resourceIterator = $resourceMetadataCollection->getIterator();
while ($resourceIterator->valid()) {
/** @var ApiResource $metadata */
$metadata = $resourceIterator->current();

foreach ($metadata->getOperations() ?? [] as $operation) {
if ($operation instanceof GetCollection) {
$this->invalidateCollection($operation, $entity, $oldEntity);
}
$resourceIterator->next();
}
} catch (InvalidArgumentException|OperationNotFoundException) {
$resourceIterator->next();
}
}

Expand Down

0 comments on commit dd199d7

Please sign in to comment.