WordPress.org

Make WordPress Core

Ticket #18453: add-backtrace-to-doing_it_wrong.diff

File add-backtrace-to-doing_it_wrong.diff, 1.1 KB (added by chrisbliss18, 3 years ago)

Add simple backtrace output of just the file and line number of the offending code

  • wp-includes/functions.php

     
    35243524 
    35253525        // Allow plugin to filter the output error trigger 
    35263526        if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true ) ) { 
     3527                $backtrace = debug_backtrace(); 
     3528                if ( isset( $backtrace[1]['line'] ) ) 
     3529                        $source = sprintf( __( '(Source: %1$s line %2$s)' ), $backtrace[1]['file'], $backtrace[1]['line'] ); 
     3530                else if ( isset( $backtrace[1]['class'] ) ) 
     3531                        $source = sprintf( __( '(Source: %1$s%2$s%3$s)' ), $backtrace[1]['class'], $backtrace[1]['type'], $backtrace[1]['function'] ); 
     3532                else 
     3533                        $source = __( '(Source: unknown)' ); 
     3534 
    35273535                $version = is_null( $version ) ? '' : sprintf( __( '(This message was added in version %s.)' ), $version ); 
    3528                 trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ) ); 
     3536                trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s %4$s' ), $function, $message, $source, $version ) ); 
    35293537        } 
    35303538} 
    35313539