From e38257fe02e75b1f326cc7d2edcb2ccf69a943c4 Mon Sep 17 00:00:00 2001 From: nishizoe Date: Mon, 1 Jun 2020 19:53:13 +0900 Subject: [PATCH] (fixed #4438) Fix `sfPatternRouting->getRoutes()` sometimes returning serialized routes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/FriendsOfSymfony1/symfony1/issues/169 参照 --- lib/vendor/symfony/lib/routing/sfPatternRouting.class.php | 8 ++++++++ .../symfony/test/unit/routing/sfPatternRoutingTest.php | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/vendor/symfony/lib/routing/sfPatternRouting.class.php b/lib/vendor/symfony/lib/routing/sfPatternRouting.class.php index 3479c7d61..38af2719a 100644 --- a/lib/vendor/symfony/lib/routing/sfPatternRouting.class.php +++ b/lib/vendor/symfony/lib/routing/sfPatternRouting.class.php @@ -144,6 +144,14 @@ public function getCurrentRouteName() */ public function getRoutes() { + foreach ($this->routes as $name => $route) { + if (is_string($route)) { + $route = unserialize($route); + $route->setDefaultParameters($this->defaultParameters); + $this->routes[$name] = $route; + } + } + return $this->routes; } diff --git a/lib/vendor/symfony/test/unit/routing/sfPatternRoutingTest.php b/lib/vendor/symfony/test/unit/routing/sfPatternRoutingTest.php index 20398fbe6..394d6a90c 100644 --- a/lib/vendor/symfony/test/unit/routing/sfPatternRoutingTest.php +++ b/lib/vendor/symfony/test/unit/routing/sfPatternRoutingTest.php @@ -639,8 +639,8 @@ function configureRouting($event) // see fixtures/config_routing.yml.php $r = new sfPatternRoutingTest(new sfEventDispatcher(), new sfNoCache(), array('load_configuration' => true)); $t->ok($r->hasRouteName('test1'), '->loadConfiguration() Config file is loaded'); -$routes = $r->getRoutes(); -$t->ok(is_string($routes['test1']), '->loadConfiguration() Route objects are not serialized in cache'); $route = $r->getRoute('test1'); $t->ok(is_object($route), '->loadConfiguration() Route objects are unserialized on demand'); +$routes = $r->getRoutes(); +$t->ok(is_object($routes['test1']), '->loadConfiguration() Route objects are not serialized in cache'); $t->is_deeply($r->parse('/'), array('module' => 'default', 'action' => 'index'), '->parse() Default parameters are applied to serialized routes');