WordPress.org

Make WordPress Core

Changeset 17638


Ignore:
Timestamp:
04/14/2011 06:05:30 PM (7 years ago)
Author:
ryan
Message:

Avoid array push/pops for empty filters and actions. fixes #17110

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/plugin.php

    r16955 r17638  
    136136
    137137    $args = array();
    138     $wp_current_filter[] = $tag;
    139138
    140139    // Do 'all' actions first
    141140    if ( isset($wp_filter['all']) ) {
     141        $wp_current_filter[] = $tag;
    142142        $args = func_get_args();
    143143        _wp_call_all_hook($args);
     
    145145
    146146    if ( !isset($wp_filter[$tag]) ) {
    147         array_pop($wp_current_filter);
     147        if ( isset($wp_filter['all']) )
     148            array_pop($wp_current_filter);
    148149        return $value;
    149150    }
     151
     152    if ( !isset($wp_filter['all']) )
     153        $wp_current_filter[] = $tag;
    150154
    151155    // Sort
     
    194198    global $wp_filter, $merged_filters, $wp_current_filter;
    195199
    196     $wp_current_filter[] = $tag;
    197 
    198200    // Do 'all' actions first
    199201    if ( isset($wp_filter['all']) ) {
     202        $wp_current_filter[] = $tag;
    200203        $all_args = func_get_args();
    201204        _wp_call_all_hook($all_args);
     
    203206
    204207    if ( !isset($wp_filter[$tag]) ) {
    205         array_pop($wp_current_filter);
     208        if ( isset($wp_filter['all']) )
     209            array_pop($wp_current_filter);
    206210        return $args[0];
    207211    }
     212
     213    if ( !isset($wp_filter['all']) )
     214        $wp_current_filter[] = $tag;
    208215
    209216    // Sort
     
    361368        ++$wp_actions[$tag];
    362369
    363     $wp_current_filter[] = $tag;
    364 
    365370    // Do 'all' actions first
    366371    if ( isset($wp_filter['all']) ) {
     372        $wp_current_filter[] = $tag;
    367373        $all_args = func_get_args();
    368374        _wp_call_all_hook($all_args);
     
    370376
    371377    if ( !isset($wp_filter[$tag]) ) {
    372         array_pop($wp_current_filter);
     378        if ( isset($wp_filter['all']) )
     379            array_pop($wp_current_filter);
    373380        return;
    374381    }
     382
     383    if ( !isset($wp_filter['all']) )
     384        $wp_current_filter[] = $tag;
    375385
    376386    $args = array();
     
    447457        ++$wp_actions[$tag];
    448458
    449     $wp_current_filter[] = $tag;
    450 
    451459    // Do 'all' actions first
    452460    if ( isset($wp_filter['all']) ) {
     461        $wp_current_filter[] = $tag;
    453462        $all_args = func_get_args();
    454463        _wp_call_all_hook($all_args);
     
    456465
    457466    if ( !isset($wp_filter[$tag]) ) {
    458         array_pop($wp_current_filter);
     467        if ( isset($wp_filter['all']) )
     468            array_pop($wp_current_filter);
    459469        return;
    460470    }
     471
     472    if ( !isset($wp_filter['all']) )
     473        $wp_current_filter[] = $tag;
    461474
    462475    // Sort
Note: See TracChangeset for help on using the changeset viewer.