Arbit - project tracking

Dwoo

#36: readVarInto function and safeMode param

Issue revisions

  • closed by lmilitao at 2009-J-24 15:48
Type bug bug
State closed closed
Priority high high
Resolution fixed fixed
Assigned to Jordi Boggiano
Scheduled for 1.1.1
Affected versions
Affected components Core
Last change Friday 24 July 2009 15:48:51 UTC by lmilitao

Consider the following code lines:

<pre> {foreach name="categories" from=$categories item=category}

{$category->id} {$category->name|upper}

{/foreach} </pre>

Inside the foreach block the first line works perfectly but the second line returns nothing.

I think that this happens when you use a plugin var with any kind of plugin modifier (block, function, etc...).

I have checked the compiled view file and this problem occurs when you have a safeMode param in the readVarInto function set to true. If safeMode param is set to false the above lines will work.

Doesn't work: $_fh0_data = $this->readVarInto(array ( 1 => array ( 0 => '->', ), 2 => array ( 0 => 'links', ), 3 => array ( 0 => '', 1 => '', ),), (isset($this->scope["category"]) ? $this->scope["category"]:null), true);

Works! $_fh0_data = $this->readVarInto(array ( 1 => array ( 0 => '->', ), 2 => array ( 0 => 'links', ), 3 => array ( 0 => '', 1 => '', ),), (isset($this->scope["category"]) ? $this->scope["category"]:null), false);

  • Jordi Boggiano at Monday 12 October 2009 20:51:44 UTC

    Heya, sorry for the slow response, busy times.. Anyway I couldn't reproduce your problem at first but I have now understood that it happens with objects that use the magic __get method to return properties. Since the "true" behavior does a isset() check, it fails since the property is not actually there.

    I can fix it by additionally checking if __get is callable if the isset() fails, and I'll commit that fix. However, I must say that it's sort of your fault, or whoever wrote that class, for not implementing the __isset() magic method at the same time. I would recommend that you implement it for performance reasons and for completeness too. See http://www.php.net/manual/en/language.oop5.overloading.php#language.oop5.overloading.members for details.

  • Jordi Boggiano at Monday 12 October 2009 20:56:23 UTC

    Applied in changeset r290.