From 807fed793f9c6842baa4eb7e4c5b6d87781fe7d2 Mon Sep 17 00:00:00 2001
Date: Sun, 18 Jun 2017 15:49:43 +0200
Subject: [PATCH] Deprecated notices should be classified as
E_(USER_)DEPRECATED.
---
src/wp-includes/compat.php | 5 +++++
src/wp-includes/functions.php | 45 ++++++++++++++++++++++++-------------------
2 files changed, 30 insertions(+), 20 deletions(-)
diff --git a/src/wp-includes/compat.php b/src/wp-includes/compat.php
index 0ccee2d..24227d2 100644
|
a
|
b
|
if ( ! function_exists( 'spl_autoload_register' ) ): |
| 578 | 578 | return $GLOBALS['_wp_spl_autoloaders']; |
| 579 | 579 | } |
| 580 | 580 | endif; |
| | 581 | |
| | 582 | // E_USER_DEPRECATED was introduced in PHP 5.3 |
| | 583 | if ( ! defined( 'E_USER_DEPRECATED' ) ) { |
| | 584 | define( 'E_USER_DEPRECATED', E_USER_WARNING ); |
| | 585 | } |
diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
index 828f123..20f5a24 100644
|
a
|
b
|
function absint( $maybeint ) { |
| 3800 | 3800 | * This function is to be used in every function that is deprecated. |
| 3801 | 3801 | * |
| 3802 | 3802 | * @since 2.5.0 |
| | 3803 | * @since 4.9.0 The error type is now classified as E_USER_DEPRECATED (used to default to E_USER_NOTICE). |
| 3803 | 3804 | * @access private |
| 3804 | 3805 | * |
| 3805 | 3806 | * @param string $function The function that was called. |
| … |
… |
function _deprecated_function( $function, $version, $replacement = null ) { |
| 3830 | 3831 | if ( function_exists( '__' ) ) { |
| 3831 | 3832 | if ( ! is_null( $replacement ) ) { |
| 3832 | 3833 | /* translators: 1: PHP function name, 2: version number, 3: alternative function name */ |
| 3833 | | trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement ) ); |
| | 3834 | trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement ), E_USER_DEPRECATED ); |
| 3834 | 3835 | } else { |
| 3835 | 3836 | /* translators: 1: PHP function name, 2: version number */ |
| 3836 | | trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) ); |
| | 3837 | trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ), E_USER_DEPRECATED ); |
| 3837 | 3838 | } |
| 3838 | 3839 | } else { |
| 3839 | 3840 | if ( ! is_null( $replacement ) ) { |
| 3840 | | trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $function, $version, $replacement ) ); |
| | 3841 | trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $function, $version, $replacement ), E_USER_DEPRECATED ); |
| 3841 | 3842 | } else { |
| 3842 | | trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ) ); |
| | 3843 | trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $function, $version ), E_USER_DEPRECATED ); |
| 3843 | 3844 | } |
| 3844 | 3845 | } |
| 3845 | 3846 | } |
| … |
… |
function _deprecated_function( $function, $version, $replacement = null ) { |
| 3857 | 3858 | * |
| 3858 | 3859 | * @since 4.3.0 |
| 3859 | 3860 | * @since 4.5.0 Added the `$parent_class` parameter. |
| | 3861 | * @since 4.9.0 The error type is now classified as E_USER_DEPRECATED (used to default to E_USER_NOTICE). |
| 3860 | 3862 | * |
| 3861 | 3863 | * @access private |
| 3862 | 3864 | * |
| … |
… |
function _deprecated_constructor( $class, $version, $parent_class = '' ) { |
| 3893 | 3895 | if ( ! empty( $parent_class ) ) { |
| 3894 | 3896 | /* translators: 1: PHP class name, 2: PHP parent class name, 3: version number, 4: __construct() method */ |
| 3895 | 3897 | 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.' ), |
| 3896 | | $class, $parent_class, $version, '<pre>__construct()</pre>' ) ); |
| | 3898 | $class, $parent_class, $version, '<pre>__construct()</pre>' ), E_USER_DEPRECATED ); |
| 3897 | 3899 | } else { |
| 3898 | 3900 | /* translators: 1: PHP class name, 2: version number, 3: __construct() method */ |
| 3899 | 3901 | trigger_error( sprintf( __( 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), |
| 3900 | | $class, $version, '<pre>__construct()</pre>' ) ); |
| | 3902 | $class, $version, '<pre>__construct()</pre>' ), E_USER_DEPRECATED ); |
| 3901 | 3903 | } |
| 3902 | 3904 | } else { |
| 3903 | 3905 | if ( ! empty( $parent_class ) ) { |
| 3904 | 3906 | 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.', |
| 3905 | | $class, $parent_class, $version, '<pre>__construct()</pre>' ) ); |
| | 3907 | $class, $parent_class, $version, '<pre>__construct()</pre>' ), E_USER_DEPRECATED ); |
| 3906 | 3908 | } else { |
| 3907 | 3909 | trigger_error( sprintf( 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', |
| 3908 | | $class, $version, '<pre>__construct()</pre>' ) ); |
| | 3910 | $class, $version, '<pre>__construct()</pre>' ), E_USER_DEPRECATED ); |
| 3909 | 3911 | } |
| 3910 | 3912 | } |
| 3911 | 3913 | } |
| … |
… |
function _deprecated_constructor( $class, $version, $parent_class = '' ) { |
| 3924 | 3926 | * This function is to be used in every file that is deprecated. |
| 3925 | 3927 | * |
| 3926 | 3928 | * @since 2.5.0 |
| | 3929 | * @since 4.9.0 The error type is now classified as E_USER_DEPRECATED (used to default to E_USER_NOTICE). |
| 3927 | 3930 | * @access private |
| 3928 | 3931 | * |
| 3929 | 3932 | * @param string $file The file that was included. |
| … |
… |
function _deprecated_file( $file, $version, $replacement = null, $message = '' ) |
| 3958 | 3961 | if ( function_exists( '__' ) ) { |
| 3959 | 3962 | if ( ! is_null( $replacement ) ) { |
| 3960 | 3963 | /* translators: 1: PHP file name, 2: version number, 3: alternative file name */ |
| 3961 | | trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file, $version, $replacement ) . $message ); |
| | 3964 | trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file, $version, $replacement ) . $message, E_USER_DEPRECATED ); |
| 3962 | 3965 | } else { |
| 3963 | 3966 | /* translators: 1: PHP file name, 2: version number */ |
| 3964 | | trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version ) . $message ); |
| | 3967 | trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version ) . $message, E_USER_DEPRECATED ); |
| 3965 | 3968 | } |
| 3966 | 3969 | } else { |
| 3967 | 3970 | if ( ! is_null( $replacement ) ) { |
| 3968 | | trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $file, $version, $replacement ) . $message ); |
| | 3971 | trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $file, $version, $replacement ) . $message, E_USER_DEPRECATED ); |
| 3969 | 3972 | } else { |
| 3970 | | trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $file, $version ) . $message ); |
| | 3973 | trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $file, $version ) . $message, E_USER_DEPRECATED ); |
| 3971 | 3974 | } |
| 3972 | 3975 | } |
| 3973 | 3976 | } |
| … |
… |
function _deprecated_file( $file, $version, $replacement = null, $message = '' ) |
| 3992 | 3995 | * The current behavior is to trigger a user error if WP_DEBUG is true. |
| 3993 | 3996 | * |
| 3994 | 3997 | * @since 3.0.0 |
| | 3998 | * @since 4.9.0 The error type is now classified as E_USER_DEPRECATED (used to default to E_USER_NOTICE). |
| 3995 | 3999 | * @access private |
| 3996 | 4000 | * |
| 3997 | 4001 | * @param string $function The function that was called. |
| … |
… |
function _deprecated_argument( $function, $version, $message = null ) { |
| 4022 | 4026 | if ( function_exists( '__' ) ) { |
| 4023 | 4027 | if ( ! is_null( $message ) ) { |
| 4024 | 4028 | /* translators: 1: PHP function name, 2: version number, 3: optional message regarding the change */ |
| 4025 | | trigger_error( sprintf( __('%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s'), $function, $version, $message ) ); |
| | 4029 | 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 ); |
| 4026 | 4030 | } else { |
| 4027 | 4031 | /* translators: 1: PHP function name, 2: version number */ |
| 4028 | | 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 ) ); |
| | 4032 | 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 ); |
| 4029 | 4033 | } |
| 4030 | 4034 | } else { |
| 4031 | 4035 | if ( ! is_null( $message ) ) { |
| 4032 | | trigger_error( sprintf( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s', $function, $version, $message ) ); |
| | 4036 | 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 ); |
| 4033 | 4037 | } else { |
| 4034 | | 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 ) ); |
| | 4038 | 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 ); |
| 4035 | 4039 | } |
| 4036 | 4040 | } |
| 4037 | 4041 | } |
| … |
… |
function _deprecated_argument( $function, $version, $message = null ) { |
| 4049 | 4053 | * functions, and so generally does not need to be called directly. |
| 4050 | 4054 | * |
| 4051 | 4055 | * @since 4.6.0 |
| | 4056 | * @since 4.9.0 The error type is now classified as E_USER_DEPRECATED (used to default to E_USER_NOTICE). |
| 4052 | 4057 | * @access private |
| 4053 | 4058 | * |
| 4054 | 4059 | * @param string $hook The hook that was used. |
| … |
… |
function _deprecated_hook( $hook, $version, $replacement = null, $message = null |
| 4081 | 4086 | $message = empty( $message ) ? '' : ' ' . $message; |
| 4082 | 4087 | if ( ! is_null( $replacement ) ) { |
| 4083 | 4088 | /* translators: 1: WordPress hook name, 2: version number, 3: alternative hook name */ |
| 4084 | | trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), $hook, $version, $replacement ) . $message ); |
| | 4089 | trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), $hook, $version, $replacement ) . $message, E_USER_DEPRECATED ); |
| 4085 | 4090 | } else { |
| 4086 | 4091 | /* translators: 1: WordPress hook name, 2: version number */ |
| 4087 | | trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $hook, $version ) . $message ); |
| | 4092 | trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $hook, $version ) . $message, E_USER_DEPRECATED ); |
| 4088 | 4093 | } |
| 4089 | 4094 | } |
| 4090 | 4095 | } |
| … |
… |
function _doing_it_wrong( $function, $message, $version ) { |
| 4138 | 4143 | __( 'https://codex.wordpress.org/Debugging_in_WordPress' ) |
| 4139 | 4144 | ); |
| 4140 | 4145 | /* translators: Developer debugging message. 1: PHP function name, 2: Explanatory message, 3: Version information message */ |
| 4141 | | trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ) ); |
| | 4146 | trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ), E_USER_NOTICE ); |
| 4142 | 4147 | } else { |
| 4143 | 4148 | if ( is_null( $version ) ) { |
| 4144 | 4149 | $version = ''; |
| … |
… |
function _doing_it_wrong( $function, $message, $version ) { |
| 4148 | 4153 | $message .= sprintf( ' Please see <a href="%s">Debugging in WordPress</a> for more information.', |
| 4149 | 4154 | 'https://codex.wordpress.org/Debugging_in_WordPress' |
| 4150 | 4155 | ); |
| 4151 | | trigger_error( sprintf( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s', $function, $message, $version ) ); |
| | 4156 | trigger_error( sprintf( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s', $function, $message, $version ), E_USER_NOTICE ); |
| 4152 | 4157 | } |
| 4153 | 4158 | } |
| 4154 | 4159 | } |