summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2015-10-16 10:31:53 (GMT)
committerNathaniel Catchpole2015-10-16 10:31:53 (GMT)
commit268f6c32d010070c09867acccb35e41c8e4f8c80 (patch)
tree91aa2e6231fe6e4504451523223791ae7050c804
parent74a50236b800230e2d4b4565f2f51e5ff3bd73ca (diff)
Issue #2581395 by moshe weitzman, kylebrowning, dawehner: Incorrect expiration in APCUBackend
-rw-r--r--core/lib/Drupal/Core/Cache/ApcuBackend.php12
-rw-r--r--core/modules/system/src/Tests/Cache/ApcuBackendUnitTest.php9
2 files changed, 12 insertions, 9 deletions
diff --git a/core/lib/Drupal/Core/Cache/ApcuBackend.php b/core/lib/Drupal/Core/Cache/ApcuBackend.php
index 7f04f0e..b64fd71 100644
--- a/core/lib/Drupal/Core/Cache/ApcuBackend.php
+++ b/core/lib/Drupal/Core/Cache/ApcuBackend.php
@@ -68,7 +68,7 @@ class ApcuBackend implements CacheBackendInterface {
* @return string
* The APCu key for the cache item ID.
*/
- protected function getApcuKey($cid) {
+ public function getApcuKey($cid) {
return $this->binPrefix . $cid;
}
@@ -178,14 +178,8 @@ class ApcuBackend implements CacheBackendInterface {
$cache->serialized = 0;
$cache->data = $data;
- // apc_store()'s $ttl argument can be omitted but also set to 0 (zero),
- // in which case the value will persist until it's removed from the cache or
- // until the next cache clear, restart, etc. This is what we want to do
- // when $expire equals CacheBackendInterface::CACHE_PERMANENT.
- if ($expire === CacheBackendInterface::CACHE_PERMANENT) {
- $expire = 0;
- }
- apc_store($this->getApcuKey($cid), $cache, $expire);
+ // Expiration is handled by our own prepareItem(), not APCu.
+ apc_store($this->getApcuKey($cid), $cache);
}
/**
diff --git a/core/modules/system/src/Tests/Cache/ApcuBackendUnitTest.php b/core/modules/system/src/Tests/Cache/ApcuBackendUnitTest.php
index fcb5577..fafac7e 100644
--- a/core/modules/system/src/Tests/Cache/ApcuBackendUnitTest.php
+++ b/core/modules/system/src/Tests/Cache/ApcuBackendUnitTest.php
@@ -87,6 +87,15 @@ class ApcuBackendUnitTest extends GenericCacheBackendUnitTestBase {
return;
}
parent::testSetGet();
+
+ // Make sure entries are permanent (i.e. no TTL).
+ $backend = $this->getCacheBackend($this->getTestBin());
+ $key = $backend->getApcuKey('TEST8');
+ foreach (new \APCIterator('user', '/^' . $key . '/') as $item) {
+ $this->assertEqual(0, $item['ttl']);
+ $found = TRUE;
+ }
+ $this->assertTrue($found);
}
/**