Skip to content

fix bug #72254 - get_object_vars with numerical properties #2091

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

Closed
wants to merge 1 commit into from

Conversation

schlndh
Copy link

@schlndh schlndh commented Aug 20, 2016

The problem is that PHP 5.6 uses add_assoc_zval_ex function to add properties to returned array, which handles numerical keys separately, whereas PHP 7.0 either returns the properties hashtable directly (in which case I guess that numerical keys are not handled separately) or adds properties to returned array using zend_hash_str_add_new/zend_has_add_new functions which again don't handle numerical keys separately.

I suspect that the reason why numerical keys are not accessible using the PHP 7 code is that when accessing an array, numerical keys are always handled separately and because they are stored as ordinary string keys, they cannot be accessed.

I therefore switched back to add_assoc_zval_ex function and removed the code that just returned properties hashtable, since it can contain numerical keys stored as strings and would need to be duplicated anyway.

@php-pulls
Copy link

Comment on behalf of cmb at php.net:

This issue has already been fixed by PR #2142, which has been already merged. Also the respective bug report has been closed, so I'm closing this PR.

Thanks for the PR, anyway!

@php-pulls php-pulls closed this Dec 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants