diff --git a/includes/cache.inc b/includes/cache.inc index 92d5864e26719ec123dfe4b85b8bdea158680c26..95d23222f4a6e9a4d2a55ad6bfe0e576b0ada972 100644 --- a/includes/cache.inc +++ b/includes/cache.inc @@ -8,21 +8,20 @@ /** * Fetch Views' data from the cache. * - * @param string|null $table - * If null return views data for all tables, else - * @param bool $move - * Under certain circumstances it makes sense to not get the moved table, but the old one. - * One example is views_get_handler. + * $param string|null $table + * (optional) The name of the table for which to fetch Views' data. If + * NULL, data for all tables will be retrieved * @param bool $reset - * If $reset is TRUE, rebuild the internal cache. + * (optional) Whether to rebuild the cache. Defaults to FALSE. * * @return array - * An array of views data. If $table is NULL if will contains one info array - * for each table, else just one info array. + * An associative array of views data for the given table. If $table is + * NULL, the array will be keyed by table name, with each key corresponding + * to the data array for that table. * - * @see hook_views_data + * @see hook_views_data() */ -function _views_fetch_data($table = NULL, $move = TRUE, $reset = FALSE) { +function _views_fetch_data($table = NULL, $reset = FALSE) { $cache = &drupal_static(__FUNCTION__ . '_cache'); $recursion_protection = &drupal_static(__FUNCTION__ . '_recursion_protected'); $fully_loaded = &drupal_static(__FUNCTION__ . '_fully_loaded'); diff --git a/lib/Drupal/views/Tests/ViewsDataTest.php b/lib/Drupal/views/Tests/ViewsDataTest.php index 6b16a82a278342d3f3601ba6c74715abb511738e..d1ab4ae04ec0bbff87d6d4b5d8531c4e5c55492e 100644 --- a/lib/Drupal/views/Tests/ViewsDataTest.php +++ b/lib/Drupal/views/Tests/ViewsDataTest.php @@ -44,7 +44,7 @@ public function testViewsFetchData() { $this->assertTrue(isset($data[$table_name]), 'Make sure the views_test_data info appears in the total views data.'); $this->assertEqual($data[$table_name], $expected_data[$table_name], 'Make sure the views_test_data has the expected values.'); - $data = views_fetch_data(NULL, TRUE, TRUE); + $data = views_fetch_data(NULL, TRUE); $this->assertTrue(isset($data[$table_name]), 'Make sure the views_fetch_data appears in the total views data with reset = TRUE.'); $this->assertEqual($data[$table_name], $expected_data[$table_name], 'Make sure the views_test_data has the expected values.'); } diff --git a/views.api.php b/views.api.php index 5780ba0dcf893930990b1e3f885be4efc546ebd6..a1b16a127c478f2cbbfce7a232cefb15262461e7 100644 --- a/views.api.php +++ b/views.api.php @@ -290,6 +290,9 @@ /** * Describe data tables (or the equivalent) to Views. * + * The data described with this hook is fetched and retrieved by + * views_fetch_data(). + * * @return array * An associative array describing the data structure. Primary key is the * name used internally by Views for the table(s) – usually the actual table diff --git a/views.module b/views.module index c7945cf1726a34fadee7916510891cfdc381a54b..b218edef79eadeddb1dfbeeba54b451ebe7e0c1c 100644 --- a/views.module +++ b/views.module @@ -1284,7 +1284,7 @@ function views_get_handler($table, $field, $type, $override = NULL) { // Get the plugin manager for this type. $manager = drupal_container()->get("plugin.manager.views.$type"); - $data = views_fetch_data($table, FALSE); + $data = views_fetch_data($table); if (isset($data[$field][$type])) { $definition = $data[$field][$type]; foreach (array('group', 'title', 'title short', 'help', 'real field', 'real table') as $key) { @@ -1324,10 +1324,23 @@ function views_get_handler($table, $field, $type, $override = NULL) { /** * Fetch Views' data from the cache + * + * $param string|null $table + * (optional) The name of the table for which to fetch Views' data. If + * NULL, data for all tables will be retrieved + * @param bool $reset + * (optional) Whether to rebuild the cache. Defaults to FALSE. + * + * @return array + * An associative array of views data for the given table. If $table is + * NULL, the array will be keyed by table name, with each key corresponding + * to the data array for that table. + * + * @see hook_views_data() */ -function views_fetch_data($table = NULL, $move = TRUE, $reset = FALSE) { +function views_fetch_data($table = NULL, $reset = FALSE) { views_include('cache'); - return _views_fetch_data($table, $move, $reset); + return _views_fetch_data($table, $reset); } /**