Skip to content

Commit b41d8cd

Browse files
committed
(fixed #4439, BP from #4438) Fix sfPatternRouting->getRoutes() sometimes returning serialized routes
FriendsOfSymfony1/symfony1#169 参照
1 parent 1860953 commit b41d8cd

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/vendor/symfony/lib/routing/sfPatternRouting.class.php

+8
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ public function getCurrentRouteName()
144144
*/
145145
public function getRoutes()
146146
{
147+
foreach ($this->routes as $name => $route) {
148+
if (is_string($route)) {
149+
$route = unserialize($route);
150+
$route->setDefaultParameters($this->defaultParameters);
151+
$this->routes[$name] = $route;
152+
}
153+
}
154+
147155
return $this->routes;
148156
}
149157

lib/vendor/symfony/test/unit/routing/sfPatternRoutingTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,8 @@ function configureRouting($event)
639639
// see fixtures/config_routing.yml.php
640640
$r = new sfPatternRoutingTest(new sfEventDispatcher(), new sfNoCache(), array('load_configuration' => true));
641641
$t->ok($r->hasRouteName('test1'), '->loadConfiguration() Config file is loaded');
642-
$routes = $r->getRoutes();
643-
$t->ok(is_string($routes['test1']), '->loadConfiguration() Route objects are not serialized in cache');
644642
$route = $r->getRoute('test1');
645643
$t->ok(is_object($route), '->loadConfiguration() Route objects are unserialized on demand');
644+
$routes = $r->getRoutes();
645+
$t->ok(is_object($routes['test1']), '->loadConfiguration() Route objects are not serialized in cache');
646646
$t->is_deeply($r->parse('/'), array('module' => 'default', 'action' => 'index'), '->parse() Default parameters are applied to serialized routes');

0 commit comments

Comments
 (0)