Welcome Guest, Not a member yet? Register   Sign In
[not fixed]# Fixed a bug (#2668) in the parser class where numeric data was ignored.
#1

[eluser]Unknown[/eluser]
The bug is not totally fixed.

The current fix is the '(string)' from Parser.php line #63
Code:
$template = $this->_parse_single($key, (string)$val, $template);

But line #135 should be also changed to
Code:
$temp = $this->_parse_single($key, (string)$val, $temp);

OR, only line #104 should be changed to
Code:
return str_replace($this->l_delim.$key.$this->r_delim, (string)$val, $string);
#2

[eluser]coolfactor[/eluser]
I've worked around this issue by coercing numeric values to strings prior to assigning to the view.

Ironically, CI 1.6.0 attempts to implement your suggestion, but takes a step backwards by removing the string check that's existed for a few versions now.

CI 1.5.4:
Code:
if (is_string($val))
{
    $template = $this->_parse_single($key, $val, $template);
}
elseif (is_array($val))
{
    $template = $this->_parse_pair($key, $val, $template);
}

CI 1.6.0:
Code:
if (is_array($val))
{
    $template = $this->_parse_pair($key, $val, $template);
}
else
{
    $template = $this->_parse_single($key, (string)$val, $template);
}

The is_string() check was originally added by Rick to allow objects to be assigned to the view, and avoid them from being parsed, which generates an error.

[strike]I agree with this thread that is_scalar() is an even better solution. Non-scalar variables (other than arrays) should just be ignored entirely by the Parser.[/strike]
#3

[eluser]coolfactor[/eluser]
Actually, now I retract my previous suggestion that is_scaler() is a better check. Boolean values would be converted to strings, but that might not be the desired behavior. I quite often assign TRUE or FALSE to the view, and would want those values to be available in their native format, even in parsed views. I return to my original feeling that only strings and arrays should be handled by the Parser, with everything else left in their native format.

However, an additional allowance should be made for integers to avoid them from being ignored.
#4

[eluser]coolfactor[/eluser]
I think the real issue lay in the assumption by CodeIgniter (1.6.0) that when using a parsed view, all variables assigned to the view will be parsed. However, that's not the case for me. I use partially-parsed views. Sometimes it makes sense to just use {page_title} instead of <?php echo $page_title; ?>, but I'll still need the conditionals and loop structures.




Theme © iAndrew 2016 - Forum software by © MyBB