From b2a0f1b9c2ce31ec7866443c5e21c2ee85cd0f7d Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 4 Sep 2015 14:17:16 +0200 Subject: [PATCH] Navigation: Peform a case-insensitive search when merging items refs #5600 --- library/Icinga/Web/Navigation/Navigation.php | 24 +++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/Navigation/Navigation.php b/library/Icinga/Web/Navigation/Navigation.php index 9d22617fb..1500f9b9b 100644 --- a/library/Icinga/Web/Navigation/Navigation.php +++ b/library/Icinga/Web/Navigation/Navigation.php @@ -318,6 +318,28 @@ class Navigation implements ArrayAccess, Countable, IteratorAggregate return $a->getPriority() > $b->getPriority() ? 1 : -1; } + /** + * Try to find and return a item with the given or a similar name + * + * @param string $name + * + * @return NavigationItem + */ + protected function findItem($name) + { + $item = $this->getItem($name); + if ($item !== null) { + return $item; + } + + $loweredName = strtolower($name); + foreach ($this->getItems() as $item) { + if (strtolower($item->getName()) === $loweredName) { + return $item; + } + } + } + /** * Merge this navigation with the given one * @@ -331,7 +353,7 @@ class Navigation implements ArrayAccess, Countable, IteratorAggregate { foreach ($navigation as $item) { /** @var $item NavigationItem */ - if (($existingItem = $this->getItem($item->getName())) !== null) { + if (($existingItem = $this->findItem($item->getName())) !== null) { if ($existingItem->conflictsWith($item)) { $name = $item->getName(); do {