Debug Data: Encode section ordering in debug info.#7289
Debug Data: Encode section ordering in debug info.#7289dmsnell wants to merge 5 commits intoWordPress:trunkfrom
Conversation
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.
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
| $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(); | ||
| } |
There was a problem hiding this comment.
| $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?
There was a problem hiding this comment.
alternatively the callback for the upcoming refactors could be null and the check could be if ( $callback !== null )
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
| * @ticket 61648. | |
| * @ticket 61648 |
No need for the full stop, see https://core.trac.wordpress.org/ticket/61238.
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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
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
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
Adaptations for WordPress#7289 Added a condition to unset $info['wp-paths-sizes'] for multisites to match the original state.
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
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.