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

Perform row count after any query filters have been run #342

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rmc47
Copy link
Contributor

@rmc47 rmc47 commented Mar 29, 2019

A proposed solution to #341, by performing the row count after any query filters have been run.

  • If any filters don't change the query, then it should have the same behaviour as before, constructing a COUNT() query from the constituent parts.
  • If filters do change the query:
    • If they leave the field list and order / group by clauses intact, we rewrite the filtered query into a COUNT() fairly safely
    • If the filters change the field list or order / group by clauses (not the case for bbPress), then rewriting it would be rather harder, and probably need a SQL parser. At the moment we just don't attempt to do it. One alternative would be to fall back to the old behaviour, but we wouldn't know if that result was correct or now. Another would be to bail out with an error, which would at least alert folks that something's likely to be incorrect.

I realise this is rather a chunk of change in the WP_Query class. Unfortunately I don't think it's possible to do the same in translations.php. Happy to look at other ways of doing this if you wish.

(Filters may change the number of rows the query returns)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant