From 0048963013deb0dcb910f80ad1e98eb3e3267bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Thu, 29 Feb 2024 15:53:59 -0300 Subject: [PATCH] Fix case where tables from wrong db is loaded in navigation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- ChangeLog | 1 + libraries/classes/Navigation/Nodes/Node.php | 4 ++-- test/classes/Navigation/Nodes/NodeTest.php | 13 +++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a3f463f057..25771e69fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -68,6 +68,7 @@ phpMyAdmin - ChangeLog - issue #17363 Fix duplicate route parameter after logging in - issue #15670 Fix case where the data is truncated after changing a longtext column's collation - issue #18865 Fix missing text-nowrap for timestamps columns +- issue #19022 Fix case where tables from wrong database is loaded in navigation tree 5.2.1 (2023-02-07) - issue #17522 Fix case where the routes cache file is invalid diff --git a/libraries/classes/Navigation/Nodes/Node.php b/libraries/classes/Navigation/Nodes/Node.php index e20d7f25a1..3a0fa424d1 100644 --- a/libraries/classes/Navigation/Nodes/Node.php +++ b/libraries/classes/Navigation/Nodes/Node.php @@ -178,13 +178,13 @@ class Node { if ($realName) { foreach ($this->children as $child) { - if ($child->realName == $name) { + if ($child->realName === $name) { return $child; } } } else { foreach ($this->children as $child) { - if ($child->name == $name && $child->isNew === false) { + if ($child->name === $name && $child->isNew === false) { return $child; } } diff --git a/test/classes/Navigation/Nodes/NodeTest.php b/test/classes/Navigation/Nodes/NodeTest.php index 1978139743..241c08dc6c 100644 --- a/test/classes/Navigation/Nodes/NodeTest.php +++ b/test/classes/Navigation/Nodes/NodeTest.php @@ -76,6 +76,19 @@ class NodeTest extends AbstractTestCase ); } + public function testGetChild(): void + { + $parent = NodeFactory::getInstance('Node', 'parent'); + $childOne = NodeFactory::getInstance('Node', '0'); + $childTwo = NodeFactory::getInstance('Node', '00'); + $parent->addChild($childOne); + $parent->addChild($childTwo); + self::assertSame($childTwo, $parent->getChild('00')); + self::assertSame($childOne, $parent->getChild('0')); + self::assertSame($childTwo, $parent->getChild('00', true)); + self::assertSame($childOne, $parent->getChild('0', true)); + } + /** * SetUp for hasChildren */