Prevent PHP warnings triggered by trying to fetch unset array entries

This commit is contained in:
Antoine Le Gonidec 2024-10-04 20:45:57 +02:00
parent 77a903816c
commit 047a5be134
Signed by: vv221
GPG key ID: 636B78F91CEB80D8

View file

@ -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];
}
}
}