diff --git a/core/lib/Drupal/Core/Template/TwigCacheChain.php b/core/lib/Drupal/Core/Template/TwigCacheChain.php index 3696e09..956cb6d 100644 --- a/core/lib/Drupal/Core/Template/TwigCacheChain.php +++ b/core/lib/Drupal/Core/Template/TwigCacheChain.php @@ -26,6 +26,7 @@ class TwigCacheChain implements \Twig_CacheInterface { * The cache classes to chain. */ public function __construct(array $caches) { + assert('Drupal\\Component\\Assertion\\Inspector::assertAllObjects($collection, \'\\Twig_CacheInterface\''); $this->caches = $caches; } @@ -34,10 +35,8 @@ public function __construct(array $caches) { */ public function generateKey($name, $className) { foreach ($this->caches as $cache) { - if ($cache instanceof \Twig_CacheInterface) { - $key = $cache->generateKey($name, $className); - return $key; - } + $key = $cache->generateKey($name, $className); + return $key; } } @@ -46,10 +45,8 @@ public function generateKey($name, $className) { */ public function has($key) { foreach ($this->caches as $cache) { - if ($cache instanceof \Twig_CacheInterface) { - if ($has = $cache->has($key)) { - return $has; - } + if ($has = $cache->has($key)) { + return $has; } } } @@ -59,15 +56,13 @@ public function has($key) { */ public function load($key) { foreach ($this->caches as $cache) { - if ($cache instanceof \Twig_CacheInterface) { - try { - if ($cache->has($key)) { - $cache->load($key); - } - return; - } - catch (\RuntimeException $e) { + try { + if ($cache->has($key)) { + $cache->load($key); } + return; + } + catch (\RuntimeException $e) { } } } @@ -76,14 +71,12 @@ public function load($key) { * {@inheritdoc} */ public function write($key, $content) { + // We want to write to all of them. foreach ($this->caches as $cache) { - if ($cache instanceof \Twig_CacheInterface) { - try { - $cache->write($key, $content); - return; - } - catch (\RuntimeException $e) { - } + try { + $cache->write($key, $content); + } + catch (\RuntimeException $e) { } } } @@ -93,10 +86,8 @@ public function write($key, $content) { */ public function getTimestamp($key) { foreach ($this->caches as $cache) { - if ($cache instanceof \Twig_CacheInterface) { - if ($timestamp = $cache->getTimestamp($key)) { - return $timestamp; - } + if ($timestamp = $cache->getTimestamp($key)) { + return $timestamp; } } }