Ticket #46813: 46813.5.diff
File 46813.5.diff, 2.2 KB (added by , 6 years ago) |
---|
-
src/wp-includes/functions.php
2972 2972 */ 2973 2973 function wp_die( $message = '', $title = '', $args = array() ) { 2974 2974 2975 global $wp_query; 2976 2975 2977 if ( is_int( $args ) ) { 2976 2978 $args = array( 'response' => $args ); 2977 2979 } elseif ( is_int( $title ) ) { … … 3016 3018 */ 3017 3019 $function = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' ); 3018 3020 } 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() ) {3021 || isset( $wp_query ) && function_exists( 'is_feed' ) && is_feed() 3022 || isset( $wp_query ) && function_exists( 'is_comment_feed' ) && is_comment_feed() 3023 || isset( $wp_query ) && function_exists( 'is_trackback' ) && is_trackback() ) { 3022 3024 /** 3023 3025 * Filters the callback for killing WordPress execution for XML requests. 3024 3026 * -
tests/phpunit/tests/includes/helpers.php
378 378 } 379 379 380 380 /** 381 * This tests that _doing_it_wrong is suppressed in the wp_die() handler 382 * 383 * @ticket 46813 384 */ 385 public function test_wp_die_has_doing_it_wrong_suppressed(){ 386 $expected = "Some Catastrophic Error"; 387 388 //Unset query to trigger _doing_it_wrong later 389 unset($GLOBALS['wp_query']); 390 391 try{ 392 //remove any other errors 393 error_clear_last(); 394 //trigger our own error, suppressing error handling 395 @trigger_error( $expected, E_USER_WARNING ); 396 //run wp_die to test if _doing_it_wrong runs 397 wp_die(); 398 }catch (WPDieException $e){ 399 //do nothing with exception regardless 400 } 401 402 //test that no additional errors were reported after ours 403 $last_error_reported = error_get_last(); 404 $this->assertSame( $last_error_reported['message'], $expected ); 405 } 406 407 /** 381 408 * This test is just a setup for the one that follows. 382 409 * 383 410 * @ticket 38196