WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#34138 closed defect (bug) (fixed)

Customizer: Missing comments in Recent Comments widget

Reported by: pavelevap Owned by: boonebgorges
Milestone: 4.4 Priority: normal
Severity: normal Version: 4.3
Component: Customize Keywords: has-patch
Focuses: Cc:

Description

When you add "Recent Comments" widget in Customizer, you will see only title "Recent comments", but no comments.

Attachments (2)

34138.patch (871 bytes) - added by rommelxcastro 6 years ago.
fallback to get_comment
341381.patch (879 bytes) - added by rommelxcastro 6 years ago.
comments duplicated issue fixed

Download all attachments as: .zip

Change History (11)

#1 @westonruter
6 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 4.4
  • Version changed from trunk to 4.3

Confirmed. The Recent Comments widget lists comments as expected in 4.3, but in trunk the call to get_comments() in WP_Widget_Recent_Comments::widget() returns an empty array when called in the context of the Customizer preview.

@rachelbaker Any thoughts here?

#2 @rommelxcastro
6 years ago

  • Keywords 2nd-opinion dev-feedback added

hello, after debugging this i have found the issue.

on preview mode on class-wp-widget:344, wp_suspend_cache_addition is defined to true, so when _prime_comment_caches is called on class-wp-comment-query:410 comments can't be added to cache.

@rommelxcastro
6 years ago

fallback to get_comment

#3 @rommelxcastro
6 years ago

  • Keywords needs-patch removed

#4 @stevehenty
6 years ago

Hi @rommelxcastro, I'm seeing comments duplicated in the widget with 34138.patch

@rommelxcastro
6 years ago

comments duplicated issue fixed

#5 @rommelxcastro
6 years ago

new patch added, thanks @tevehenty

#6 @wonderboymusic
6 years ago

  • Keywords has-patch added; 2nd-opinion dev-feedback removed
  • Owner set to boonebgorges
  • Status changed from new to assigned

I think this touches upon your oeuvre

#7 @stevehenty
6 years ago

@rommelxcastro with 341381.patch the comments appear correctly.

#8 @boonebgorges
6 years ago

Good catch. We can simplify this by just calling get_comment(), which will grab from the cache or the database as necessary.

#9 @boonebgorges
6 years ago

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

In 35512:

WP_Comment_Query: Fill comment objects from database when cache is unavailable.

This fixes a bug where widgets loaded in a preview or the Customizer are
rendered inside of a wp_suspend_cache_addition() block and thus could not
find comment objects in the cache.

Props rommelxcastro, stevehenty.
Fixes #34138.

Note: See TracTickets for help on using tickets.