From a7db3de10510c9e6270b513c4424a6f0a15d349b Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Thu, 30 Nov 2023 16:59:46 +0100 Subject: [PATCH] Revert "[Routing] Fix removing aliases pointing to removed route in RouteCollection::remove()" This reverts commit 238894bdc0d866d5ec14c89004e30991a3e17c28. --- src/Symfony/Component/Routing/RouteCollection.php | 11 ++--------- .../Component/Routing/Tests/RouteCollectionTest.php | 2 -- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/Routing/RouteCollection.php b/src/Symfony/Component/Routing/RouteCollection.php index d59a5a3bda1cf..a0700bba3d681 100644 --- a/src/Symfony/Component/Routing/RouteCollection.php +++ b/src/Symfony/Component/Routing/RouteCollection.php @@ -157,15 +157,8 @@ public function get(string $name) */ public function remove($name) { - $names = (array) $name; - foreach ($names as $n) { - unset($this->routes[$n], $this->priorities[$n]); - } - - foreach ($this->aliases as $k => $alias) { - if (\in_array($alias->getId(), $names, true)) { - unset($this->aliases[$k]); - } + foreach ((array) $name as $n) { + unset($this->routes[$n], $this->priorities[$n], $this->aliases[$n]); } } diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php index db5125b5ab43e..a191c88a61849 100644 --- a/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php +++ b/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php @@ -225,13 +225,11 @@ public function testRemove() $collection1->add('bar', $bar = new Route('/bar')); $collection->addCollection($collection1); $collection->add('last', $last = new Route('/last')); - $collection->addAlias('ccc_my_custom_alias', 'foo'); $collection->remove('foo'); $this->assertSame(['bar' => $bar, 'last' => $last], $collection->all(), '->remove() can remove a single route'); $collection->remove(['bar', 'last']); $this->assertSame([], $collection->all(), '->remove() accepts an array and can remove multiple routes at once'); - $this->assertNull($collection->getAlias('ccc_my_custom_alias')); } public function testSetHost()