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

slantview - October 24, 2007 - 22:40
Status:active» by design

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

firebus - October 24, 2007 - 22:54
Status:by design» 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.

#3

firebus - November 6, 2007 - 17:49
Status:active» patch (code needs review)

patch for this

AttachmentSize
memcache.inc_.186332.patch802 bytes

#4

firebus - December 24, 2007 - 02:21
Assigned to:Anonymous» firebus
Status:patch (code needs review)» patch (reviewed & tested by the community)

#5

firebus - December 24, 2007 - 02:24
Title:cache_clear_all differences between memcache.inc and cache.inc» cache_clear_all should clear cache_page by default

#6

firebus - December 24, 2007 - 02:39
Status:patch (reviewed & tested by the community)» patch (code needs work)

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

#7

robertDouglass - February 12, 2008 - 21:59

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

robertDouglass - July 18, 2008 - 20:25
Status:patch (code needs work)» fixed

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

#9

Anonymous (not verified) - August 1, 2008 - 20:35
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.