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' ) ) { |
| 434 | 434 | if ( ! function_exists( 'random_int' ) ) { |
| 435 | 435 | require ABSPATH . WPINC . '/random_compat/random.php'; |
| 436 | 436 | } |
| | 437 | |
| | 438 | // E_USER_DEPRECATED was introduced in PHP 5.3 |
| | 439 | if ( ! defined( 'E_USER_DEPRECATED' ) ) { |
| | 440 | define( 'E_USER_DEPRECATED', E_USER_WARNING ); |
| | 441 | } |
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 ) { |
| 3672 | 3672 | if ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) { |
| 3673 | 3673 | if ( function_exists( '__' ) ) { |
| 3674 | 3674 | 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 ); |
| 3676 | 3676 | 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 ); |
| 3678 | 3678 | } else { |
| 3679 | 3679 | 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 ); |
| 3681 | 3681 | 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 ); |
| 3683 | 3683 | } |
| 3684 | 3684 | } |
| 3685 | 3685 | } |
| … |
… |
function _deprecated_constructor( $class, $version, $parent_class = '' ) { |
| 3732 | 3732 | if ( ! empty( $parent_class ) ) { |
| 3733 | 3733 | /* translators: 1: PHP class name, 2: PHP parent class name, 3: version number, 4: __construct() method */ |
| 3734 | 3734 | 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 ); |
| 3736 | 3736 | } else { |
| 3737 | 3737 | /* translators: 1: PHP class name, 2: version number, 3: __construct() method */ |
| 3738 | 3738 | 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 ); |
| 3740 | 3740 | } |
| 3741 | 3741 | } else { |
| 3742 | 3742 | if ( ! empty( $parent_class ) ) { |
| 3743 | 3743 | 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 ); |
| 3745 | 3745 | } else { |
| 3746 | 3746 | 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 ); |
| 3748 | 3748 | } |
| 3749 | 3749 | } |
| 3750 | 3750 | } |
| … |
… |
function _deprecated_file( $file, $version, $replacement = null, $message = '' ) |
| 3796 | 3796 | $message = empty( $message ) ? '' : ' ' . $message; |
| 3797 | 3797 | if ( function_exists( '__' ) ) { |
| 3798 | 3798 | 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 ); |
| 3800 | 3800 | 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 ); |
| 3802 | 3802 | } else { |
| 3803 | 3803 | 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 ); |
| 3805 | 3805 | 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 ); |
| 3807 | 3807 | } |
| 3808 | 3808 | } |
| 3809 | 3809 | } |
| … |
… |
function _deprecated_argument( $function, $version, $message = null ) { |
| 3856 | 3856 | if ( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) { |
| 3857 | 3857 | if ( function_exists( '__' ) ) { |
| 3858 | 3858 | 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 ); |
| 3860 | 3860 | 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 ); |
| 3862 | 3862 | } else { |
| 3863 | 3863 | 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 ); |
| 3865 | 3865 | 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 ); |
| 3867 | 3867 | } |
| 3868 | 3868 | } |
| 3869 | 3869 | } |
| … |
… |
function _doing_it_wrong( $function, $message, $version ) { |
| 3911 | 3911 | $message .= ' ' . sprintf( __( 'Please see <a href="%s">Debugging in WordPress</a> for more information.' ), |
| 3912 | 3912 | __( 'https://codex.wordpress.org/Debugging_in_WordPress' ) |
| 3913 | 3913 | ); |
| 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 ); |
| 3915 | 3915 | } else { |
| 3916 | 3916 | $version = is_null( $version ) ? '' : sprintf( '(This message was added in version %s.)', $version ); |
| 3917 | 3917 | $message .= sprintf( ' Please see <a href="%s">Debugging in WordPress</a> for more information.', |
| 3918 | 3918 | 'https://codex.wordpress.org/Debugging_in_WordPress' |
| 3919 | 3919 | ); |
| 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 ); |
| 3921 | 3921 | } |
| 3922 | 3922 | } |
| 3923 | 3923 | } |