Make WordPress Core

Ticket #36561: 36561-classify-trigger_error-calls.patch

File 36561-classify-trigger_error-calls.patch, 8.5 KB (added by jrf, 10 years ago)
  • src/wp-includes/compat.php

    From 16ce92e908b0178a10abd92460ffbc80c0b701c8 Mon Sep 17 00:00:00 2001
    Date: Sun, 17 Apr 2016 13:06:19 +0200
    Subject: [PATCH] Deprecated notices should be classified as
     E_(USER_)DEPRECATED.
    
    ---
     src/wp-includes/compat.php    |  5 +++++
     src/wp-includes/functions.php | 36 ++++++++++++++++++------------------
     2 files changed, 23 insertions(+), 18 deletions(-)
    
    diff --git a/src/wp-includes/compat.php b/src/wp-includes/compat.php
    index cfb0f70..d2fd834 100644
    a b if ( ! interface_exists( 'JsonSerializable' ) ) { 
    434434if ( ! function_exists( 'random_int' ) ) {
    435435        require ABSPATH . WPINC . '/random_compat/random.php';
    436436}
     437
     438// E_USER_DEPRECATED was introduced in PHP 5.3
     439if ( ! defined( 'E_USER_DEPRECATED' ) ) {
     440        define( 'E_USER_DEPRECATED', E_USER_WARNING );
     441}
  • src/wp-includes/functions.php

    diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
    index ca1c4c9..1e69cec 100644
    a b function _deprecated_function( $function, $version, $replacement = null ) { 
    36723672        if ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) {
    36733673                if ( function_exists( '__' ) ) {
    36743674                        if ( ! is_null( $replacement ) )
    3675                                 trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement ) );
     3675                                trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement ), E_USER_DEPRECATED );
    36763676                        else
    3677                                 trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) );
     3677                                trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ), E_USER_DEPRECATED );
    36783678                } else {
    36793679                        if ( ! is_null( $replacement ) )
    3680                                 trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $function, $version, $replacement ) );
     3680                                trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $function, $version, $replacement ), E_USER_DEPRECATED );
    36813681                        else
    3682                                 trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ) );
     3682                                trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ), E_USER_DEPRECATED );
    36833683                }
    36843684        }
    36853685}
    function _deprecated_constructor( $class, $version, $parent_class = '' ) { 
    37323732                        if ( ! empty( $parent_class ) ) {
    37333733                                /* translators: 1: PHP class name, 2: PHP parent class name, 3: version number, 4: __construct() method */
    37343734                                trigger_error( sprintf( __( 'The called constructor method for %1$s in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.' ),
    3735                                         $class, $parent_class, $version, '<pre>__construct()</pre>' ) );
     3735                                        $class, $parent_class, $version, '<pre>__construct()</pre>' ), E_USER_DEPRECATED );
    37363736                        } else {
    37373737                                /* translators: 1: PHP class name, 2: version number, 3: __construct() method */
    37383738                                trigger_error( sprintf( __( 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ),
    3739                                         $class, $version, '<pre>__construct()</pre>' ) );
     3739                                        $class, $version, '<pre>__construct()</pre>' ), E_USER_DEPRECATED );
    37403740                        }
    37413741                } else {
    37423742                        if ( ! empty( $parent_class ) ) {
    37433743                                trigger_error( sprintf( 'The called constructor method for %1$s in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.',
    3744                                         $class, $parent_class, $version, '<pre>__construct()</pre>' ) );
     3744                                        $class, $parent_class, $version, '<pre>__construct()</pre>' ), E_USER_DEPRECATED );
    37453745                        } else {
    37463746                                trigger_error( sprintf( 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.',
    3747                                         $class, $version, '<pre>__construct()</pre>' ) );
     3747                                        $class, $version, '<pre>__construct()</pre>' ), E_USER_DEPRECATED );
    37483748                        }
    37493749                }
    37503750        }
    function _deprecated_file( $file, $version, $replacement = null, $message = '' ) 
    37963796                $message = empty( $message ) ? '' : ' ' . $message;
    37973797                if ( function_exists( '__' ) ) {
    37983798                        if ( ! is_null( $replacement ) )
    3799                                 trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file, $version, $replacement ) . $message );
     3799                                trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file, $version, $replacement ) . $message, E_USER_DEPRECATED );
    38003800                        else
    3801                                 trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version ) . $message );
     3801                                trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version ) . $message, E_USER_DEPRECATED );
    38023802                } else {
    38033803                        if ( ! is_null( $replacement ) )
    3804                                 trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $file, $version, $replacement ) . $message );
     3804                                trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $file, $version, $replacement ) . $message, E_USER_DEPRECATED );
    38053805                        else
    3806                                 trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $file, $version ) . $message );
     3806                                trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $file, $version ) . $message, E_USER_DEPRECATED );
    38073807                }
    38083808        }
    38093809}
    function _deprecated_argument( $function, $version, $message = null ) { 
    38563856        if ( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) {
    38573857                if ( function_exists( '__' ) ) {
    38583858                        if ( ! is_null( $message ) )
    3859                                 trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s'), $function, $version, $message ) );
     3859                                trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s'), $function, $version, $message ), E_USER_DEPRECATED );
    38603860                        else
    3861                                 trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) );
     3861                                trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ), E_USER_DEPRECATED );
    38623862                } else {
    38633863                        if ( ! is_null( $message ) )
    3864                                 trigger_error( sprintf( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s', $function, $version, $message ) );
     3864                                trigger_error( sprintf( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s', $function, $version, $message ), E_USER_DEPRECATED );
    38653865                        else
    3866                                 trigger_error( sprintf( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ) );
     3866                                trigger_error( sprintf( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ), E_USER_DEPRECATED );
    38673867                }
    38683868        }
    38693869}
    function _doing_it_wrong( $function, $message, $version ) { 
    39113911                        $message .= ' ' . sprintf( __( 'Please see <a href="%s">Debugging in WordPress</a> for more information.' ),
    39123912                                __( 'https://codex.wordpress.org/Debugging_in_WordPress' )
    39133913                        );
    3914                         trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ) );
     3914                        trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ), E_USER_NOTICE );
    39153915                } else {
    39163916                        $version = is_null( $version ) ? '' : sprintf( '(This message was added in version %s.)', $version );
    39173917                        $message .= sprintf( ' Please see <a href="%s">Debugging in WordPress</a> for more information.',
    39183918                                'https://codex.wordpress.org/Debugging_in_WordPress'
    39193919                        );
    3920                         trigger_error( sprintf( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s', $function, $message, $version ) );
     3920                        trigger_error( sprintf( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s', $function, $message, $version ), E_USER_NOTICE );
    39213921                }
    39223922        }
    39233923}