-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Lazy load post meta #4216
base: trunk
Are you sure you want to change the base?
Lazy load post meta #4216
Conversation
Renamed 'lazyload_meta_callback' to 'lazyload_post_meta' in 'post' array. Introduced new function 'lazyload_post_meta' for lazy-loading metadata of queued posts. The function also includes logic for resetting the object queue after the meta cache has been updated.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
The commit updates the expected number of database queries in several PHPUnit tests. The changes reflect improvements made in database query management and caching strategy. As a result, these tests are now expecting fewer queries than before, ensuring that our performance optimizations are correctly implemented and functioning.
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Introduce 'rest_menu_read_access' filter to allow customization of read access permissions in REST API endpoints for menus, menu items, and menu locations. This facilitates more flexible access control based on custom criteria.
Replaced wp_lazyload_post_meta with update_postmeta_cache to improve clarity and ensure the correct function is executed for updating post meta cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @spacedmonkey. I haven't tested this, but have left a few questions after reading through the proposed changes.
|
||
$object_ids = array_keys( $this->pending_objects[ $meta_type ] ); | ||
if ( $object_id && ! in_array( $object_id, $object_ids, true ) ) { | ||
return $check; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole method is a line for line duplication of lazyload_meta_callback()
except for this line. Why is the logic different here, and could this be simplified by adding a check for $meta_type
to return the $check
rather than adding the $object_id
to the array of IDs?
@@ -1967,6 +1972,12 @@ public function get_posts() { | |||
$q['update_post_meta_cache'] = true; | |||
} | |||
|
|||
if ( ! isset( $q['lazy_load_post_meta'] ) ) { | |||
$q['lazy_load_post_meta'] = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the DocBlock, shouldn't this be the following?
$q['lazy_load_post_meta'] = false; | |
$q['lazy_load_post_meta'] = $q['update_post_meta_cache']; |
if ( ! isset( $q['lazy_load_post_meta'] ) ) { | ||
$q['lazy_load_post_meta'] = false; | ||
} elseif ( $q['lazy_load_post_meta'] ) { | ||
$q['update_post_meta_cache'] = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For term meta, lazy loading requires term cache priming. Can you add an inline comment about why this is different?
Also, the Docblock states...
Setting to false will disable cache priming for post meta, so that each get_post_meta() call will hit the database.
...but that doesn't seem to be implemented.
Trac ticket: https://core.trac.wordpress.org/ticket/57496
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.