Hello,
I'm switching my project from sf1.1 to sf1.2 (beta2/rc1 for now) and I'm having trouble with some default values for the route variables:
Imagine that this is one part of my routing.yml:
route_name:
url: /mypath/:myvariable
param: {module: mymodule, action: myaction, myvariable: 0}
When it comes to generating an URL (p.e. with link_to in a template), I get the following error message, in case I do not specify myvariable or myvariable takes the value 0:
The "/mypath/:myvariable.html" route has some missing mandatory parameters (:myvariable).
Digging into it I found that in sfRoute.class.php (around line 208) it says
// all params must be given
if ($diff = array_diff_key($this->variables, array_filter($tparams)))
{
throw new InvalidArgumentException(sprintf('The "%s" route has some missing mandatory parameters (%s).', $this->pattern, implode(', ', $diff)));
}
The problem here seems to be the use of array_filter() because it removes keys from the $tparams array that have a value of 0 (== false). This leads to array_diff_key to be true and throwing of the InvalidArgumentException?.
For me removing array_filter from the if-statement solved the problem.
(The use of array_filter might be incorrect in other places (in sfRoute.class.php)?!)