Make WordPress Core

Changeset 34581


Ignore:
Timestamp:
09/26/2015 06:00:09 AM (8 years ago)
Author:
wonderboymusic
Message:

Recent Comments Widget: a la [34464], this widget has the same mixed content issues. Remove the fragment caching. The comment queries are now split to scale. This was the only remaining widget with an HTML fragment cache.

Fixes #25556.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/widgets/class-wp-widget-recent-comments.php

    r34514 r34581  
    2424        if ( is_active_widget(false, false, $this->id_base) )
    2525            add_action( 'wp_head', array($this, 'recent_comments_style') );
    26 
    27         add_action( 'comment_post', array($this, 'flush_widget_cache') );
    28         add_action( 'edit_comment', array($this, 'flush_widget_cache') );
    29         add_action( 'transition_comment_status', array($this, 'flush_widget_cache') );
    3026    }
    3127
     
    5147
    5248    /**
    53      * @access public
    54      */
    55     public function flush_widget_cache() {
    56         wp_cache_delete('widget_recent_comments', 'widget');
    57     }
    58 
    59     /**
    6049     * @param array $args
    6150     * @param array $instance
    6251     */
    6352    public function widget( $args, $instance ) {
    64         $cache = array();
    65         if ( ! $this->is_preview() ) {
    66             $cache = wp_cache_get('widget_recent_comments', 'widget');
    67         }
    68         if ( ! is_array( $cache ) ) {
    69             $cache = array();
    70         }
    71 
    7253        if ( ! isset( $args['widget_id'] ) )
    7354            $args['widget_id'] = $this->id;
    74 
    75         if ( isset( $cache[ $args['widget_id'] ] ) ) {
    76             echo $cache[ $args['widget_id'] ];
    77             return;
    78         }
    7955
    8056        $output = '';
     
    129105
    130106        echo $output;
    131 
    132         if ( ! $this->is_preview() ) {
    133             $cache[ $args['widget_id'] ] = $output;
    134             wp_cache_set( 'widget_recent_comments', $cache, 'widget' );
    135         }
    136107    }
    137108
     
    145116        $instance['title'] = sanitize_text_field( $new_instance['title'] );
    146117        $instance['number'] = absint( $new_instance['number'] );
    147         $this->flush_widget_cache();
    148 
    149         $alloptions = wp_cache_get( 'alloptions', 'options' );
    150         if ( isset($alloptions['widget_recent_comments']) )
    151             delete_option('widget_recent_comments');
    152 
    153118        return $instance;
    154119    }
Note: See TracChangeset for help on using the changeset viewer.