From a1d1a02b47fe211d7dfd072a43f2eed4f5709002 Mon Sep 17 00:00:00 2001 From: Tim Nagel Date: Tue, 10 Jul 2012 13:59:45 +1000 Subject: [PATCH 1/2] Null default value route regression --- .../FrameworkBundle/Tests/Routing/RouterTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php index 1d50d7a25f..877cc2df4a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php @@ -144,6 +144,19 @@ class RoutingTest extends \PHPUnit_Framework_TestCase $router->getRouteCollection()->get('foo'); } + public function testDefaultValueNullAsEmptyStringRegression() + { + $routes = new RouteCollection(); + $routes->add('foo', new Route('foo', array('foo' => null), array('foo' => '\d+'))); + + $sc = $this->getServiceContainer($routes); + + $router = new Router($sc, 'foo'); + + $route = $router->getRouteCollection()->get('foo'); + $this->assertNull($route->getDefault('foo')); + } + private function getServiceContainer(RouteCollection $routes) { $loader = $this->getMock('Symfony\Component\Config\Loader\LoaderInterface'); From c061c30a9e50f0250b3e5e5e08d60484daa017b8 Mon Sep 17 00:00:00 2001 From: Tim Nagel Date: Tue, 10 Jul 2012 14:22:39 +1000 Subject: [PATCH 2/2] Router#resolveString should return null instead of empty string when $value is null Closes #4823 --- src/Symfony/Bundle/FrameworkBundle/Routing/Router.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php index 3f9b5cf75e..c69ec13066 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php @@ -114,6 +114,10 @@ class Router extends BaseRouter implements WarmableInterface { $container = $this->container; + if (null === $value) { + return null; + } + $escapedValue = preg_replace_callback('/%%|%([^%\s]+)%/', function ($match) use ($container, $value) { // skip %% if (!isset($match[1])) {