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.
This commit is contained in:
Ubuntu
2026-05-11 19:28:33 +00:00
parent 92a84aadb1
commit 4a93b5efa0
2 changed files with 2 additions and 0 deletions
@@ -6,6 +6,7 @@
if(in_array($selectedLang, $langArray)){ if(in_array($selectedLang, $langArray)){
$currentPageUrl = $_SERVER['REQUEST_URI']; $currentPageUrl = $_SERVER['REQUEST_URI'];
$currentPageUrlArray = explode('/',$currentPageUrl); $currentPageUrlArray = explode('/',$currentPageUrl);
$currentPageUrlArray += array(2 => '', 3 => '');
$currentPageUrlArray[1] = $selectedLang; $currentPageUrlArray[1] = $selectedLang;
switch($selectedLang){ switch($selectedLang){
@@ -8,6 +8,7 @@
if(in_array($selectedLang, $langArray)){ if(in_array($selectedLang, $langArray)){
$currentPageUrl = $_SERVER['REQUEST_URI']; $currentPageUrl = $_SERVER['REQUEST_URI'];
$currentPageUrlArray = explode('/',$currentPageUrl); $currentPageUrlArray = explode('/',$currentPageUrl);
$currentPageUrlArray += array(2 => '', 3 => '');
$currentPageUrlArray[1] = $selectedLang; $currentPageUrlArray[1] = $selectedLang;
switch($selectedLang){ switch($selectedLang){