The cache_get() code seems to never use the "expire" column outside of checking whether it is equal to CACHE_PERMANENT.
Here is the code in question (cache.inc lines 27+):
if (isset($cache->data)) {
// If the data is permanent or we're not enforcing a minimum cache lifetime
// always return the cached data.
if ($cache->expire == CACHE_PERMANENT || !variable_get('cache_lifetime', 0)) {
$cache->data = db_decode_blob($cache->data);
// ...
}
}
...
If the cache item is not permanent (either temporary or with an expire time) and there is no enforced minimum cache lifetime, shouldn't the code then check to see if the current time is beyond the item's expiration time?
By the time you hit the else clause in line 42 you're guaranteed that the cache item is not permanent and there is a minimum lifetime on the cache. Once it's been determined that the current user's time is past the minimum cache lifetime, shouldn't the code also do another check based on the item's expiration time?
I think the fix to this is simple, but before I submit a patch or anything I would like confirmation that what I'm proposing is expected behavior.
Comments
Comment #1
legion80 commentedDespite me saying I didn't want to submit a patch, here's the diff anyway of what I'm proposing:
Comment #2
Mark Theunissen commentedDuplicate of #534092: cache_get() returns expired cache items