Issues

ZF-3157: partialLoop helper - check for ArrayObject

Issue Type: Bug Created: 2008-04-21T07:17:17.000+0000 Last Updated: 2008-05-05T11:44:42.000+0000 Status: Resolved Fix version(s): - 1.5.2 (15/May/08)

Reporter: Andries Seutens (andries) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_View

Related issues: Attachments:

Description

There seem to be a bug on SPL level: ArrayObject does not report as Iterator with PHP 5.2.4. It implements ArrayAccess, which indirectly implements Iterator via ArrayIteartor.

This causes a bug when providing an empty ArrayObject to the partialLoop view helper.

Fails:

<pre class="highlight">
<?php echo $this->partialLoop('catalog/products.phtml', new ArrayObject()) ?>

Works:

<pre class="highlight">
<?php $object = new ArrayObject() ?>
<?php echo $this->partialLoop('catalog/products.phtml', $object->getIterator()) ?>

To fix this in ZF, we need to add an extra check in the partialLoop helper that checks for ArrayObject:

<pre class="highlight">
if (!is_array($model) && (!$model instanceof Iterator or !$model instanceof ArrayObject)) { }

Comments

Posted by Andries Seutens (andries) on 2008-04-21T07:56:48.000+0000

Reported by Matthew:

[http://bugs.php.net/bug.php?id=44793]

Posted by Matthew Weier O'Phinney (matthew) on 2008-04-21T11:16:32.000+0000

Actually, discovered that ArrayAccess does not implement ArrayIterator, but vice versa... meaning that ArrayObject does not implement Iterator. The correct behavior would be to check for Traversable, which would catch both Iterators and ArrayObjects, and would work with foreach().

Posted by Matthew Weier O'Phinney (matthew) on 2008-04-22T10:56:18.000+0000

Scheduling for next mini release.

Posted by Matthew Weier O'Phinney (matthew) on 2008-05-02T12:16:55.000+0000

Resolved in trunk and 1.5 release branch

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts