Skip to content

Fix GH-8068: mysqli_fetch_object creates inaccessible properties #8189

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 3 commits into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Mar 10, 2022

When fetching into objects, we need to create object style hash tables,
i.e. where numeric column names are stored as string keys instead of
integer keys. Instead of the slightly more efficient alternative to
create the desired hash table in the first place, we go for the more
readable implementation and convert the array style hash table using
zend_symtable_to_proptable().

When fetching into objects, we need to create object style hash tables,
i.e. where numeric column names are stored as string keys instead of
integer keys.  Instead of the slightly more efficient alternative to
create the desired hash table in the first place, we go for the more
readable implementation and convert the array style hash table using
`zend_symtable_to_proptable()`.
@cmb69 cmb69 linked an issue Mar 10, 2022 that may be closed by this pull request
@cmb69 cmb69 requested a review from kamil-tekiela March 10, 2022 18:22
Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@kamil-tekiela kamil-tekiela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this. This is a simple solution and it works.

The only other alternative I see would be to add to mysqlnd a way of fetching an object HashTable but that would require changing a lot of code and possibly even duplicating some. This is probably not worth it for the performance gain it would bring.

I have checked the performance and, in my tests, it seems to be up to 40% worse. It's not good but at the same time I doubt it will be noticeable in real-life scenarios. I think we can live with it.

cmb69 and others added 2 commits March 11, 2022 13:02
@cmb69 cmb69 closed this in ef29ddc Mar 14, 2022
@cmb69 cmb69 deleted the cmb/gh8068 branch March 14, 2022 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mysqli_fetch_object creating objects with inaccessible properties
3 participants