Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#10427 closed defect (bug) (fixed)

The 'recent comments' widget needs to flush its cache on transition_comment_status events

Reported by: josephscott Owned by: azaozz
Milestone: 2.9 Priority: normal
Severity: normal Version: 2.8.1
Component: Widgets Keywords: has-patch
Focuses: Cc:


The WP iPhone app uses the wp.editComment XML-RPC method to change the status of a comment. This uses the core wp_update_comment() function to do the actual updates to a comment. Which in turn calls the wp_transition_comment_status() function to trigger hooks that are watching for comment status changes.

Currently the recent comment widget only clears the cache on comment_post and wp_set_comment_status events. So comments that get their status changed through wp_update_comment() don't cause the recent comments widget cache to get updated. To solve this here is my one line patch that adds transition_comment_status to the list of actions that cause the recent comments widget cache to get updated.

As a side note, I think that we could remove the wp_set_comment_status action from the flush cache list for this widget. That event should get caught by the transition_comment_status action as well. I didn't not verify that this was case though, so I did not remove that line in my patch.

Attachments (1)

wp-includes--default-widgets.php.diff (597 bytes) - added by josephscott 5 years ago.

Download all attachments as: .zip

Change History (3)

comment:1 azaozz5 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [11718]) Flush the cache in Recent Comments widget on transition_comment_status, props josephscott, fixes #10427

comment:2 azaozz5 years ago

transition_comment_status is called together with wp_set_comment_status and runs only when the status changes. Seems the right hook to clear cache.

Note: See TracTickets for help on using tickets.