Skip to content

Commit

Permalink
Debug Data: Encode section ordering in debug info.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dmsnell committed Sep 6, 2024
1 parent da1ea40 commit af239ae
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions src/wp-admin/includes/class-wp-debug-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,35 @@ public static function debug_data() {
}
}

// Set up the array that holds all debug information.
$info = array();
/*
* Set up the array that holds all debug information.
*
* When iterating through the debug data, the ordering of the sections
* occurs in insertion-order of the assignments into this array. Setting
* up empty values here preserves that specific ordering so it doesn't
* depend on when inside this method each section is otherwise assigned.
*
* 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
*/
$info = array(
'wp-core' => array(),
'wp-paths-sizes' => array(),
'wp-dropins' => array(),
'wp-active-theme' => array(),
'wp-parent-theme' => array(),
'wp-themes-inactive' => array(),
'wp-mu-plugins' => array(),
'wp-plugins-active' => array(),
'wp-plugins-inactive' => array(),
'wp-media' => array(),
'wp-server' => array(),
'wp-database' => self::get_wp_database(),
'wp-constants' => self::get_wp_constants(),
'wp-filesystem' => self::get_wp_filesystem(),
);

$info['wp-core'] = array(
'label' => __( 'WordPress' ),
Expand Down Expand Up @@ -1154,10 +1181,6 @@ public static function debug_data() {
);
}

$info['wp-constants'] = self::get_wp_constants();
$info['wp-database'] = self::get_wp_database();
$info['wp-filesystem'] = self::get_wp_filesystem();

/**
* Filters the debug information shown on the Tools -> Site Health -> Info screen.
*
Expand Down

0 comments on commit af239ae

Please sign in to comment.