From 8754cef14bff0455fe16c39695b185f2b21f09d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Roman=C3=AD?= Date: Sun, 21 Jun 2026 12:23:26 +0200 Subject: [PATCH 1/3] allow Symfony v8 --- composer.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 5f74e39..3564536 100644 --- a/composer.json +++ b/composer.json @@ -12,15 +12,15 @@ ], "require": { "php": "^8.0", - "symfony/framework-bundle": "^6.0 | ^7.0", + "symfony/framework-bundle": "^6.0 | ^7.0 | ^8.0", "symfony/orm-pack": "^2.3", "twig/twig": "^3.0", - "symfony/yaml": "^6.0 | ^7.0", - "symfony/asset": "^6.0 | ^7.0", - "symfony/console": "^6.0 | ^7.0", - "symfony/http-foundation": "^6.0 | ^7.0", - "symfony/http-kernel": "^6.0 | ^7.0", - "symfony/dependency-injection": "^6.0 | ^7.0" + "symfony/yaml": "^6.0 | ^7.0 | ^8.0", + "symfony/asset": "^6.0 | ^7.0 | ^8.0", + "symfony/console": "^6.0 | ^7.0 | ^8.0", + "symfony/http-foundation": "^6.0 | ^7.0 | ^8.0", + "symfony/http-kernel": "^6.0 | ^7.0 | ^8.0", + "symfony/dependency-injection": "^6.0 | ^7.0 | ^8.0" }, "autoload": { "psr-4": { From 6a292e74752499d0b8a08392d562b3495b911841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Roman=C3=AD?= Date: Sun, 21 Jun 2026 13:04:27 +0200 Subject: [PATCH 2/3] replace Annotation by Attribute into CookieConsentController --- src/Controller/CookieConsentController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controller/CookieConsentController.php b/src/Controller/CookieConsentController.php index aebb6d2..e241220 100644 --- a/src/Controller/CookieConsentController.php +++ b/src/Controller/CookieConsentController.php @@ -5,7 +5,7 @@ use Exception; use Psr\Log\LoggerInterface; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Annotation\Route; +use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\RequestStack; use Eveltic\CookieBundle\Service\CookieConsentService; From 671b47b440138b491525a49d0dfdd2101103e074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Roman=C3=AD?= Date: Sun, 28 Jun 2026 12:33:00 +0200 Subject: [PATCH 3/3] Fix PHP 8.5 deprecations: guard null before strtotime()/json_decode() CookieConsentService passed a possibly-null value straight into strtotime() (isConsentGiven) and json_decode() (getConsentCookie), which PHP 8.5 deprecates and PHP 9 will reject with a TypeError: - isConsentGiven(): bail out early when the consent cookie is absent or missing its expiration/version keys, and cast strtotime() to int so an invalid value can't reach DateTime::setTimestamp(false). - getConsentCookie(): return null without decoding when no cookie is set (and null-safe the request lookup). Co-Authored-By: Claude Opus 4.8 --- src/Service/CookieConsentService.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Service/CookieConsentService.php b/src/Service/CookieConsentService.php index 140fcc8..b1a00d3 100644 --- a/src/Service/CookieConsentService.php +++ b/src/Service/CookieConsentService.php @@ -112,11 +112,14 @@ public function isConsentGiven(): bool { $consentData = $this->getConsentCookie(); + if (!isset($consentData['expiration'], $consentData['version'])) { + return false; + } + $currentDate = new DateTime(); - $expirationDate = (new DateTime())->setTimestamp(strtotime($consentData['expiration']??null)); - - if (isset($consentData['version']) && - $consentData['version'] === $this->currentVersion && + $expirationDate = (new DateTime())->setTimestamp((int) strtotime($consentData['expiration'])); + + if ($consentData['version'] === $this->currentVersion && $expirationDate > $currentDate) { return true; } @@ -171,7 +174,12 @@ public function getConsentCookie(): ?array $request = $this->requestStack->getCurrentRequest(); // Get the value of the consent cookie using the defined cookie name. - $cookieValue = $request->cookies->get(self::COOKIE_NAME, null); + $cookieValue = $request?->cookies->get(self::COOKIE_NAME); + + // No consent cookie present yet — nothing to decode. + if (!is_string($cookieValue) || '' === $cookieValue) { + return $this->cachedConsentCookie = null; + } // Decode the JSON-encoded cookie value into an associative array. try {