From ed50b5ef46fa02046fda0f4d24e4fdc9f72c0c71 Mon Sep 17 00:00:00 2001
From: Bob Vincent <bobvin@pillars.net>
Date: Fri, 12 Aug 2011 09:53:24 -0400
Subject: [PATCH] Issue #81461, Issue #1246796: Patch core and Memcache so that memcache can pass its own tests.

---
 memcache.inc                |   26 +++++++++++++++++++++++---
 tests/memcache-session.test |    2 +-
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/memcache.inc b/memcache.inc
index 7718880d2c6499ad2be9ce1ccba3dbea73a26bfe..f5ed636910bf96f3b351408907b8fb1b5e2a63a8 100644
--- a/memcache.inc
+++ b/memcache.inc
@@ -71,7 +71,7 @@ class MemCacheDrupal implements DrupalCacheInterface {
     }
 
     // The item can be expired if:
-    // - A liftetime is set and the item is older than both the lifetime and
+    // - A lifetime is set and the item is older than both the lifetime and
     //   the global flush.
     // - The item has been create before the bin was flushed for this user.
     // - The item could simply expire.
@@ -130,6 +130,25 @@ class MemCacheDrupal implements DrupalCacheInterface {
     dmemcache_set($cid, $cache, 0, $this->bin, $this->memcache);
   }
 
+  function delete($cid) {
+    $this->clear($cid);
+  }
+  function deleteMultiple(array $cids) {
+    $this->clear($cid);
+  }
+  function deletePrefix($prefix) {
+    $this->clear($prefix, TRUE);
+  }
+  function flush() {
+    $this->clear('*', TRUE);
+  }
+  function flushTemporary() {
+    $this->clear(NULL, TRUE);
+  }
+  function garbageCollection() {
+    return FALSE;
+  }
+
   function clear($cid = NULL, $wildcard = FALSE) {
     if (empty($cid) || $wildcard === TRUE) {
       // system_cron() flushes all cache bins returned by hook_flush_caches()
@@ -137,10 +156,11 @@ class MemCacheDrupal implements DrupalCacheInterface {
       // the database cache, but serves no purpose with memcache. So return
       // early here.
       if (!isset($cid)) {
-        return;
+        // Removed as per http://drupal.org/node/1246796#comment-4856936
+        // return;
       }
       elseif ($cid == '*') {
-        $cid = '';
+        $cid = NULL;
       }
       if ($this->cache_lifetime && empty($cid)) {
         // Update the timestamp of the last global flushing of this bin.  When
diff --git a/tests/memcache-session.test b/tests/memcache-session.test
index e39abb9fff6a00fba2d4dc3f104fc4ec2c0ff108..2c077170ce5a0835736ed919a68dcc5e2a7fb6d8 100644
--- a/tests/memcache-session.test
+++ b/tests/memcache-session.test
@@ -140,7 +140,7 @@ class MemcacheSessionTestCase extends DrupalWebTestCase {
     $this->assertSessionEmpty(TRUE);
 
     // The same behavior is expected when caching is enabled.
-    variable_set('cache', CACHE_NORMAL);
+    variable_set('cache', 1);
     $this->drupalGet('');
     $this->assertSessionCookie(FALSE);
     $this->assertSessionEmpty(TRUE);
-- 
1.7.4.1

