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

Prime parent cache on save post. #5443

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

spacedmonkey
Copy link
Member

Break out from #5420.

Trac ticket: https://core.trac.wordpress.org/ticket/59188


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.

Copy link
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Left some nit-pick feedback.

* This function sets or updates the post parent cache for a given post ID.
* The post parent cache is used to store the parent ID of a post for quick retrieval.
*
* @since 6.4.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @since 6.4.0
* @since 6.4.0

* The post parent cache is used to store the parent ID of a post for quick retrieval.
*
* @since 6.4.0
*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
*
* @access private
*

Comment on lines +3579 to +3580
* @param int $post_id The ID of the post for which to set or update the parent cache.
* @param WP_Post $post The post object representing the post.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param int $post_id The ID of the post for which to set or update the parent cache.
* @param WP_Post $post The post object representing the post.
* @param int $post_id The ID of the post for which to set or update the parent cache.
* @param WP_Post $post The post object representing the post.

@@ -3568,6 +3568,21 @@ function _reset_front_page_settings_for_post( $post_id ) {
unstick_post( $post->ID );
}

/**
* Set or update the post parent cache for a specific post.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Set or update the post parent cache for a specific post.
* Sets or updates the post parent cache for a specific post.

Copy link
Member

@joemcgill joemcgill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this @spacedmonkey, and sorry for the delay in reviewing it. The approach looks solid, but personally, I don't see a lot of value in this, unless I'm missing something. Given that for most sites the cache will be non-persistent, these primed caches will never be used.

For sites that do have a persistent cache, this DB query would be more efficiently called when reading versus when writing data, where it would only be in the cache when some query is requesting it—and then, only the first time. Plus, when IDs are cached in queries, multiple IDs could be cached at the same time, rather that one at a time here.

If we decide to do this later, we can revisit as part of a standalone follow-up ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants