[ciapug] Symfony bug
carl-olsen at mchsi.com
carl-olsen at mchsi.com
Tue Nov 6 09:38:26 CST 2007
If a parameter (form field) is blank, you can supply a default value in the Symfony form helpers. Unfortunately, the code checks for a null value instead of an empty string, and it doesn't work. I corrected the code by adding a check for an empty string (although I don't see how it is possible for a null value to ever be returned by the calling code - a form post).
Here is the bug I mentioned at the meeting last night:
#2436: BUG in sfParameterHolder.class.php
----------------------------+-------------------------------------------
----------------------------+----
Reporter: carlolsen | Owner: fabien
Type: defect | Status: new
Priority: minor | Component: other
Version: 1.0.8 | Keywords:
Qualification: Unreviewed |
----------------------------+-------------------------------------------
----------------------------+----
On line 87 of sfParameterHolder.class.php the check for a null value is not going to catch an empty string. I rewrote the method, as follows (starting at line 80):
public function & get($name, $default = null, $ns = null)
{
if (!$ns)
{
$ns = $this->default_namespace;
}
if (isset($this->parameters[$ns][$name]) && ($this->parameters[$ns][$name] != ''))
{
$value = & $this->parameters[$ns][$name];
}
else if (isset($this->parameters[$ns]))
{
$value = sfToolkit::getArrayValueForPath($this->parameters[$ns],
$name, $default);
}
else
{
$value = $default;
}
return $value;
}
--
Ticket URL: <http://trac.symfony-project.com/ticket/2436>
symfony <http://www.symfony-project.com/> symfony project
More information about the ciapug
mailing list