diff --git a/core/lib/Drupal/Core/Cache/ApcuBackend.php b/core/lib/Drupal/Core/Cache/ApcuBackend.php index 13b09d7..5fa5e1a 100644 --- a/core/lib/Drupal/Core/Cache/ApcuBackend.php +++ b/core/lib/Drupal/Core/Cache/ApcuBackend.php @@ -271,9 +271,12 @@ public function invalidate($cid) { * {@inheritdoc} */ public function invalidateMultiple(array $cids) { - foreach (apc_fetch(array_map(array($this, 'getApcuKey'), $cids)) as $key => $cache) { - $cache->expire = REQUEST_TIME - 1; - apc_store($key, $cache, 1); + $result = apc_fetch(array_map(array($this, 'getApcuKey'), $cids)); + if ($result) { + foreach ($result as $key => $cache) { + $cache->expire = REQUEST_TIME - 1; + apc_store($key, $cache, 1); + } } } diff --git a/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php b/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php index 2df1290..2a93827 100644 --- a/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php +++ b/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php @@ -533,10 +533,10 @@ function testDeleteTags() { $this->assertTrue($this->getCacheBackend($bin)->get('test_cid_invalidate1'), 'Cache items not matching tag were not invalidated.'); // Test that invalid items are deleted. - $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag' => array(1))); + $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag:1')); $backend->invalidate('test_cid_invalidate1'); $this->assertTrue($backend->get('test_cid_invalidate1', TRUE), 'The invalid cache item exists before deleting.'); - $backend->deleteTags(array('test_tag' => array(1))); + $backend->deleteTags(array('test_tag:1')); $this->assertFalse($backend->get('test_cid_invalidate1', TRUE), 'The invalid cache item was deleted.'); } @@ -597,9 +597,9 @@ function testInvalidate() { $this->assertFalse($backend->invalidateMultiple(array())); // Test that an invalidated item is deleted with deleteTags(). - $backend->set('test5', 5, Cache::PERMANENT, array('test_tag' => 5)); + $backend->set('test5', 5, Cache::PERMANENT, array('test_tag:5')); $backend->invalidate('test5'); - $backend->deleteTags(array('test_tag' => 5)); + $backend->deleteTags(array('test_tag:5')); $this->assertFalse($backend->get('test5', TRUE)); } @@ -686,14 +686,14 @@ public function testInvalidateAll() { $this->assertIdentical($backend->get('test1', TRUE)->data, 1); // Test that an invalidated item is deleted with deleteTags(). - $backend->set('test4', 4, Cache::PERMANENT, array('test_tag' => 4)); + $backend->set('test4', 4, Cache::PERMANENT, array('test_tag:4')); $backend->invalidateAll(); - $backend->deleteTags(array('test_tag' => 4)); + $backend->deleteTags(array('test_tag:4')); $this->assertFalse($backend->get('test4', TRUE)); // Test that a deleted item is still deleted after invalidateAll(). - $backend->set('test5', 5, Cache::PERMANENT, array('test_tag' => 5)); - $backend->deleteTags(array('test_tag' => 5)); + $backend->set('test5', 5, Cache::PERMANENT, array('test_tag:5')); + $backend->deleteTags(array('test_tag:5')); $backend->invalidateAll(); $this->assertFalse($backend->get('test5', TRUE)); }