php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68128 Regression in RecursiveRegexIterator
Submitted: 2014-10-01 22:00 UTC Modified: 2014-10-06 01:11 UTC
From: ivan dot enderlin at hoa-project dot net Assigned:
Status: Closed Package: *General Issues
PHP Version: master-Git-2014-10-01 (Git) OS:
Private report: No CVE-ID: None
 [2014-10-01 22:00 UTC] ivan dot enderlin at hoa-project dot net
Description:
------------
There is a regression in the RecursiveRegexIterator iterator. Detected by the failure of a test in the Hoa\Iterator library. Test script from the documentation (http://php.net/recursiveregexiterator.construct).

Test script:
---------------
<?php
$rArrayIterator = new RecursiveArrayIterator(array('test1', array('tet3', 'test4', 'test5')));
$rRegexIterator = new RecursiveRegexIterator($rArrayIterator, '/^test/',
    RecursiveRegexIterator::ALL_MATCHES);

foreach ($rRegexIterator as $key1 => $value1) {

    if ($rRegexIterator->hasChildren()) {

        // print all children
        echo "Children: ";
        foreach ($rRegexIterator->getChildren() as $key => $value) {
            echo $value . " ";
        }
        echo "\n";
    } else {
        echo "No children\n";
    }

}
?>


Expected result:
----------------
No children
Children: test4 test5

Actual result:
--------------
Aucun fils disponible
PHP Notice:  Array to string conversion in /tmp/a.php on line 6

Notice: Array to string conversion in /tmp/a.php on line 6
Fils : test4 test5

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-05 10:15 UTC] ivan dot enderlin at hoa-project dot net
Also happens in PHP5.6.2-dev.
 [2014-10-05 12:45 UTC] ivan dot enderlin at hoa-project dot net
Also happens in PHP5.5.19-dev.
 [2014-10-05 13:26 UTC] ivan dot enderlin at hoa-project dot net
From PHP5.4 to 5.6.1, it fails: http://3v4l.org/msnnF.

So this is not really a regression, this is just a bug from a long time (but it worked in 5.3).
 [2014-10-06 01:11 UTC] datibbaw@php.net
Tracked the issue down to this commit: http://git.php.net/?p=php-src.git;a=commit;h=d81ea16ef14735b97f22702ca1a78c3674fd987e

After the change it no longer silently converts arrays into string("Array") and this affects RecursiveRegexFilterIterator::accept().
 [2014-10-06 07:06 UTC] ivan dot enderlin at hoa-project dot net
Ok, and so what is the next step? The documentation is wrong and the class does not work as expected.
 [2014-10-06 07:07 UTC] ivan dot enderlin at hoa-project dot net
PR on Github: https://github.com/php/php-src/pull/865.
 [2014-10-14 15:00 UTC] datibbaw@php.net
Automatic comment on behalf of datibbaw
Revision: http://git.php.net/?p=php-src.git;a=commit;h=71ba533640a33bf6d034637ad68c145dec3180ba
Log: Fixed bug #68128
 [2014-10-14 15:00 UTC] datibbaw@php.net
-Status: Open +Status: Closed
 [2014-10-15 10:11 UTC] ab@php.net
Automatic comment on behalf of datibbaw
Revision: http://git.php.net/?p=php-src.git;a=commit;h=71ba533640a33bf6d034637ad68c145dec3180ba
Log: Fixed bug #68128
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC