Make WordPress Core

Ticket #18453: 18453.patch

File 18453.patch, 1.8 KB (added by azaozz, 13 years ago)
  • wp-includes/functions.php

     
    35173517        // Allow plugin to filter the output error trigger
    35183518        if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true ) ) {
    35193519                $version = is_null( $version ) ? '' : sprintf( __( '(This message was added in version %s.)' ), $version );
    3520                 trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ) );
     3520
     3521                if ( WP_DEBUG_DISPLAY ) {
     3522                        echo "<p><strong>$message</strong> $version</p>\n";
     3523                        wp_debug_backtrace();
     3524                } else {
     3525                        trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ) );
     3526                }
    35213527        }
    35223528}
    35233529
    35243530/**
     3531 * Output formatted backtrace
     3532 *
     3533 * @subpackage Debug
     3534 * @since 3.3
     3535 */   
     3536function wp_debug_backtrace( $echo = true ) {
     3537        $all = array_reverse( debug_backtrace() );
     3538        $trace = '';
     3539        $i = 0;
     3540        $b1 = '<i>';
     3541        $b2 = '</i>';
     3542
     3543        foreach ( $all as $key => $call ) {
     3544                if ( $call['function'] == __FUNCTION__ || $call['function'] == '_doing_it_wrong' ) // skip __FUNCTION__ and _doing_it_wrong() calls
     3545                        continue;
     3546
     3547                ++$i;
     3548                $func = isset( $call['class'] ) ? "{$call['class']}->{$call['function']}" : $call['function'];
     3549
     3550                if ( strpos( $call['file'], '/plugins/' ) !== false || strpos( $call['file'], '/themes/' ) !== false )
     3551                        $b1 = $b2 = '';
     3552
     3553                $trace .= "{$i} $b1{$call['file']}, " . __('line:') . " {$call['line']}, " . __('function:') . " {$func} $b2\n";
     3554        }
     3555
     3556        if ( !$echo )
     3557                return $trace;
     3558
     3559        echo '<p>' . __('Backtrace:') . "</p>\n<pre style='overflow:auto;'>$trace</pre>";
     3560}
     3561
     3562/**
    35253563 * Is the server running earlier than 1.5.0 version of lighttpd?
    35263564 *
    35273565 * @since 2.5.0