When context module is installed but no contexts are defined, it stores empty arrays or even NULL in the cache. On the next request, these caches are incorrectly ignored, re-loaded and re-saved into the cache. This happens on every request.
In case of the conditions_map cache, this is actually repeated ~8 times *per page load*.
Since writing a cache is relatively slow, this seriously impacts performance.
The attached patch assures that:
- an empty array is stored into the cache (instead of NULL)
- changes both context_cache_get() to return empty arrays (by replacing !empty with isset) and changes the calling code to accept empty arrays.
Comment | File | Size | Author |
---|---|---|---|
cache_fixes.patch | 1.13 KB | Berdir | |
Comments
Comment #1
BerdirComment #2
emanaton CreditAttribution: emanaton commentedIt appears that this bug is no longer effecting the project. I've taken the following steps:
Barring further activity on this thread, I'm closing out this ticket on the assumption that this is an old bug that effected the beta release, but which no longer effects the current release.
Comment #3
rooby CreditAttribution: rooby commentedI have definitely seen this issue on a live site although it was a little while ago.
I would hesitate to close the issue though because if you look at the code in the patch it would seem like a sensible change regardless.
If a maintainer still doesn't want to commit it though I won't argue.
Comment #4
BerdirBased on the code, I expect this still to be a problem. Try to add a drupal_set_message() in cache_set(), not get(). The static cache will prevent multile cache_get() calls but it should still try to save empty caches back on every request.
Patch also still applies...
Comment #5
emanaton CreditAttribution: emanaton commentedComment #6
emanaton CreditAttribution: emanaton commentedGreetings rooby and Berdir,
You're right!
On a fresh install without modifications (other than adding debugging messages), I'm detecting the following call with each page load:
... but after applying the patch:
On re-reading the original description, I see that I should have figured out to be testing cache_set as well. I shouldn't have been testing code so late at night, me thinks. =oP
I'm going to do a bit of regression testing on this in the next few days to make sure there's no unforeseen side effects from this; I don't expect any based on the code, but better to be safe. Thank you both for commenting so quickly and getting me back on track!
Comment #7
DamienMcKenna