php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44838 Extending RecursiveDirectoryIterator not possible, getChildren Class wrong
Submitted: 2008-04-26 09:08 UTC Modified: 2008-05-03 16:01 UTC
From: dev_oskar at hotmail dot com Assigned: colder (profile)
Status: Closed Package: SPL related
PHP Version: 5.2.5 OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dev_oskar at hotmail dot com
New email:
PHP Version: OS:

 

 [2008-04-26 09:08 UTC] dev_oskar at hotmail dot com
Description:
------------
RecursiveDirectoryIterator::getChildren uses a hard coded reference to itself in the function getChildren, so it can't be extended.
Note: It's not possible to completely overwrite getChildren without a lose of subPath handling.


In spl_directory.c:

SPL_METHOD(RecursiveDirectoryIterator, getChildren)

... 

spl_instantiate_arg_ex1(spl_ce_RecursiveDirectoryIterator, &return_value, 0, &zpath TSRMLS_CC);

...

This should be changed to something like the RecursiveFilterIterator getChildren uses:

spl_instantiate_arg_ex1(Z_OBJCE_P(getThis() ...



Reproduce code:
---------------
class RecursiveDirectoryIteratorTest extends RecursiveDirectoryIterator
{

public function test() {
    echo "test";
}

}

$di = new RecursiveIteratorIterator(new RecursiveDirectoryIteratorTest ("/somepathwithsubfolders"), RecursiveIteratorIterator::SELF_FIRST);

foreach ($di as $key => $value) {
    echo $key, " - ",$value, $di->test(),"<br>";
}



Expected result:
----------------
echoing "test" for each item.

Actual result:
--------------
Call to undefined method RecursiveDirectoryIterator::test() as soon getChildren creates a new object for a subfolder.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-03 16:01 UTC] colder@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 17:01:29 2024 UTC