Skip to content

ext/standard: make debug_zval_dump() output whether the array is packed #12641

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

Merged
merged 1 commit into from
Jan 12, 2024

Conversation

MaxSem
Copy link
Contributor

@MaxSem MaxSem commented Nov 9, 2023

Packed arrays can make a lot of difference, however lots of developers simply don't
know about them or when an array can be packed. Thus I propose to make this
information available to userspace, but as a debug tool, not something like array_is_list().

@staabm
Copy link
Contributor

staabm commented Nov 10, 2023

Is there documentation somewhere when arrays are packed/not packed and when/which/how much impact it has?


edit: after some research I found

is this still accurate?

@jorgsowa

This comment was marked as off-topic.

@MaxSem
Copy link
Contributor Author

MaxSem commented Nov 10, 2023

exposing the internal term

It's literally the purpose of this function. Quoting the manual:

Dumps a string representation of an internal zval (Zend value) structure to output. This is mostly useful for understanding or debugging implementation details of the Zend Engine or PHP extensions.

@MaxSem
Copy link
Contributor Author

MaxSem commented Nov 10, 2023

Changed "packed array" to "array packed" to be consistent with other attributes.

@@ -84,7 +84,7 @@ opcache.enable=0
require_once 'clean_table.inc';
?>
--EXPECTF--
array(7) refcount(2){
array(7) packed refcount(2){
Copy link
Contributor

Choose a reason for hiding this comment

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

Just as an idea which could be also used in regular var_dump()

Suggested change
array(7) packed refcount(2){
list(7) refcount(2){

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had thought about something like this, but decided that it would be confusing because the type remains IS_ARRAY at all times.

@jorgsowa
Copy link
Contributor

It's literally the purpose of this function. Quoting the manual

Sorry. Confused it with var_dump(). Then, it's completely fine.

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

Makes sense to me, can you add an entry to UPGRADING/NEWS ?

@MaxSem MaxSem force-pushed the debug_dump_packed branch from 600a8eb to f28b28e Compare January 11, 2024 20:01
@MaxSem
Copy link
Contributor Author

MaxSem commented Jan 11, 2024

Makes sense to me, can you add an entry to UPGRADING/NEWS ?

Done.

@Girgias Girgias merged commit a2b2830 into php:master Jan 12, 2024
@Girgias
Copy link
Member

Girgias commented Jan 12, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants