From 9e68a0245848121db47e70fde9199c7882e7fb67 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Tue, 22 Aug 2023 17:55:43 +0100 Subject: [PATCH] MDL-79118 output: account for empty node/current URL path element. --- lib/classes/navigation/output/primary.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/classes/navigation/output/primary.php b/lib/classes/navigation/output/primary.php index f55dc8c8c4f..e1f36780bd3 100644 --- a/lib/classes/navigation/output/primary.php +++ b/lib/classes/navigation/output/primary.php @@ -194,12 +194,15 @@ class primary implements renderable, templatable { $current = parse_url($FULLME ?? ''); $pathmatches = false; + // Exact match of the path of node and current url. - if ($nodeurl['path'] === $current['path']) { + $nodepath = $nodeurl['path'] ?? '/'; + $currentpath = $current['path'] ?? '/'; + if ($nodepath === $currentpath) { $pathmatches = true; } // The current url may be trailed by a index.php, otherwise it's the same as the node path. - if (!$pathmatches && $nodeurl['path'] . 'index.php' === $current['path']) { + if (!$pathmatches && $nodepath . 'index.php' === $currentpath) { $pathmatches = true; } // No path did match, so the node can't be active.