-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed bug #61527 (Recursive/ArrayIterator gives misleading notice when array empty or moved to the end) #38
Conversation
@@ -58,6 +58,29 @@ | |||
#define SPL_ARRAY_INT_MASK 0xFFFF0000 | |||
#define SPL_ARRAY_CLONE_MASK 0x0300FFFF | |||
|
|||
#define SPL_ARRAY_CHECK_POS_EMPTY_OR_END_REACHED(object, ht, err_msg) do { \ | |||
if (!aht) { \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably should be ht
, as that's what you're passing into the macro.
update: error messsage updated & if else branch cleanup |
Thanks for reply, I will updated it soon;) |
btw are you sure the bug id is correct? The bug you refer to is closed and has little to do with your change. |
Which bug you are trying to fix? Bug #61347 is "inconsistent isset behavior of Arrayobject" and already fixed. |
There should be no messages when array is iterated to an end - it is perfectly normal thing to do. Empty array is a perfectly normal thing too, there should be no messages on that either. Also, I don't see why array should be rewinded. If it's at the end, it should just stay there. |
sorry ,my fault it's Bug#61527 |
I agree with @smalyshev here. It's perfectly valid to iterate over an empty array. As #61527 points out, there shouldn't be any Notice at all in those cases. |
em, it makes sense, next() didn't notice too. so no notice at all in this case, am I right? |
but the method related to current entry still need notice if array was empty or reached the end. thanks |
I have updated the patch:
@smalyshev I've already rebased the pull request, that has been updated. the previous code show up in discussion. "There should be no messages when array is iterated to an end - it is perfectly normal thing to do. Empty array is a perfectly normal thing too, there should be no messages on that either. Also, I don't see why array should be rewinded. If it's at the end, it should just stay there." Thanks. |
current() should not give any notices either. It should just return false. That notice does not contribute anything. |
actually, I think only notice for :"modified outside" is enough. no need yelling for "reached the end" |
…n array empty or moved to the end)
Hi, Thanks. |
Comment on behalf of stas at php.net: merged |
Hi,
when calling
- ArrayIterator->next(),
- ArrayIterator->key(),
- ArrayIterator->current(),
- RecurseArrayIterator->getChildren()
- RecurseArrayIterator->hasChildren()
it will raise misleading(array was modified outside) message. when array was empty or moved to then end of array.
This pull request is trying to fix it.
Thanks.