WordPress.org

Make WordPress Core

Changeset 48327


Ignore:
Timestamp:
07/05/2020 09:07:48 PM (15 months ago)
Author:
SergeyBiryukov
Message:

Plugins: Consistently use an empty string as the default value for $replacement and $message parameters in:

  • _deprecated_function()
  • _deprecated_constructor()
  • _deprecated_file()
  • _deprecated_argument()
  • _deprecated_hook()
  • apply_filters_deprecated()
  • do_action_deprecated()

This matches the documented type of string for these parameters and removes unnecessarily strict ! is_null() checks.

Follow-up to [46792].

Props jignesh.nakrani, renathoc, SergeyBiryukov.
Fixes #49698.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r48319 r48327  
    47014701 * @param string $function    The function that was called.
    47024702 * @param string $version     The version of WordPress that deprecated the function.
    4703  * @param string $replacement Optional. The function that should have been called. Default null.
    4704  */
    4705 function _deprecated_function( $function, $version, $replacement = null ) {
     4703 * @param string $replacement Optional. The function that should have been called. Default empty.
     4704 */
     4705function _deprecated_function( $function, $version, $replacement = '' ) {
    47064706
    47074707    /**
     
    47254725    if ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) {
    47264726        if ( function_exists( '__' ) ) {
    4727             if ( ! is_null( $replacement ) ) {
     4727            if ( $replacement ) {
    47284728                trigger_error(
    47294729                    sprintf(
     
    47484748            }
    47494749        } else {
    4750             if ( ! is_null( $replacement ) ) {
     4750            if ( $replacement ) {
    47514751                trigger_error(
    47524752                    sprintf(
     
    48174817    if ( WP_DEBUG && apply_filters( 'deprecated_constructor_trigger_error', true ) ) {
    48184818        if ( function_exists( '__' ) ) {
    4819             if ( ! empty( $parent_class ) ) {
     4819            if ( $parent_class ) {
    48204820                trigger_error(
    48214821                    sprintf(
     
    48424842            }
    48434843        } else {
    4844             if ( ! empty( $parent_class ) ) {
     4844            if ( $parent_class ) {
    48454845                trigger_error(
    48464846                    sprintf(
     
    48874887 * @param string $version     The version of WordPress that deprecated the file.
    48884888 * @param string $replacement Optional. The file that should have been included based on ABSPATH.
    4889  *                            Default null.
     4889 *                            Default empty.
    48904890 * @param string $message     Optional. A message regarding the change. Default empty.
    48914891 */
    4892 function _deprecated_file( $file, $version, $replacement = null, $message = '' ) {
     4892function _deprecated_file( $file, $version, $replacement = '', $message = '' ) {
    48934893
    48944894    /**
     
    49154915
    49164916        if ( function_exists( '__' ) ) {
    4917             if ( ! is_null( $replacement ) ) {
     4917            if ( $replacement ) {
    49184918                trigger_error(
    49194919                    sprintf(
     
    49384938            }
    49394939        } else {
    4940             if ( ! is_null( $replacement ) ) {
     4940            if ( $replacement ) {
    49414941                trigger_error(
    49424942                    sprintf(
     
    49854985 * @param string $function The function that was called.
    49864986 * @param string $version  The version of WordPress that deprecated the argument used.
    4987  * @param string $message  Optional. A message regarding the change. Default null.
    4988  */
    4989 function _deprecated_argument( $function, $version, $message = null ) {
     4987 * @param string $message  Optional. A message regarding the change. Default empty.
     4988 */
     4989function _deprecated_argument( $function, $version, $message = '' ) {
    49904990
    49914991    /**
     
    50095009    if ( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) {
    50105010        if ( function_exists( '__' ) ) {
    5011             if ( ! is_null( $message ) ) {
     5011            if ( $message ) {
    50125012                trigger_error(
    50135013                    sprintf(
     
    50325032            }
    50335033        } else {
    5034             if ( ! is_null( $message ) ) {
     5034            if ( $message ) {
    50355035                trigger_error(
    50365036                    sprintf(
     
    50735073 * @param string $hook        The hook that was used.
    50745074 * @param string $version     The version of WordPress that deprecated the hook.
    5075  * @param string $replacement Optional. The hook that should have been used. Default null.
    5076  * @param string $message     Optional. A message regarding the change. Default null.
    5077  */
    5078 function _deprecated_hook( $hook, $version, $replacement = null, $message = null ) {
     5075 * @param string $replacement Optional. The hook that should have been used. Default empty.
     5076 * @param string $message     Optional. A message regarding the change. Default empty.
     5077 */
     5078function _deprecated_hook( $hook, $version, $replacement = '', $message = '' ) {
    50795079    /**
    50805080     * Fires when a deprecated hook is called.
     
    51005100        $message = empty( $message ) ? '' : ' ' . $message;
    51015101
    5102         if ( ! is_null( $replacement ) ) {
     5102        if ( $replacement ) {
    51035103            trigger_error(
    51045104                sprintf(
     
    51675167    if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true, $function, $message, $version ) ) {
    51685168        if ( function_exists( '__' ) ) {
    5169             if ( is_null( $version ) ) {
    5170                 $version = '';
    5171             } else {
     5169            if ( $version ) {
    51725170                /* translators: %s: Version number. */
    51735171                $version = sprintf( __( '(This message was added in version %s.)' ), $version );
     
    51915189            );
    51925190        } else {
    5193             if ( is_null( $version ) ) {
    5194                 $version = '';
    5195             } else {
     5191            if ( $version ) {
    51965192                $version = sprintf( '(This message was added in version %s.)', $version );
    51975193            }
  • trunk/src/wp-includes/plugin.php

    r48109 r48327  
    621621 * @param array  $args        Array of additional function arguments to be passed to apply_filters().
    622622 * @param string $version     The version of WordPress that deprecated the hook.
    623  * @param string $replacement Optional. The hook that should have been used. Default null.
    624  * @param string $message     Optional. A message regarding the change. Default null.
    625  */
    626 function apply_filters_deprecated( $tag, $args, $version, $replacement = null, $message = null ) {
     623 * @param string $replacement Optional. The hook that should have been used. Default empty.
     624 * @param string $message     Optional. A message regarding the change. Default empty.
     625 */
     626function apply_filters_deprecated( $tag, $args, $version, $replacement = '', $message = '' ) {
    627627    if ( ! has_filter( $tag ) ) {
    628628        return $args[0];
     
    648648 * @param array  $args        Array of additional function arguments to be passed to do_action().
    649649 * @param string $version     The version of WordPress that deprecated the hook.
    650  * @param string $replacement Optional. The hook that should have been used. Default null.
    651  * @param string $message     Optional. A message regarding the change. Default null.
    652  */
    653 function do_action_deprecated( $tag, $args, $version, $replacement = null, $message = null ) {
     650 * @param string $replacement Optional. The hook that should have been used. Default empty.
     651 * @param string $message     Optional. A message regarding the change. Default empty.
     652 */
     653function do_action_deprecated( $tag, $args, $version, $replacement = '', $message = '' ) {
    654654    if ( ! has_action( $tag ) ) {
    655655        return;
Note: See TracChangeset for help on using the changeset viewer.