From af239aee1bee6686c6eec5ee7b87e65ca9c00898 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Fri, 6 Sep 2024 19:48:54 +0000 Subject: [PATCH] Debug Data: Encode section ordering in debug info. 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 https://github.com/WordPress/wordpress-develop/pull/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 --- src/wp-admin/includes/class-wp-debug-data.php | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php index 4b1982454c528..766253b1ea086 100644 --- a/src/wp-admin/includes/class-wp-debug-data.php +++ b/src/wp-admin/includes/class-wp-debug-data.php @@ -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' ), @@ -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. *