Skip to content

Debug Data: Encode section ordering in debug info.#7289

Closed
dmsnell wants to merge 5 commits intoWordPress:trunkfrom
dmsnell:debug-data/constrain-section-ordering
Closed

Debug Data: Encode section ordering in debug info.#7289
dmsnell wants to merge 5 commits intoWordPress:trunkfrom
dmsnell:debug-data/constrain-section-ordering

Conversation

@dmsnell
Copy link
Copy Markdown
Member

@dmsnell dmsnell commented Sep 4, 2024

Trac ticket: Core-61648

During a refactor to modularize the debug data class, it came up that the ordering of the sections inside of the returned debug info is relevant to existing UIs, as they iterate the array, which happens in insertion order.

This patch presets each section at the start to ensure that the ordering remains consistent even as code within the method is rearranged.

During a refactor to modularize the debug data class, it came up that
the ordering of the sections inside of the returned debug info is
relevant to existing UIs, as they iterate the array, which happens in
insertion order.

This patch presets each section at the start to ensure that the ordering
remains consistent even as code within themethod is rearranged.

See Core-61648.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 4, 2024

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Comment on lines +67 to +92
$section_ordering = array(
'wp-core',
'wp-paths-sizes',
'wp-dropins',
'wp-active-theme',
'wp-parent-theme',
'wp-themes-inactive',
'wp-mu-plugins',
'wp-plugins-active',
'wp-plugins-inactive',
'wp-media',
'wp-server',
'wp-database',
'wp-constants',
'wp-filesystem',
);

/*
* When iterating through the debug data, the ordering of the sections
* occurs in insertion-order of the assignments into this array. This
* ensures that ordering so that it doesn't depend on when inside this
* method the sections are filled out.
*/
foreach ( $section_ordering as $section_name ) {
$info[ $section_name ] = array();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
$section_ordering = array(
'wp-core',
'wp-paths-sizes',
'wp-dropins',
'wp-active-theme',
'wp-parent-theme',
'wp-themes-inactive',
'wp-mu-plugins',
'wp-plugins-active',
'wp-plugins-inactive',
'wp-media',
'wp-server',
'wp-database',
'wp-constants',
'wp-filesystem',
);
/*
* When iterating through the debug data, the ordering of the sections
* occurs in insertion-order of the assignments into this array. This
* ensures that ordering so that it doesn't depend on when inside this
* method the sections are filled out.
*/
foreach ( $section_ordering as $section_name ) {
$info[ $section_name ] = array();
}
$section_ordering = array(
'wp-core' => 'get_wp_core',
'wp-paths-sizes' => 'get_wp_paths_sizes',
'wp-dropins' => 'get_wp_paths_sizes,
'wp-active-theme' => 'get_wp_active_theme,
'wp-parent-theme' => 'get_wp_parent_theme',
'wp-themes-inactive' => 'get_wp_themes_inactive,
'wp-mu-plugins' => 'get_wp_mu_plugins,
'wp-plugins-active' => 'get_wp_plugins_active,
'wp-plugins-inactive' => 'get_wp_plugins_inactive,
'wp-media' => 'get_wp_media,
'wp-server' => 'get_wp_server,
'wp-database' => 'get_wp_database,
'wp-constants' => 'get_wp_constants,
'wp-filesystem' => 'get_wp_filesystem,
);
/*
* When iterating through the debug data, the ordering of the sections
* occurs in insertion-order of the assignments into this array. This
* ensures that ordering so that it doesn't depend on when inside this
* method the sections are filled out.
*/
foreach ( $section_ordering as $section_name => $getter_callback ) {
if ( method_exists( __CLASS__, $getter_callback ) ) {
$info[ $section_name ] = self::$getter_callback()
} else {
$info[ $section_name ] = array();
}
}

How about this enhancement? This solves the same purpose, and eliminates the need of the manual function calls, as soon as they are available?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

alternatively the callback for the upcoming refactors could be null and the check could be if ( $callback !== null )

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

thanks for the feedback @apermo - I'm less of a fan of the dynamic checking, but replaced everything with a static initial assignment, which is both what I started doing when I created this PR and I think closer to what you suggested earlier on anyway.

how do you feel about it in this form after e1e2cfd?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I love that change. It's better than the changes in between. imho that's the best approach (so far) we came up with.

* When all sections have been modularized, this will be the final single
* assignment of the sections before filtering and none will be empty.
*
* @ticket 61648.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* @ticket 61648.
* @ticket 61648

No need for the full stop, see https://core.trac.wordpress.org/ticket/61238.

@dmsnell dmsnell marked this pull request as ready for review September 5, 2024 01:34
@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 5, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props dmsnell, apermo, sergeybiryukov.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Copy Markdown

@apermo apermo left a comment

Choose a reason for hiding this comment

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

I like it :)

