From 998b3a19cd8b8aa11abe3ed381578c8a0af9d356 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Thu, 28 Mar 2024 19:39:16 +0100 Subject: [PATCH] Fix a regression caused in #39 --- src/Caching/Attribute/Send304IfNotModified.php | 4 ++++ src/Caching/EventListener.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Caching/Attribute/Send304IfNotModified.php b/src/Caching/Attribute/Send304IfNotModified.php index 4c4c21e..ed4f14b 100644 --- a/src/Caching/Attribute/Send304IfNotModified.php +++ b/src/Caching/Attribute/Send304IfNotModified.php @@ -28,6 +28,10 @@ public function __construct(...$values) \E_USER_DEPRECATED ); + if (!$values) { + throw new \InvalidArgumentException(sprintf('The %s attribute needs at least one criterion', __CLASS__)); + } + $this->lastmodHelper = new LastmodHelper(); foreach ($values as $key => $value) { diff --git a/src/Caching/EventListener.php b/src/Caching/EventListener.php index d06f907..1785642 100644 --- a/src/Caching/EventListener.php +++ b/src/Caching/EventListener.php @@ -109,7 +109,7 @@ protected function findAttribute($callback): ?Attribute\Send304IfNotModified $attributes = $method->getAttributes(\Webfactory\Bundle\WfdMetaBundle\Caching\Attribute\Send304IfNotModified::class); if ($attributes) { - return $attributes[0]; + return $attributes[0]->newInstance(); } }