diff --git a/core/lib/Drupal/Core/Cache/PhpBackend.php b/core/lib/Drupal/Core/Cache/PhpBackend.php index 8613859..d4554c5 100644 --- a/core/lib/Drupal/Core/Cache/PhpBackend.php +++ b/core/lib/Drupal/Core/Cache/PhpBackend.php @@ -165,7 +165,7 @@ public function deleteMultiple(array $cids) { public function deleteTags(array $tags) { $flat_tags = $this->flattenTags($tags); foreach ($this->storage()->listAll() as $cidhash) { - $item = $this->getByHash($cidhash); + $item = $this->getByHash($cidhash, TRUE); if (is_object($item) && array_intersect($flat_tags, $item->tags)) { $this->delete($item->cid); } diff --git a/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php b/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php index 050cf03..4515714 100644 --- a/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php +++ b/core/modules/system/src/Tests/Cache/GenericCacheBackendUnitTestBase.php @@ -503,6 +503,13 @@ function testDeleteTags() { $this->assertFalse($this->getCacheBackend($bin)->get('test_cid_invalidate2', TRUE), 'Cache items matching tag were deleted.'); // Test that the cache entry with without a matching tag still exists. $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->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))); + $this->assertFalse($backend->get('test_cid_invalidate1', TRUE), 'The invalid cache item was deleted.'); } /**