diff --git a/core/lib/Drupal/Core/Plugin/Discovery/CacheDecorator.php b/core/lib/Drupal/Core/Plugin/Discovery/CacheDecorator.php index 67d6cab..3565e8b 100644 --- a/core/lib/Drupal/Core/Plugin/Discovery/CacheDecorator.php +++ b/core/lib/Drupal/Core/Plugin/Discovery/CacheDecorator.php @@ -65,14 +65,24 @@ public function __construct(DiscoveryInterface $decorated, $cache_key, $cache_bi * Implements Drupal\Component\Plugin\Discovery\DicoveryInterface::getDefinition(). */ public function getDefinition($plugin_id) { + if (isset($this->definitions[$plugin_id])) { + return $this->definitions[$plugin_id]; + } + $definitions = $this->getDefinitions(); - return isset($definitions[$plugin_id]) ? $definitions[$plugin_id] : NULL; + if (isset($definitions[$plugin_id])) { + return $definitions[$plugin_id]; + } } /** * Implements Drupal\Component\Plugin\Discovery\DicoveryInterface::getDefinitions(). */ public function getDefinitions() { + if (isset($this->definitions)) { + return $this->definitions; + } + $definitions = $this->getCachedDefinitions(); if (!isset($definitions)) { $definitions = $this->decorated->getDefinitions(); @@ -91,10 +101,9 @@ public function getDefinitions() { * and would actually be returned by the getDefinitions() method. */ protected function getCachedDefinitions() { - if (!isset($this->definitions) && isset($this->cacheKey) && $cache = cache($this->cacheBin)->get($this->cacheKey)) { - $this->definitions = $cache->data; + if (isset($this->cacheKey) && $cache = cache($this->cacheBin)->get($this->cacheKey)) { + return $cache->data; } - return $this->definitions; } /**