[buddypress-trac] [BuddyPress Trac] #8777: `bp_comments_pre_query()` short-circuits manual comment queries

buddypress-trac noreply at wordpress.org
Mon Dec 5 20:04:10 UTC 2022


#8777: `bp_comments_pre_query()` short-circuits manual comment queries
--------------------------+-----------------------------
 Reporter:  boonebgorges  |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Core          |    Version:  10.5.0
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 `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:

 {{{#!php
 $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?

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/8777>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list