Browse Source

[Routing] fixed generation when a default value is null

Fabien Potencier 14 years ago
parent
commit
df81296443
1 changed files with 1 additions and 1 deletions
  1. 1 1
      src/Symfony/Component/Routing/Generator/UrlGenerator.php

+ 1 - 1
src/Symfony/Component/Routing/Generator/UrlGenerator.php

@@ -108,7 +108,7 @@ class UrlGenerator implements UrlGeneratorInterface
         $optional = true;
         $optional = true;
         foreach ($tokens as $token) {
         foreach ($tokens as $token) {
             if ('variable' === $token[0]) {
             if ('variable' === $token[0]) {
-                if (false === $optional || !isset($defaults[$token[3]]) || (isset($parameters[$token[3]]) && $parameters[$token[3]] != $defaults[$token[3]])) {
+                if (false === $optional || !array_key_exists($token[3], $defaults) || (isset($parameters[$token[3]]) && $parameters[$token[3]] != $defaults[$token[3]])) {
                     if (!$isEmpty = in_array($tparams[$token[3]], array(null, '', false), true)) {
                     if (!$isEmpty = in_array($tparams[$token[3]], array(null, '', false), true)) {
                         // check requirement
                         // check requirement
                         if ($tparams[$token[3]] && !preg_match('#^'.$token[2].'$#', $tparams[$token[3]])) {
                         if ($tparams[$token[3]] && !preg_match('#^'.$token[2].'$#', $tparams[$token[3]])) {