From 4a93b5efa05aa83677705549ec3056fe35221d4d Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 11 May 2026 19:28:33 +0000 Subject: [PATCH] Fix undefined array key in header on short URLs The language switcher in barber/beauty headers reads $currentPageUrlArray[2] unguarded after exploding REQUEST_URI on '/'. On routes with no language prefix (e.g. POST /manage-booking-cancel rendering the cancelled page inline), the array has only 2 elements, triggering "Undefined array key 2" warnings and producing malformed language links like https://studiobeve.no/en//. Normalize the array with += [2 => '', 3 => ''] right after the explode so indices 2 and 3 always exist. --- application/views/includes/barber-header.php | 1 + application/views/includes/beauty-header.php | 1 + 2 files changed, 2 insertions(+) diff --git a/application/views/includes/barber-header.php b/application/views/includes/barber-header.php index a8d72d4..de26f0c 100755 --- a/application/views/includes/barber-header.php +++ b/application/views/includes/barber-header.php @@ -6,6 +6,7 @@ if(in_array($selectedLang, $langArray)){ $currentPageUrl = $_SERVER['REQUEST_URI']; $currentPageUrlArray = explode('/',$currentPageUrl); + $currentPageUrlArray += array(2 => '', 3 => ''); $currentPageUrlArray[1] = $selectedLang; switch($selectedLang){ diff --git a/application/views/includes/beauty-header.php b/application/views/includes/beauty-header.php index 977aaa5..a4f89d9 100755 --- a/application/views/includes/beauty-header.php +++ b/application/views/includes/beauty-header.php @@ -8,6 +8,7 @@ if(in_array($selectedLang, $langArray)){ $currentPageUrl = $_SERVER['REQUEST_URI']; $currentPageUrlArray = explode('/',$currentPageUrl); + $currentPageUrlArray += array(2 => '', 3 => ''); $currentPageUrlArray[1] = $selectedLang; switch($selectedLang){