Issue #2567133 by Wim Leers: getTypes in TypeLinkManager doesn't work with the null cache back end

8.2.x
Alex Pott 2016-06-02 13:48:41 +01:00
parent d4c41939e2
commit edad386212
1 changed files with 10 additions and 3 deletions

View File

@ -89,10 +89,12 @@ class TypeLinkManager extends LinkManagerBase implements TypeLinkManagerInterfac
$cid = 'rest:links:types'; $cid = 'rest:links:types';
$cache = $this->cache->get($cid); $cache = $this->cache->get($cid);
if (!$cache) { if (!$cache) {
$this->writeCache($context); $data = $this->writeCache($context);
$cache = $this->cache->get($cid);
} }
return $cache->data; else {
$data = $cache->data;
}
return $data;
} }
/** /**
@ -100,6 +102,10 @@ class TypeLinkManager extends LinkManagerBase implements TypeLinkManagerInterfac
* *
* @param array $context * @param array $context
* Context from the normalizer/serializer operation. * Context from the normalizer/serializer operation.
*
* @return array
* An array of typed data ids (entity_type and bundle) keyed by
* corresponding type URI.
*/ */
protected function writeCache($context = array()) { protected function writeCache($context = array()) {
$data = array(); $data = array();
@ -125,6 +131,7 @@ class TypeLinkManager extends LinkManagerBase implements TypeLinkManagerInterfac
// These URIs only change when entity info changes, so cache it permanently // These URIs only change when entity info changes, so cache it permanently
// and only clear it when entity_info is cleared. // and only clear it when entity_info is cleared.
$this->cache->set('rest:links:types', $data, Cache::PERMANENT, array('entity_types')); $this->cache->set('rest:links:types', $data, Cache::PERMANENT, array('entity_types'));
return $data;
} }
} }