Bug #77633 [NEW]: Preloading incompatible with ArrayItertor inheritance

From: Date: Mon, 18 Feb 2019 10:48:06 +0000
Subject: Bug #77633 [NEW]: Preloading incompatible with ArrayItertor inheritance
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219625@lists.php.net to get a copy of this message
From: nikic Operating system: PHP version: master-Git-2019-02-18 (Git) Package: Scripting Engine problem Bug Type: Bug Bug description:Preloading incompatible with ArrayItertor inheritance Description: ------------ When extending an ArrayIterator, the get_iterator handler is overridden with spl_array_get_iterator **during object construction**: https://github.com/php/php-src/blob/8ee78441f87d59f22c2e6865a31e87f5076500da/ext/spl/spl_array.c#L211 This is incompatible with preloading, as the class is immutable at this point. We can't simply remove the assignment, because this would break by-ref iteration of objects extending ArrayIterator. Another way to handle this would be to inherit get_iterator in the interface_gets_implemented handlers for Iterator/IteratorAggregate. Unfortunately this also doesn't work, because some code (e.g. RecursiveIteratorIterator) assumes that the user get_iterator handler will be used if the class is inherited (it does not deal with overridden iterator methods). Test script: --------------- <?php class Foo extends ArrayIterator {} new Foo([]); -- Edit bug report at https://bugs.php.net/bug.php?id=77633&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77633&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77633&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77633&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77633&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77633&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77633&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77633&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77633&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77633&r=support Expected behavior: https://bugs.php.net/fix.php?id=77633&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77633&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77633&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77633&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77633&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77633&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77633&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77633&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77633&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77633&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77633&r=mysqlcfg

« previous php.bugs (#219625) next »