berlindb / core

All of the required core code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cache Group `last_changed` Not Always Updated

spencerfinnell opened this issue · comments

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.