WordPress.org

Make WordPress Core

Ticket #11892: 11892.patch

File 11892.patch, 1.4 KB (added by hakre, 4 years ago)

Die-Action-Hook with throwing an exception. Does the job.

  • wordpress/wp-includes/functions.php

     
    24852485 * @param string $title Error title. 
    24862486 * @param string|array $args Optional arguements to control behaviour. 
    24872487 */ 
    2488 function wp_die( $message, $title = '', $args = array() ) { 
     2488function wp_die( $message='', $title = '', $args = array() ) { 
    24892489        global $wp_locale; 
    24902490 
    24912491        $defaults = array( 'response' => 500 ); 
    24922492        $r = wp_parse_args($args, $defaults); 
    2493  
     2493         
     2494        do_action( 'wp_die_call', $message, $title, $r ); 
     2495         
    24942496        $have_gettext = function_exists('__'); 
    24952497 
    24962498        if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) { 
  • wp-test.php

     
    7373// make sure we're installed 
    7474assert(true == is_blog_installed()); 
    7575 
     76// register exception on wp_die to make it test-able  
     77add_action('wp_die_call', array('wp_die_exception', 'hook'), 1, 3); 
     78class wp_die_exception extends Exception { 
     79        static function hook($message, $title, $args) { 
     80                throw new wp_die_exception(sprintf('Died. %s', print_r($message, true)));                
     81        } 
     82} 
     83 
    7684// include plugins for testing, if any 
    7785if (is_dir(DIR_TESTPLUGINS)) { 
    7886        $plugins = glob(realpath(DIR_TESTPLUGINS).'/*.php');