SF's routing accept NULL as default value for parameters but can't handle generation correctly. In the following example, the route will match, but generation will fail, telling a mandatory parameter is missing:
myroute:
url: /foo/:bar
param: { bar: ~ }
This is because an array_filter() is performed on parameters before to check if all mandatory parameters are present. The fix would be to remove this array_filter() (see patch below).
diff --git a/lib/routing/sfRoute.class.php b/lib/routing/sfRoute.class.php
index c24c72d..3bc02e2 100644
--- a/lib/routing/sfRoute.class.php
+++ b/lib/routing/sfRoute.class.php
@@ -206,7 +206,7 @@ class sfRoute implements Serializable
$tparams = $this->mergeArrays($defaults, $params);
// all params must be given
- if ($diff = array_diff_key($this->variables, array_filter($tparams)))
+ if ($diff = array_diff_key($this->variables, $tparams))
{
throw new InvalidArgumentException(sprintf('The "%s" route has some missing mandatory parameters (%s).', $this->pattern, implode(', ', $diff)));
}