From: dev_oskar at hotmail dot com
Operating system: Irrelevant
PHP version: 5.2.5
PHP Bug Type: SPL related
Bug description: Extending RecursiveDirectoryIterator not possible,
getChildren Class wrong
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 bug report at http://bugs.php.net/?id=44838&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=44838&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=44838&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=44838&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44838&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=44838&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44838&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44838&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44838&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44838&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44838&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=44838&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=44838&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44838&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44838&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=44838&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44838&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44838&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44838&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44838&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44838&r=mysqlcfg