From: dpantel at gmail dot com
Operating system: RHES (linux 2.4.21-37)
PHP version: 5.1.1
PHP Bug Type: SPL related
Bug description: RecursiveIteratorIterator constructor fails to recognize mode
constants
Description:
------------
RecursiveIteratorIterator constructor fails to recognize mode constants.
The constructor works fine when passed only a RecursiveIterator object.
It also functions correctly if passed a RecursiveIterator object and an
integer (0,1,2, etc) as the second (mode) argument. However, if one
attempts to pass a documented constant keyword (RIT_SELF_FIRST or
SELF_FIRST), the constructor fails.
Note: different documentations show different constant definitions
(RIT_SELF_FIRST vs SELF_FIRST). I have tried both, and neither one works.
Reproduce code:
---------------
class Rit implements RecursiveIterator {...}
$test = new Rit();
//work fine
$rii = new RecursiveIteratorIterator($test);
$rii = new RecursiveIteratorIterator($test, 1);
//do not work
$rii = new RecursiveIteratorIterator($test, RIT_SELF_FIRST);
$rii = new RecursiveIteratorIterator($test, SELF_FIRST);
//even tried this, with no avail
$rii = new RecursiveIteratorIterator($test,
RecursiveIteratorIterator::RIT_SELF_FIRST);
$rii = new RecursiveIteratorIterator($test,
RecursiveIteratorIterator::SELF_FIRST);
Expected result:
----------------
A RecursiveIteratorIterator object
Actual result:
--------------
Notice: Use of undefined constant RIT_SELF_FIRST - assumed
'RIT_SELF_FIRST' in /www/rit.class.php on line 276
(or Notice: Use of undefined constant SELF_FIRST - assumed 'SELF_FIRST' in
/www/rit.class.php on line 276)
Fatal error: Uncaught exception 'InvalidArgumentException' with message
'An instance of RecursiveIterator or IteratorAggregate creating it is
required' in /www/rit.class.php:276 Stack trace: #0
/www/rit.class.php(276):
RecursiveIteratorIterator->__construct(Object(treeIterator),
'RIT_SELF_FIRST') ...
--
Edit bug report at http://bugs.php.net/?id=35734&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=35734&r=trysnapshot44
Try a CVS snapshot (PHP 5.1):
http://bugs.php.net/fix.php?id=35734&r=trysnapshot51
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=35734&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=35734&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=35734&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=35734&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=35734&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=35734&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=35734&r=support
Expected behavior: http://bugs.php.net/fix.php?id=35734&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=35734&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=35734&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=35734&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35734&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=35734&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=35734&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=35734&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=35734&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=35734&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=35734&r=mysqlcfg