Make WordPress Core

Changeset 58996


Ignore:
Timestamp:
09/06/2024 07:48:54 PM (5 weeks ago)
Author:
dmsnell
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-debug-data.php

    r58964 r58996  
    6262        }
    6363
    64         // Set up the array that holds all debug information.
    65         $info = array();
     64        /*
     65         * Set up the array that holds all debug information.
     66         *
     67         * When iterating through the debug data, the ordering of the sections
     68         * occurs in insertion-order of the assignments into this array. Setting
     69         * up empty values here preserves that specific ordering so it doesn't
     70         * depend on when inside this method each section is otherwise assigned.
     71         *
     72         * When all sections have been modularized, this will be the final single
     73         * assignment of the sections before filtering and none will be empty.
     74         *
     75         * @ticket 61648
     76         */
     77        $info = array(
     78            'wp-core'             => array(),
     79            'wp-paths-sizes'      => array(),
     80            'wp-dropins'          => array(),
     81            'wp-active-theme'     => array(),
     82            'wp-parent-theme'     => array(),
     83            'wp-themes-inactive'  => array(),
     84            'wp-mu-plugins'       => array(),
     85            'wp-plugins-active'   => array(),
     86            'wp-plugins-inactive' => array(),
     87            'wp-media'            => array(),
     88            'wp-server'           => array(),
     89            'wp-database'         => self::get_wp_database(),
     90            'wp-constants'        => self::get_wp_constants(),
     91            'wp-filesystem'       => self::get_wp_filesystem(),
     92        );
    6693
    6794        $info['wp-core'] = array(
     
    11541181            );
    11551182        }
    1156 
    1157         $info['wp-constants']  = self::get_wp_constants();
    1158         $info['wp-database']   = self::get_wp_database();
    1159         $info['wp-filesystem'] = self::get_wp_filesystem();
    11601183
    11611184        /**
Note: See TracChangeset for help on using the changeset viewer.