Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment query block isn't lazy loading meta data. #40241

Closed
peterwilsoncc opened this issue Apr 12, 2022 · 2 comments
Closed

Comment query block isn't lazy loading meta data. #40241

peterwilsoncc opened this issue Apr 12, 2022 · 2 comments
Labels
[Block] Comment Template Affects the Comment Template Block [Feature] Blocks Overall functionality of blocks Needs Technical Feedback Needs testing from a developer perspective. [Type] Code Quality Issues or PRs that relate to code quality

Comments

@peterwilsoncc
Copy link
Contributor

Description

In build_comment_query_vars_from_block the comment meta cache isn't updated on the basis the the comment data is lazy loaded.

However, there are no calls within the code base to wp_queue_comments_for_comment_meta_lazyload( array $comment_objects ), so if any meta data is used in comments it will trigger a database call for each individual comment.

The function should be used each time a comments query is made using the build function:

$comments = new WP_Comment_Query( build_comment_query_vars_from_block() );
wp_queue_comments_for_comment_meta_lazyload( $comments );

Options:

  • Add all the calls
  • Removing this line and come back to this in GB 14/WP 6.1
    'update_comment_meta_cache' => false, // We lazy-load comment meta for performance.
  • If WP_Comment_Query is cached, make the query in build_comment_query_vars_from_block() so you can prime the meta data for lazy loading. It seems a little ugly though as building the arguments doens't nesesarily mean they will be used
  • use get_comments() and propose a fix to Core that get_comments() triggers lazy loading of meta data by default. Add a coding standards sniff to Gutenberg that you call that rather than WP_Comments_Query.

Step-by-step reproduction instructions

None, sorry, it's code.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@ramonjd ramonjd added [Type] Code Quality Issues or PRs that relate to code quality [Feature] Blocks Overall functionality of blocks [Block] Comment Template Affects the Comment Template Block labels Apr 12, 2022
@ndiego ndiego added the Needs Technical Feedback Needs testing from a developer perspective. label Apr 12, 2022
@gziolo
Copy link
Member

gziolo commented Apr 19, 2022

Closed with #40242. We still need to apply the same change in WordPress core. I'll take care of it shortly.

@gziolo gziolo closed this as completed Apr 19, 2022
pento pushed a commit to WordPress/wordpress-develop that referenced this issue Apr 19, 2022
Related GitHub issue: WordPress/gutenberg#40241.
Primes comment meta data cache within calls to WP_Comment_Query.

Props peterwilsoncc, cbravobernal.
See #55567.
Follow-up [53138].




git-svn-id: https://develop.svn.wordpress.org/trunk@53214 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this issue Apr 19, 2022
Related GitHub issue: WordPress/gutenberg#40241.
Primes comment meta data cache within calls to WP_Comment_Query.

Props peterwilsoncc, cbravobernal.
See #55567.
Follow-up [53138].



Built from https://develop.svn.wordpress.org/trunk@53214


git-svn-id: http://core.svn.wordpress.org/trunk@52803 1a063a9b-81f0-0310-95a4-ce76da25c4cd
github-actions bot pushed a commit to platformsh/wordpress-performance that referenced this issue Apr 19, 2022
Related GitHub issue: WordPress/gutenberg#40241.
Primes comment meta data cache within calls to WP_Comment_Query.

Props peterwilsoncc, cbravobernal.
See #55567.
Follow-up [53138].



Built from https://develop.svn.wordpress.org/trunk@53214


git-svn-id: https://core.svn.wordpress.org/trunk@52803 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@gziolo
Copy link
Member

gziolo commented Apr 19, 2022

I landed a temporary fix in the WordPress core with https://core.trac.wordpress.org/changeset/53214.

@peterwilsoncc, should we reopen the issue to work on a better approach for WP 6.1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Comment Template Affects the Comment Template Block [Feature] Blocks Overall functionality of blocks Needs Technical Feedback Needs testing from a developer perspective. [Type] Code Quality Issues or PRs that relate to code quality
Projects
No open projects
Archived in project
Development

No branches or pull requests

4 participants