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

Cache Group last_changed Not Always Updated #160

Open
spencerfinnell opened this issue Jun 6, 2023 · 0 comments
Open

Cache Group last_changed Not Always Updated #160

spencerfinnell opened this issue Jun 6, 2023 · 0 comments
Assignees
Labels
component-query The Query class type-bug A problem in the code
Milestone

Comments

@spencerfinnell
Copy link

Query::$last_changed is only updated when a value has not previously been set.

This can cause potentially unexpected results when re-querying with the same Query instance, with the same query variables, after changing the dataset.

See: https://gist.github.com/spencerfinnell/0b02521602fa2bdaa8b9495fff745ff8

Instead of finding the remaining item in the set, the originally found item is given a false value.

I say potentially unexpected because an argument could be made that not creating a new instance of the Query class should return the same set originally found items with the relevant updates. Expecting a new instance of the query class to be instantiated does seem to mirror general new WP_Query usage. However, I am unsure of the extended caching ramifications of this.

A quick workaround is ensuring $this->set_last_changed(); is always called inside of Query::update_last_changed_cache() -- however the extended ramifications of this change have not been fully explored.

@JJJ JJJ self-assigned this Jun 7, 2023
@JJJ JJJ added type-bug A problem in the code component-query The Query class labels Jun 7, 2023
@JJJ JJJ added this to the 3.0.0 milestone Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component-query The Query class type-bug A problem in the code
Projects
None yet
Development

No branches or pull requests

2 participants