Make WordPress Core

Ticket #46813: 46813.7.diff

File 46813.7.diff, 2.3 KB (added by tmdesigned, 6 years ago)

Cleaned indentation and removed extra line in comment

  • src/wp-includes/functions.php

     
    29442944 * @since 4.1.0 The `$title` and `$args` parameters were changed to optionally accept
    29452945 *              an integer to be used as the response code.
    29462946 * @since 5.1.0 The `$link_url`, `$link_text`, and `$exit` arguments were added.
     2947 *
     2948 * @global WP_Query $wp_query
    29472949 *
    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() ) {
    29742976
     2977        global $wp_query;
     2978
    29752979        if ( is_int( $args ) ) {
    29762980                $args = array( 'response' => $args );
    29772981        } elseif ( is_int( $title ) ) {
     
    30163020                 */
    30173021                $function = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' );
    30183022        } 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() ) {
     3023                || isset( $wp_query ) && function_exists( 'is_feed' ) && is_feed()
     3024                || isset( $wp_query ) && function_exists( 'is_comment_feed' ) && is_comment_feed()
     3025                || isset( $wp_query ) && function_exists( 'is_trackback' ) && is_trackback() ) {
    30223026                /**
    30233027                 * Filters the callback for killing WordPress execution for XML requests.
    30243028                 *
  • tests/phpunit/tests/includes/helpers.php

     
    378378        }
    379379
    380380        /**
     381         * @ticket 46813
     382         */
     383        public function test_wp_die_does_not_cause_doing_it_wrong_notice_without_wp_query_set() {
     384                //Unset query to trigger _doing_it_wrong later
     385                unset( $GLOBALS['wp_query'] );
     386
     387                try {
     388                        //run wp_die to test if _doing_it_wrong runs
     389                        wp_die();
     390                } catch ( WPDieException $e ) {
     391                        //do nothing with exception regardless
     392                }
     393
     394                $this->assertEmpty( $this->caught_doing_it_wrong );
     395        }
     396       
     397        /**
    381398         * This test is just a setup for the one that follows.
    382399         *
    383400         * @ticket 38196