Zend Framework

partialLoop helper - check for ArrayObject

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.5.2
  • Component/s: Zend_View
  • Labels:
    None
  • Fix Version Priority:
    Must Have

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:

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

Works:

<?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:

if (!is_array($model) && (!$model instanceof Iterator or !$model instanceof ArrayObject)) { }

Activity

Hide
Andries Seutens added a comment -
Show
Andries Seutens added a comment - Reported by Matthew: http://bugs.php.net/bug.php?id=44793
Hide
Matthew Weier O'Phinney added a comment -

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().

Show
Matthew Weier O'Phinney added a comment - 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().
Hide
Matthew Weier O'Phinney added a comment -

Scheduling for next mini release.

Show
Matthew Weier O'Phinney added a comment - Scheduling for next mini release.
Hide
Matthew Weier O'Phinney added a comment -

Resolved in trunk and 1.5 release branch

Show
Matthew Weier O'Phinney added a comment - Resolved in trunk and 1.5 release branch

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
15m
Original Estimate - 15 minutes
Remaining:
15m
Remaining Estimate - 15 minutes
Logged:
Not Specified
Time Spent - Not Specified