#44838 [Opn->Csd]: Extending RecursiveDirectoryIterator not possible, getChildren Class wrong
| From: | colder@php.net | Date: | Sat, 03 May 2008 16:01:19 +0000 |
| Subject: | #44838 [Opn->Csd]: Extending RecursiveDirectoryIterator not possible, getChildren Class wrong | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-124702@lists.php.net to get a copy of this message | ||
ID: 44838
Updated by: colder@php.net
Reported By: dev_oskar at hotmail dot com
-Status: Open
+Status: Closed
Bug Type: SPL related
Operating System: Irrelevant
PHP Version: 5.2.5
-Assigned To:
+Assigned To: colder
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2008-04-26 09:08:49] 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.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=44838&edit=1