From 047a5be134692b7090715b66d5734aa1b9a4adda Mon Sep 17 00:00:00 2001 From: Antoine Le Gonidec Date: Fri, 4 Oct 2024 20:45:57 +0200 Subject: [PATCH] Prevent PHP warnings triggered by trying to fetch unset array entries --- action.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/action.php b/action.php index 181dc13..905c43b 100644 --- a/action.php +++ b/action.php @@ -93,10 +93,13 @@ class action_plugin_childrenpages extends DokuWiki_Action_Plugin { $language = $translation_plugin->getLangPart($INFO['id']); } // Skip top-level language namespace if one is in use + $namespace = explode(':', $INFO['namespace']); if ( $language !== null && preg_match("/^$language:/", $INFO['id']) ) { - return explode(':', $INFO['namespace'])[1]; + // FIXME: $namespace is sometimes shorter than expected, + // this might be the symptom of some bug. + return ( count($namespace) > 1 ) ? $namespace[1] : null; } else { - return explode(':', $INFO['namespace'])[0]; + return $namespace[0]; } } }