From 8316f47c1083def5f43f3d7f92ebf5dfff9bd56d Mon Sep 17 00:00:00 2001 From: Eduardo Mozart de Oliveira <2974895+eduardomozart@users.noreply.github.com> Date: Thu, 1 Feb 2024 10:08:05 -0300 Subject: [PATCH] Attempts to restore Hogfather compatibility The class PageResolver doesn't exists on DokuWiki Hogfather and older releases, so this PR attempts to fix https://github.com/samuelet/indexmenu/issues/291 by falling back to the old function "resolve_id" to parse NS if the class PageResolver isn't available. --- syntax/indexmenu.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/syntax/indexmenu.php b/syntax/indexmenu.php index d91322d..82092d9 100644 --- a/syntax/indexmenu.php +++ b/syntax/indexmenu.php @@ -769,10 +769,14 @@ public function parseNs($ns, $id = false) if ($ns == '..') { $ns = ":"; } - $ns = "$ns:arandompagehere"; - $resolver = new PageResolver($id); - $ns = getNs($resolver->resolveId($ns)); - return $ns === false ? '' : $ns; + if (class_exists('dokuwiki\File\PageResolver')) { + $ns = "$ns:arandompagehere"; + $resolver = new PageResolver($id); + $ns = getNs($resolver->resolveId($ns)); + return $ns === false ? '' : $ns; + } else { + return resolve_id(getNS($id), $ns); + } } /**