From 3ee0b0b71f51d183d7cc87e0d03506b56e3ed7dd Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Fri, 24 Sep 2021 10:31:15 +0100
Subject: [PATCH] Issue #3238457 by alexpott, paulocs: Fix
 \Drupal\Core\EventSubscriber\ActiveLinkResponseFilter::setLinkActiveClass()
 to not trigger a deprecation on PHP 8.1

---
 .../Drupal/Core/EventSubscriber/ActiveLinkResponseFilter.php    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/lib/Drupal/Core/EventSubscriber/ActiveLinkResponseFilter.php b/core/lib/Drupal/Core/EventSubscriber/ActiveLinkResponseFilter.php
index bb3031e6e90b..d70f2ce0743c 100644
--- a/core/lib/Drupal/Core/EventSubscriber/ActiveLinkResponseFilter.php
+++ b/core/lib/Drupal/Core/EventSubscriber/ActiveLinkResponseFilter.php
@@ -181,7 +181,7 @@ public static function setLinkActiveClass($html_markup, $current_path, $is_front
 
       // Get the HTML: this will be the opening part of a single tag, e.g.:
       // <a href="/" data-drupal-link-system-path="&lt;front&gt;">
-      $tag = substr($html_markup, $pos_tag_start, $pos_tag_end - $pos_tag_start + 1);
+      $tag = substr($html_markup, $pos_tag_start ?? 0, $pos_tag_end - $pos_tag_start + 1);
 
       // Parse it into a DOMDocument so we can reliably read and modify
       // attributes.
-- 
GitLab