Make WordPress Core

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

File 36561-2-classify-trigger_error-calls.patch, 9.9 KB (added by jrf, 10 years ago)

Added @since changelog tags

  • src/wp-includes/compat.php

    From d0f9fb47cedaa0f59e18c36efbb142e796db69af Mon Sep 17 00:00:00 2001
    Date: Wed, 20 Apr 2016 20:28:44 +0200
    Subject: [PATCH] Deprecated notices should be classified as
     E_(USER_)DEPRECATED.
    
    ---
     src/wp-includes/compat.php    |  5 +++++
     src/wp-includes/functions.php | 40 ++++++++++++++++++++++------------------
     2 files changed, 27 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..f4ce840 100644
    a b function absint( $maybeint ) { 
    36433643 * This function is to be used in every function that is deprecated.
    36443644 *
    36453645 * @since 2.5.0
     3646 * @since 4.6.0 The error type is now classified as E_USER_DEPRECATED (used to default to E_USER_NOTICE).
    36463647 * @access private
    36473648 *
    36483649 * @param string $function    The function that was called.
    function _deprecated_function( $function, $version, $replacement = null ) { 
    36723673        if ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) {
    36733674                if ( function_exists( '__' ) ) {
    36743675                        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 ) );
     3676                                trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement ), E_USER_DEPRECATED );
    36763677                        else
    3677                                 trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) );
     3678                                trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ), E_USER_DEPRECATED );
    36783679                } else {
    36793680                        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 ) );
     3681                                trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $function, $version, $replacement ), E_USER_DEPRECATED );
    36813682                        else
    3682                                 trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ) );
     3683                                trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ), E_USER_DEPRECATED );
    36833684                }
    36843685        }
    36853686}
    function _deprecated_function( $function, $version, $replacement = null ) { 
    36963697 *
    36973698 * @since 4.3.0
    36983699 * @since 4.5.0 Added the `$parent_class` parameter.
     3700 * @since 4.6.0 The error type is now classified as E_USER_DEPRECATED (used to default to E_USER_NOTICE).
    36993701 *
    37003702 * @access private
    37013703 *
    function _deprecated_constructor( $class, $version, $parent_class = '' ) { 
    37323734                        if ( ! empty( $parent_class ) ) {
    37333735                                /* translators: 1: PHP class name, 2: PHP parent class name, 3: version number, 4: __construct() method */
    37343736                                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>' ) );
     3737                                        $class, $parent_class, $version, '<pre>__construct()</pre>' ), E_USER_DEPRECATED );
    37363738                        } else {
    37373739                                /* translators: 1: PHP class name, 2: version number, 3: __construct() method */
    37383740                                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>' ) );
     3741                                        $class, $version, '<pre>__construct()</pre>' ), E_USER_DEPRECATED );
    37403742                        }
    37413743                } else {
    37423744                        if ( ! empty( $parent_class ) ) {
    37433745                                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>' ) );
     3746                                        $class, $parent_class, $version, '<pre>__construct()</pre>' ), E_USER_DEPRECATED );
    37453747                        } else {
    37463748                                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>' ) );
     3749                                        $class, $version, '<pre>__construct()</pre>' ), E_USER_DEPRECATED );
    37483750                        }
    37493751                }
    37503752        }
    function _deprecated_constructor( $class, $version, $parent_class = '' ) { 
    37633765 * This function is to be used in every file that is deprecated.
    37643766 *
    37653767 * @since 2.5.0
     3768 * @since 4.6.0 The error type is now classified as E_USER_DEPRECATED (used to default to E_USER_NOTICE).
    37663769 * @access private
    37673770 *
    37683771 * @param string $file        The file that was included.
    function _deprecated_file( $file, $version, $replacement = null, $message = '' ) 
    37963799                $message = empty( $message ) ? '' : ' ' . $message;
    37973800                if ( function_exists( '__' ) ) {
    37983801                        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 );
     3802                                trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file, $version, $replacement ) . $message, E_USER_DEPRECATED );
    38003803                        else
    3801                                 trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version ) . $message );
     3804                                trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version ) . $message, E_USER_DEPRECATED );
    38023805                } else {
    38033806                        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 );
     3807                                trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $file, $version, $replacement ) . $message, E_USER_DEPRECATED );
    38053808                        else
    3806                                 trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $file, $version ) . $message );
     3809                                trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $file, $version ) . $message, E_USER_DEPRECATED );
    38073810                }
    38083811        }
    38093812}
    function _deprecated_file( $file, $version, $replacement = null, $message = '' ) 
    38273830 * The current behavior is to trigger a user error if WP_DEBUG is true.
    38283831 *
    38293832 * @since 3.0.0
     3833 * @since 4.6.0 The error type is now classified as E_USER_DEPRECATED (used to default to E_USER_NOTICE).
    38303834 * @access private
    38313835 *
    38323836 * @param string $function The function that was called.
    function _deprecated_argument( $function, $version, $message = null ) { 
    38563860        if ( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) {
    38573861                if ( function_exists( '__' ) ) {
    38583862                        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 ) );
     3863                                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 );
    38603864                        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 ) );
     3865                                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 );
    38623866                } else {
    38633867                        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 ) );
     3868                                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 );
    38653869                        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 ) );
     3870                                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 );
    38673871                }
    38683872        }
    38693873}
    function _doing_it_wrong( $function, $message, $version ) { 
    39113915                        $message .= ' ' . sprintf( __( 'Please see <a href="%s">Debugging in WordPress</a> for more information.' ),
    39123916                                __( 'https://codex.wordpress.org/Debugging_in_WordPress' )
    39133917                        );
    3914                         trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ) );
     3918                        trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ), E_USER_NOTICE );
    39153919                } else {
    39163920                        $version = is_null( $version ) ? '' : sprintf( '(This message was added in version %s.)', $version );
    39173921                        $message .= sprintf( ' Please see <a href="%s">Debugging in WordPress</a> for more information.',
    39183922                                'https://codex.wordpress.org/Debugging_in_WordPress'
    39193923                        );
    3920                         trigger_error( sprintf( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s', $function, $message, $version ) );
     3924                        trigger_error( sprintf( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s', $function, $message, $version ), E_USER_NOTICE );
    39213925                }
    39223926        }
    39233927}