From 85aa92b0de0b74d8ea2a05d265f47fdfcad991b2 Mon Sep 17 00:00:00 2001
From: catch <6915-catch@users.noreply.drupalcode.org>
Date: Mon, 9 Sep 2024 17:29:26 +0100
Subject: [PATCH] Issue #3471741 by mstrelan, bbrala, kristiaanvandeneynde: Fix
 null $cid in CacheCollector classes

---
 core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php | 6 +++---
 core/lib/Drupal/Core/Menu/MenuActiveTrail.php            | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php b/core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php
index f7c5afb17be9..6885d023169e 100644
--- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php
+++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php
@@ -43,7 +43,7 @@ class LibraryDiscoveryCollector extends CacheCollector implements LibraryDiscove
    */
   public function __construct(CacheBackendInterface $cache, LockBackendInterface $lock, LibraryDiscoveryParser $discovery_parser, ThemeManagerInterface $theme_manager) {
     $this->themeManager = $theme_manager;
-    parent::__construct(NULL, $cache, $lock, ['library_info']);
+    parent::__construct('', $cache, $lock, ['library_info']);
 
     $this->discoveryParser = $discovery_parser;
   }
@@ -52,7 +52,7 @@ public function __construct(CacheBackendInterface $cache, LockBackendInterface $
    * {@inheritdoc}
    */
   protected function getCid() {
-    if (!isset($this->cid)) {
+    if ($this->cid === '') {
       $this->cid = 'library_info:' . $this->themeManager->getActiveTheme()->getName();
     }
 
@@ -186,7 +186,7 @@ public function getLibraryByName($extension, $name) {
    */
   public function reset() {
     parent::reset();
-    $this->cid = NULL;
+    $this->cid = '';
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Menu/MenuActiveTrail.php b/core/lib/Drupal/Core/Menu/MenuActiveTrail.php
index 978aeffbf4f4..d11be878e6bf 100644
--- a/core/lib/Drupal/Core/Menu/MenuActiveTrail.php
+++ b/core/lib/Drupal/Core/Menu/MenuActiveTrail.php
@@ -42,7 +42,7 @@ class MenuActiveTrail extends CacheCollector implements MenuActiveTrailInterface
    *   The lock backend.
    */
   public function __construct(MenuLinkManagerInterface $menu_link_manager, RouteMatchInterface $route_match, CacheBackendInterface $cache, LockBackendInterface $lock) {
-    parent::__construct(NULL, $cache, $lock);
+    parent::__construct('', $cache, $lock);
     $this->menuLinkManager = $menu_link_manager;
     $this->routeMatch = $route_match;
   }
@@ -53,7 +53,7 @@ public function __construct(MenuLinkManagerInterface $menu_link_manager, RouteMa
    * @see ::getActiveTrailIds()
    */
   protected function getCid() {
-    if (!isset($this->cid)) {
+    if ($this->cid === '') {
       $route_parameters = $this->routeMatch->getRawParameters()->all();
       ksort($route_parameters);
       $this->cid = 'active-trail:route:' . $this->routeMatch->getRouteName() . ':route_parameters:' . serialize($route_parameters);
-- 
GitLab