Skip to:
Content

BuddyPress.org

#8777 closed defect (bug) (fixed)

`bp_comments_pre_query()` short-circuits manual comment queries

Reported by: boonebgorges's profile boonebgorges Owned by: imath's profile imath
Milestone: 10.7.0 Priority: normal
Severity: normal Version: 10.5.0
Component: Core Keywords: has-patch
Cc:

Description

bp_comments_pre_query() was introduced in [13332] #8744 to reduce unnecessary SQL queries.

The strategy of bp_comments_pre_query() is overly broad, and applies to any comment query on the page. For example, I've come across a situation on a client site where we were doing the following on a custom group page:

$comments = get_comments( ... );

bp_comments_pre_query() is forcing an empty array to be returned.

I guess the block editor is using the following technique to build its markup: https://github.com/WordPress/gutenberg/blob/2a3901db9c46f0e0963f991f2d8f9e57d370158e/packages/block-library/src/comments/index.php#L24

Perhaps we can use hooks like pre_render_block and render_block to target only those comment queries that originate with the core/comments block?

Change History (5)

This ticket was mentioned in PR #42 on buddypress/buddypress by @imath.


21 months ago
#1

  • Keywords has-patch added

#2 @imath
21 months ago

  • Milestone changed from Awaiting Review to 10.7.0

Hi @boonebgorges thanks for your report, I confirm your plan is better 👍.

#3 @boonebgorges
21 months ago

Thanks for the quick work, the PR is exactly what I was thinking.

#4 @imath
21 months ago

In 13378:

Restrict bp_comments_pre_query() usage to core/comments block

Props boonebgorges

See #8777 (trunk)

#5 @imath
21 months ago

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

In 13379:

Restrict bp_comments_pre_query() usage to core/comments block

Props boonebgorges

Fixes #8777 (branch 10.0)

Note: See TracTickets for help on using tickets.