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!

CommentFileSizeAuthor
#3 memcache.inc_.186332.patch802 bytesfirebus

Comments

slantview’s picture

Status: Active » Closed (works as designed)

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

firebus’s picture

Status: Closed (works as designed) » Active

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.

firebus’s picture

Status: Active » Needs review
StatusFileSize
new802 bytes

patch for this

firebus’s picture

Assigned: Unassigned » firebus
Status: Needs review » Reviewed & tested by the community
firebus’s picture

Title: cache_clear_all differences between memcache.inc and cache.inc » cache_clear_all should clear cache_page by default
firebus’s picture

Status: Reviewed & tested by the community » Needs work

oops. i need to patch memcache.db.inc too for this.

robertdouglass’s picture

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.

robertdouglass’s picture

Status: Needs work » Fixed

Nobody complained so I assume the testing actually happened ;-)

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.