WordPress.org

Make WordPress Core

Ticket #47678: 47678-do_action-remove-PHP-4-code.patch

File 47678-do_action-remove-PHP-4-code.patch, 1.3 KB (added by jrf, 10 months ago)

Simplify do_action() / remove PHP 4 code

  • src/wp-includes/plugin.php

    From 9efcb29ab08f0832587316f34c5385fea1b839d7 Mon Sep 17 00:00:00 2001
    From: jrfnl <jrfnl@users.noreply.github.com>
    Date: Mon, 16 Sep 2019 05:00:01 +0200
    Subject: [PATCH] Simplify do_action() / remove PHP 4 code
    
    ---
     src/wp-includes/plugin.php | 16 +++++++---------
     1 file changed, 7 insertions(+), 9 deletions(-)
    
    diff --git a/src/wp-includes/plugin.php b/src/wp-includes/plugin.php
    index 3e021bbdd8..1f6cacd5b4 100644
    a b function do_action( $tag, $arg = '' ) { 
    448448                ++$wp_actions[ $tag ];
    449449        }
    450450
     451        $all_args = func_get_args();
     452
    451453        // Do 'all' actions first
    452454        if ( isset( $wp_filter['all'] ) ) {
    453455                $wp_current_filter[] = $tag;
    454                 $all_args            = func_get_args();
    455456                _wp_call_all_hook( $all_args );
    456457        }
    457458
    function do_action( $tag, $arg = '' ) { 
    466467                $wp_current_filter[] = $tag;
    467468        }
    468469
    469         $args = array();
    470         if ( is_array( $arg ) && 1 == count( $arg ) && isset( $arg[0] ) && is_object( $arg[0] ) ) { // array(&$this)
    471                 $args[] =& $arg[0];
    472         } else {
    473                 $args[] = $arg;
    474         }
    475         for ( $a = 2, $num = func_num_args(); $a < $num; $a++ ) {
    476                 $args[] = func_get_arg( $a );
     470        $args = $all_args;
     471        array_shift( $args );
     472
     473        if ( empty( $args ) ) {
     474                $args = array( '' );
    477475        }
    478476
    479477        $wp_filter[ $tag ]->do_action( $args );