cache_clear_all should clear cache_page by default
firebus - October 24, 2007 - 19:55
| Project: | Memcache API and Integration |
| Version: | 5.x-1.6 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | firebus |
| Status: | closed |
Description
if no cache table is definited, the core cache_clear_all will clear the 'cache_page' table:
if (!isset($cid) && !isset($table)) {
cache_clear_all(NULL, 'cache_page');
return;
}however, memcache.inc clears the 'cache' table and bin:
$bin = empty($table) ? 'cache' : $table;i'm pretty new at this, but the cache_clear_all() calls i see in comment and node modules are intended to flush the page cache.
i think in drupal 5 that the cache table only exists for contrib module authors who want to cache but are too lazy to make their own table...but i could be totally mistaken here. please let me know if it's safe for me to change the default bin for cache_clear_all in memcache.inc
thanks!

#1
Those are not the same thing. empty() is a php function that returns a bool (TRUE|FALSE) of whether the variable is empty or not. The ternary operator ( ? : ) works like a single if-else statement.
check out http://us.php.net/manual/en/function.empty.php
steve
#2
yes, however despite the differences between isset() and empty(), and the rather round about coding in cache.inc, the behavior is still incorrect for memcache.
with cache.inc, cache_clear_all() and cache_clear_all($cid) will operate on the 'cache_page' table.
with memcache.inc, cache_clear_all() and cache_clear_all($cid) will operate on the 'cache' table.
the default value for $table in both cache_clear_all() functions is NULL. empty(NULL) returns FALSE. isset(NULL) also returns FALSE.
the difference between the two functions is that when $table == NULL, cache.inc uses 'cache_page' and memcache.inc uses 'cache'.
sorry if i'm stupid and am missing something really obvious here.
#3
patch for this
#4
#5
#6
oops. i need to patch memcache.db.inc too for this.
#7
I committed this (and the equivalent for memcache.db.inc) but I want some testing to be done! Please test with some different bin configurations, in particular the case where the default 1 bin setup is used and the case where cache_page shares a bin, and the case where cache_page has its own bin.
#8
Nobody complained so I assume the testing actually happened ;-)
#9
Automatically closed -- issue fixed for two weeks with no activity.