Bug #75942 [Com]: Backward incompatibility introduced in RecursiveArrayIterator

From: Date: Tue, 13 Feb 2018 09:17:06 +0000
Subject: Bug #75942 [Com]: Backward incompatibility introduced in RecursiveArrayIterator
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213935@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75942&edit=1 ID: 75942 Comment by: andries at centim dot be Reported by: andries at centim dot be Summary: Backward incompatibility introduced in RecursiveArrayIterator Status: Open Type: Bug Package: SPL related Operating System: any PHP Version: 7.1.14 Block user comment: N Private report: N New Comment: Which objects are unsupported objects? I tried it with a couple of other internal classes (Exception, stdClass), but could not reproduce the error with those. Previous Comments: ------------------------------------------------------------------------ [2018-02-09 08:46:04] nikic@php.net The fix for bug #73209 restores the behavior of PHP 5.x, which was accidentally broken during the migration to PHP 7. This is definitely a bug, in particular because previously behavior would differ based on whether or not the property was declared. If it was not declared, the properties would have already been iterated and you'd already see the error. Due to the aforementioned migration issue, the same did not happen for declared object properties. RecursiveArrayIterator has an option CHILD_ARRAYS_ONLY to limit recursion to arrays only. One potential change we could make here is to not try to iterate overloaded objects in RecursiveArrayIterator, thus also avoiding the exception. I think this exception is more intended for ArrayIterator and it might be better to just skip unsupported objects in RecursiveArrayIterator. ------------------------------------------------------------------------ [2018-02-09 07:56:20] andries at centim dot be Description: ------------ I'm referencing to ticket https://bugs.php.net/bug.php?id=73209 that was fixed in PHP 7.1.14, and seems to have introduced a backward compatibility issue compared to PHP 7.1.13. I'm creating a new ticket, as this ticket was already closed. When RecursiveArrayIterator is used in combination with a RecursiveIteratorIterator, and your class has a public property that contains a DateTime instance, it will crash with the following error: Overloaded object of type DateTime is not compatible with RecursiveArrayIterator This did not produce an error on PHP 7.1.13, Was it a bug that it didn't iterate object properties? Or is supporting it a new feature? I lean toward the latter without having seen the spec, but either way the current fix breaks backward compatibility. Test script: --------------- https://gist.github.com/andriesss/b22b4057bd7e0563f4d21b7b2cfd6a09 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75942&edit=1

« previous php.bugs (#213935) next »