WordPress.org

Make WordPress Core

Changeset 45206


Ignore:
Timestamp:
04/15/2019 11:48:11 PM (16 months ago)
Author:
SergeyBiryukov
Message:

Bootstrap/Load: After [45016], make sure wp_die() does not cause _doing_it_wrong() notices if called before $wp_query global is set.

Props tmdesigned, TimothyBlynJacobs.
Fixes #46813.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r45185 r45206  
    29462946 * @since 5.1.0 The `$link_url`, `$link_text`, and `$exit` arguments were added.
    29472947 *
     2948 * @global WP_Query $wp_query Global WP_Query instance.
     2949 *
    29482950 * @param string|WP_Error  $message Optional. Error message. If this is a WP_Error object,
    29492951 *                                  and not an Ajax or XML-RPC request, the error's messages are used.
     
    29722974 */
    29732975function wp_die( $message = '', $title = '', $args = array() ) {
     2976    global $wp_query;
    29742977
    29752978    if ( is_int( $args ) ) {
     
    30173020        $function = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' );
    30183021    } elseif ( wp_is_xml_request()
    3019         || function_exists( 'is_feed' ) && is_feed()
    3020         || function_exists( 'is_comment_feed' ) && is_comment_feed()
    3021         || function_exists( 'is_trackback' ) && is_trackback() ) {
     3022        || isset( $wp_query ) &&
     3023            ( function_exists( 'is_feed' ) && is_feed()
     3024            || function_exists( 'is_comment_feed' ) && is_comment_feed()
     3025            || function_exists( 'is_trackback' ) && is_trackback() ) ) {
    30223026        /**
    30233027         * Filters the callback for killing WordPress execution for XML requests.
  • trunk/tests/phpunit/tests/includes/helpers.php

    r44690 r45206  
    276276
    277277    /**
     278     * @ticket 46813
     279     * @expectedException WPDieException
     280     */
     281    public function test_die_handler_should_not_cause_doing_it_wrong_notice_without_wp_query_set() {
     282        unset( $GLOBALS['wp_query'] );
     283
     284        wp_die();
     285
     286        $this->assertEmpty( $this->caught_doing_it_wrong );
     287    }
     288
     289    /**
    278290     * @ticket 45933
    279291     * @dataProvider data_die_process_input
Note: See TracChangeset for help on using the changeset viewer.