pento pushed a commit that referenced this pull request Sep 6, 2024
During a refactor to modularize the debug data class, it came up that the ordering of the sections inside of the returned debug info is relevant to existing UIs, as they iterate the array, which happens in insertion order.

This patch presets each section at the start to ensure that the ordering remains consistent even as code within the method is rearranged. As the mini-project progresses, this assignment will be the final place all the sections are referenced.

Developed in #7289
Discussed in https://core.trac.wordpress.org/ticket/61648

Props apermo, dmsnell, sergeybiryukov.
See #61648.


git-svn-id: https://develop.svn.wordpress.org/trunk@58996 602fd350-edb4-49c9-b593-d223f7449a82
@dmsnell
Copy link
Copy Markdown
Member Author

dmsnell commented Sep 6, 2024

Merged in [58996]
af239ae

@dmsnell dmsnell closed this Sep 6, 2024
@dmsnell dmsnell deleted the debug-data/constrain-section-ordering branch September 6, 2024 19:50
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Sep 6, 2024
During a refactor to modularize the debug data class, it came up that the ordering of the sections inside of the returned debug info is relevant to existing UIs, as they iterate the array, which happens in insertion order.

This patch presets each section at the start to ensure that the ordering remains consistent even as code within the method is rearranged. As the mini-project progresses, this assignment will be the final place all the sections are referenced.

Developed in WordPress/wordpress-develop#7289
Discussed in https://core.trac.wordpress.org/ticket/61648

Props apermo, dmsnell, sergeybiryukov.
See #61648.

Built from https://develop.svn.wordpress.org/trunk@58996


git-svn-id: http://core.svn.wordpress.org/trunk@58392 1a063a9b-81f0-0310-95a4-ce76da25c4cd
github-actions bot pushed a commit to platformsh/wordpress-performance that referenced this pull request Sep 6, 2024
During a refactor to modularize the debug data class, it came up that the ordering of the sections inside of the returned debug info is relevant to existing UIs, as they iterate the array, which happens in insertion order.

This patch presets each section at the start to ensure that the ordering remains consistent even as code within the method is rearranged. As the mini-project progresses, this assignment will be the final place all the sections are referenced.

Developed in WordPress/wordpress-develop#7289
Discussed in https://core.trac.wordpress.org/ticket/61648

Props apermo, dmsnell, sergeybiryukov.
See #61648.

Built from https://develop.svn.wordpress.org/trunk@58996


git-svn-id: https://core.svn.wordpress.org/trunk@58392 1a063a9b-81f0-0310-95a4-ce76da25c4cd
apermo added a commit to apermo/wordpress-develop that referenced this pull request Sep 7, 2024
Adaptations for WordPress#7289
Added a condition to unset $info['wp-paths-sizes'] for multisites to match the original state.
aslamdoctor pushed a commit to aslamdoctor/wordpress-develop that referenced this pull request Dec 28, 2024
During a refactor to modularize the debug data class, it came up that the ordering of the sections inside of the returned debug info is relevant to existing UIs, as they iterate the array, which happens in insertion order.

This patch presets each section at the start to ensure that the ordering remains consistent even as code within the method is rearranged. As the mini-project progresses, this assignment will be the final place all the sections are referenced.

Developed in WordPress#7289
Discussed in https://core.trac.wordpress.org/ticket/61648

Props apermo, dmsnell, sergeybiryukov.
See #61648.


git-svn-id: https://develop.svn.wordpress.org/trunk@58996 602fd350-edb4-49c9-b593-d223f7449a82
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.

3 participants