Opened 21 months ago
Closed 21 months ago
#8777 closed defect (bug) (fixed)
`bp_comments_pre_query()` short-circuits manual comment queries
Reported by: | boonebgorges | Owned by: | 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?
Trac ticket: https://buddypress.trac.wordpress.org/ticket/8777