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

Issue Type: Bug Created: 2008-10-18T04:07:20.000+0000 Last Updated: 2008-11-13T14:10:24.000+0000 Status: Resolved Fix version(s): - 1.7.0 (17/Nov/08)

Reporter: Ben Noordhuis (bnoordhuis) Assignee: Benjamin Eberlei (beberlei) Tags: - Zend_Dom_Query

Related issues: Attachments:



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


Posted by Benjamin Eberlei (beberlei) on 2008-11-07T01:35:49.000+0000

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

Posted by Wil Sinclair (wil) on 2008-11-13T14:10:24.000+0000

Changing issues in preparation for the 1.7.0 release.

Have you found an issue?

See the Overview section for more details.


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

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