浏览代码

Merge remote branch 'udat/router/empty-string-as-default-parameter-value'

Fabien Potencier 14 年之前
父节点
当前提交
ef87ca3d75

+ 1 - 1
src/Symfony/Component/Routing/RouteCompiler.php

@@ -212,7 +212,7 @@ class RouteCompiler implements RouteCompilerInterface
         $this->segments[] = preg_quote($separator, '#').'(?P<'.$variable.'>'.$requirement.')';
         $this->variables[$variable] = $name;
 
-        if (!$this->route->getDefault($variable)) {
+        if (null === $this->route->getDefault($variable)) {
             $this->firstOptional = count($this->segments);
         }
     }

+ 1 - 1
tests/Symfony/Tests/Component/Routing/RouteCompilerTest.php

@@ -69,7 +69,7 @@ class RouteCompilerTest extends \PHPUnit_Framework_TestCase
 
             array(
                 'Route with several variables that have default values',
-                array('/foo/{bar}/{foobar}', array('bar' => 'bar', 'foobar' => 'foobar')),
+                array('/foo/{bar}/{foobar}', array('bar' => 'bar', 'foobar' => '')),
                 '/foo', '#^/foo(?:/(?P<bar>[^/\.]+?) (?:/(?P<foobar>[^/\.]+?) )?)?$#x', array('bar' => '{bar}', 'foobar' => '{foobar}'), array(
                     array('variable', '/', '{foobar}', 'foobar'),
                     array('variable', '/', '{bar}', 'bar'),