From c96a0782dc9c4329843c611cf190b5acc4330a56 Mon Sep 17 00:00:00 2001
From: Lukasz Tyc <lukasz.tyc@droptica.com>
Date: Wed, 26 Feb 2025 09:48:24 +0100
Subject: [PATCH 1/2] Issue #3509064 by lukasz.tyc: Undefined array key "class"
 in template_preprocess_toc_tree() in toc_api.module

---
 toc_api.module | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/toc_api.module b/toc_api.module
index 62aa9c3..5bbb1c5 100755
--- a/toc_api.module
+++ b/toc_api.module
@@ -120,7 +120,7 @@ function template_preprocess_toc_tree(&$variables) {
   $variables['options'] = $toc->getOptions();
 
   // Add default classes.
-  $variables['attributes']['class'] = (array) $variables['attributes']['class'];
+  $variables['attributes']['class'] = (array) $variables['attributes']['class'] ?? [];
   $variables['attributes']['class'][] = 'toc';
   $variables['attributes']['class'][] = 'toc-tree';
 
-- 
GitLab


From 79cf5bc42daffdb7812126fcd87865e6b06c9674 Mon Sep 17 00:00:00 2001
From: Lukasz Tyc <lukasz.tyc@droptica.com>
Date: Wed, 26 Feb 2025 09:56:07 +0100
Subject: [PATCH 2/2] Issue #3509064 by lukasz.tyc: Undefined array key "class"
 in template_preprocess_toc_tree() in toc_api.module

---
 toc_api.module | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/toc_api.module b/toc_api.module
index 5bbb1c5..0954347 100755
--- a/toc_api.module
+++ b/toc_api.module
@@ -120,7 +120,7 @@ function template_preprocess_toc_tree(&$variables) {
   $variables['options'] = $toc->getOptions();
 
   // Add default classes.
-  $variables['attributes']['class'] = (array) $variables['attributes']['class'] ?? [];
+  $variables['attributes']['class'] = isset($variables['attributes']['class']) ? (array) $variables['attributes']['class'] : [];
   $variables['attributes']['class'][] = 'toc';
   $variables['attributes']['class'][] = 'toc-tree';
 
-- 
GitLab