ZF-4631: Zend_Dom_Query_Result breaks foreach() iteration on empty result sets



$dom = new Zend_Dom_Query('example.html'); foreach ($dom->query('elementdoesnotexist') as $element) { echo $element->getAttribute('id'); }

This snippet will crash with fatal error 'Call to a member function getAttribute() on a non-object'.

Why? Because Zend_Dom_Query_Result::valid() returns TRUE for empty result sets. This bug also exists in the latest SVN (rev 12003).


Fixed in trunk, added a new TestCase class Zend_Dom_Query_ResultTest for this

Changing issues in preparation for the 1.7.0 release.