MVC / MenuInitException - handle broken menu xml files more gracefully, dump to error log, but don't crash out with a fatal exception.

This commit is contained in:
Ad Schellevis 2023-11-13 10:08:01 +01:00
parent 53b8f0f8f0
commit 22f939bb8d
2 changed files with 7 additions and 7 deletions

View File

@ -97,7 +97,6 @@ class MenuController extends ApiControllerBase
* request user context sensitive menu (items)
* @param string $selected_uri selected uri
* @return array menu items
* @throws Menu\MenuInitException when unable to construct menu
*/
private function getMenu($selected_uri)
{
@ -166,7 +165,6 @@ class MenuController extends ApiControllerBase
/**
* return menu items for this user
* @return array
* @throws Menu\MenuInitException when unable to construct menu
*/
public function treeAction()
{
@ -178,7 +176,6 @@ class MenuController extends ApiControllerBase
/**
* search menu items
* @return array
* @throws Menu\MenuInitException when unable to construct menu
*/
public function searchAction()
{

View File

@ -108,7 +108,6 @@ class MenuSystem
* Load and persist Menu configuration to disk.
* @param bool $nowait when the cache is locked, skip waiting for it to become available.
* @return SimpleXMLElement
* @throws MenuInitException
*/
public function persist($nowait = true)
{
@ -133,9 +132,13 @@ class MenuSystem
foreach (glob($vendor . '/*') as $module) {
$menu_cfg_xml = $module . '/Menu/Menu.xml';
if (file_exists($menu_cfg_xml)) {
$domNode = dom_import_simplexml($this->addXML($menu_cfg_xml));
$domNode = $root->ownerDocument->importNode($domNode, true);
$root->appendChild($domNode);
try {
$domNode = dom_import_simplexml($this->addXML($menu_cfg_xml));
$domNode = $root->ownerDocument->importNode($domNode, true);
$root->appendChild($domNode);
} catch (MenuInitException $e) {
error_log($e);
}
}
}
}