Commit cef693bc authored by das-peter's avatar das-peter Committed by dawehner

Issue by das-peter: Ensure that we do not end up with broken views data cache entries.

parent 10e71bd4
......@@ -67,12 +67,11 @@ function _views_fetch_data($table = NULL, $move = TRUE, $reset = FALSE) {
}
else {
if (!$fully_loaded) {
$data = views_cache_get('views_data', TRUE);
if (!empty($data->data)) {
if ($data = views_cache_get('views_data', TRUE)) {
$cache = $data->data;
}
if (empty($cache)) {
else {
// No cache entry, rebuild.
$cache = _views_fetch_data_build();
}
$fully_loaded = TRUE;
......
......@@ -194,6 +194,30 @@ class ViewsModuleTest extends ViewsSqlTest {
$this->assertEqual(variable_get('views_test_views_data_count', 0), 1, 'Views data rebuilt once');
$this->assertFalse(drupal_static('_views_fetch_data_fully_loaded'), 'Views data is not fully loaded');
// Test if the cache consistency is ensured. There was an issue where
// calling _views_fetch_data() first with a table would prevent the function
// from properly rebuilt a missing the general cache entry.
// See https://www.drupal.org/node/2475669 for details.
// Make sure we start with a empty cache.
$this->resetStaticViewsDataCache();
cache_clear_all('*', 'cache_views', TRUE);
// Prime the static cache of _views_fetch_data() by calling it with a table
// first.
views_fetch_data('views_test');
// Now remove the general cache.
cache_clear_all('views_data:en', 'cache_views');
// Reset the static cache to see if fetches from the persistent cache
// properly rebuild the static cache.
$this->resetStaticViewsDataCache();
// Prime the static cache of _views_fetch_data() by calling it with a table
// first.
views_fetch_data('views_test');
// Fetch the general cache, which was deleted, an see if it is rebuild
// properly.
views_fetch_data();
$this->assertTrue(cache_get('views_data:en', 'cache_views'), 'Cache for all tables was properly rebuild.');
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment