From: Marcus Boerger Date: Sat, 14 May 2005 16:40:58 +0000 (+0000) Subject: - Execute both RecursiveIteratorIterator::beginChildren() and endChildren() X-Git-Tag: php-5.0.1b1~237 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=626d781afd9adabd299b0df3d441b8e647d74fa4;p=php - Execute both RecursiveIteratorIterator::beginChildren() and endChildren() on the same level (while the actual child is available). --- diff --git a/ext/spl/internal/recursiveiteratoriterator.inc b/ext/spl/internal/recursiveiteratoriterator.inc index 65f9a20ba9..0e76de21dd 100755 --- a/ext/spl/internal/recursiveiteratoriterator.inc +++ b/ext/spl/internal/recursiveiteratoriterator.inc @@ -164,14 +164,15 @@ class RecursiveIteratorIterator implements OuterIterator return $this->ait[$this->count]->getChildren(); } - /** Called right after calling getChildren() + /** Called right after calling getChildren() and its rewind(). * @since PHP 5.1 */ function beginChildren() { } - /** Called after current child iterator is invalid + /** Called after current child iterator is invalid and right before it + * gets destructed. * @since PHP 5.1 */ function endChildren() diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 879d357374..d8f672cc36 100755 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -251,12 +251,12 @@ next_step: } /* no more elements */ if (object->level > 0) { - iterator->funcs->dtor(iterator TSRMLS_CC); - zval_ptr_dtor(&object->iterators[object->level].zobject); - object->level--; if (object->endChildren) { zend_call_method_with_0_params(&zthis, object->ce, &object->endChildren, "endchildren", NULL); } + iterator->funcs->dtor(iterator TSRMLS_CC); + zval_ptr_dtor(&object->iterators[object->level].zobject); + object->level--; } else { return; /* done completeley */ }