Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports

[2009-08-16 01:28 UTC] president at basnetworks dot net

I addition to the reproduce code, the following may help to understand the bug:
foreach ($array_object as $item)
{
echo $item;
}
Will successfully print "abc", while:
foreach ((isset($array_object) ? $array_object : array()) as $item)
{
echo $item;
}
will not print anything, indicating that isset() is returning false. I hope that helps.

[2009-08-16 01:36 UTC] president at basnetworks dot net

After further testing, I have found this bug is stranger than it seems:
foreach ((isset($array_object) ? $array_object : array('1', '2', '3')) as $item)
{
echo $item;
}
Should either print 'abc' or '123' no matter if isset() is successful or fails. It prints neither. Now I am wondering if it is not isset(), but the ternary operator that is failing.

Note that the Iterator in my previous comment sucks and should not be used.

[2009-08-16 17:21 UTC] president at basnetworks dot net

sjoerd-php at linuxonly dot nl,
Your code sample is much clearer, and seems to narrow it down to the ternary operator mis-behaving. Thanks for the added clarification, I will update the report.
You should also "vote" that you reproduced the bug above.

This bug has been fixed in SVN.
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.