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

Use _prime_post_caches if the query is not filtered. #5251

Closed
wants to merge 5 commits into from

Conversation

spacedmonkey
Copy link
Member

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


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

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

@spacedmonkey Only one crucial point of feedback here, similar to what I mentioned on the original PR.

Other than that, this looks good to me.

@@ -3270,10 +3270,11 @@ public function get_posts() {
return $post_parents;
}

$unfiltered_query = $old_request == $this->request && "{$wpdb->posts}.*" === $fields;
Copy link
Member

Choose a reason for hiding this comment

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

Two things:

  • Why a non-strict comparison here? Can't we use ===?
  • Nit-pick, but maybe $is_unfiltered_query is a better name here, to clarify that this is a boolean.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have changed the variable name. But I will not change the logic for now. That is the logic it was before and I don't want to change it.

Copy link
Member

Choose a reason for hiding this comment

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

@spacedmonkey Why not use ===? I see this was using == before, but I don't think there's a good reason not to fix it. The request is always a string, and I don't think for strings the == or === even makes a real difference. I think we should use === in accordance with the latest WordPress coding standards and using strict comparisons.

src/wp-includes/class-wp-query.php Outdated Show resolved Hide resolved
Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

Thanks @spacedmonkey for the updates, LGTM. I'd still recommend using a strict comparison in #5251 (comment), but not a blocker.

Would be great to get @peterwilsoncc's review on this as well before committing.

@spacedmonkey
Copy link
Member Author

Committed e486ac0

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