Last active
August 29, 2015 13:58
-
-
Save damiankloip/10269728 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/core/modules/views/lib/Drupal/views/ViewsData.php b/core/modules/views/lib/Drupal/views/ViewsData.php | |
index a1e2da4..a2a7d29 100644 | |
--- a/core/modules/views/lib/Drupal/views/ViewsData.php | |
+++ b/core/modules/views/lib/Drupal/views/ViewsData.php | |
@@ -38,13 +38,20 @@ class ViewsData { | |
protected $cacheBackend; | |
/** | |
- * Storage for the data itself. | |
+ * Table data storage. | |
* | |
* @var array | |
*/ | |
protected $storage = array(); | |
/** | |
+ * All table storage data loaded from cache. | |
+ * | |
+ * @var array | |
+ */ | |
+ protected $allStorage = array(); | |
+ | |
+ /** | |
* Whether the data has been fully loaded in this request. | |
* | |
* @var bool | |
@@ -115,8 +122,8 @@ public function get($key = NULL) { | |
if (!isset($this->storage[$key])) { | |
// Prepare a cache ID for get and set. | |
$cid = $this->baseCid . ':' . $key; | |
- | |
$from_cache = FALSE; | |
+ | |
if ($data = $this->cacheGet($cid)) { | |
$this->storage[$key] = $data->data; | |
$from_cache = TRUE; | |
@@ -124,18 +131,23 @@ public function get($key = NULL) { | |
// If there is no cached entry and data is not already fully loaded, | |
// rebuild. This will stop requests for invalid tables calling getData. | |
elseif (!$this->fullyLoaded) { | |
- $this->storage = $this->getData(); | |
+ $this->allStorage = $this->getData(); | |
} | |
if (!$from_cache) { | |
- if (!isset($this->storage[$key])) { | |
+ if (!isset($this->allStorage[$key])) { | |
// Write an empty cache entry if no information for that table | |
// exists to avoid repeated cache get calls for this table and | |
// prevent loading all tables unnecessarily. | |
$this->storage[$key] = array(); | |
+ $this->allStorage[$key] = array(); | |
} | |
+ else { | |
+ $this->storage[$key] = $this->allStorage[$key]; | |
+ } | |
+ | |
// Create a cache entry for the requested table. | |
- $this->cacheSet($cid, $this->storage[$key]); | |
+ $this->cacheSet($cid, $this->allStorage[$key]); | |
} | |
} | |
@@ -143,11 +155,12 @@ public function get($key = NULL) { | |
} | |
else { | |
if (!$this->fullyLoaded) { | |
- $this->storage = $this->getData(); | |
+ $this->allStorage = $this->getData(); | |
+ $this->storage = $this->allStorage; | |
} | |
} | |
- return $this->storage; | |
+ return $this->allStorage; | |
} | |
/** | |
@@ -286,6 +299,7 @@ public function fetchBaseTables() { | |
*/ | |
public function clear() { | |
$this->storage = array(); | |
+ $this->allStorage = array(); | |
$this->fullyLoaded = FALSE; | |
$this->cacheBackend->deleteAll(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment