Comment query block isn't lazy loading meta data. #40241
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
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:
Options:
gutenberg/lib/compat/wordpress-6.0/blocks.php
Line 300 in 6f7c5b5
WP_Comment_Query
is cached, make the query inbuild_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 usedget_comments()
and propose a fix to Core thatget_comments()
triggers lazy loading of meta data by default. Add a coding standards sniff to Gutenberg that you call that rather thanWP_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
The text was updated successfully, but these errors were encountered: