updated modules

views friendly_register serial address_field i18n
This commit is contained in:
Bachir Soussi Chiadmi
2015-05-26 19:56:22 +02:00
parent c9f8dc21ed
commit 706c96d663
58 changed files with 584 additions and 367 deletions

View File

@@ -42,10 +42,14 @@ function views_drush_command() {
),
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
'aliases' => array('vr'),
'options' => array(
'all' => 'If provided, all views will be reverted.',
),
'examples' => array(
'drush vr archive' => 'Reverts the "archive" view.',
'drush rln archive frontpage' => 'Reverts the "archive" and "frontpage" view.',
'drush vr' => 'Will present you with a list of overridden views to choose from, and an option to revert all overridden views.',
'drush vr --all' => 'Will revert all overridden views.',
),
);
$items['views-dev'] = array(
@@ -126,15 +130,21 @@ function views_revert_views() {
}
}
// Return early if there are no overridden views in the system.
// If there are no overridden views in the system, report it.
if (empty($overridden)) {
return drush_set_error(dt('There are no overridden views in the system.'));
drush_log(dt('There are no overridden views in the system.'), 'ok');
}
// If the user specified in the command the views to be overridden.
if (!empty($viewnames)) {
// If the user provided the "--all" option, revert all views.
if (drush_get_option('all')) {
$i = views_revert_allviews($views);
}
// If the user specified a list of views on the CLI, revert those.
elseif (!empty($viewnames)) {
foreach ($viewnames as $key => $viewname) {
$is_overridden = key_exists($viewname, $overridden);
// Check if the provided view name is in the system
if ($viewname && !key_exists($viewname, $views)) {
drush_set_error(dt("'@viewname' view is not present in the system.", array('@viewname' => $viewname)));
@@ -144,18 +154,22 @@ function views_revert_views() {
drush_set_error(dt("The view specified '@viewname' is not overridden.", array('@viewname' => $viewname)));
}
// If the view is overriden, revert it.
elseif ($is_overridden){
elseif ($is_overridden) {
views_revert_view($views[$viewname]);
$i++;
}
// We should never get here but well...
else {
drush_set_error(dt("The view specified '@viewname' is not provided in code, and thus cannot be reverted.", array('@viewname' => $viewname)));
drush_set_error(dt(
"The view specified '@viewname' is not provided in code, and thus cannot be reverted.",
array('@viewname' => $viewname)
));
}
}
}
// The user did not specify any views in the command, prompt the user
// The user neither selected the "--all" option, nor provided a list of views to revert.
// Prompt the user.
else {
// list of choices for the user
$overridden['all'] = dt('Revert all overridden views'); // add a choice at the end

View File

@@ -372,7 +372,7 @@ class views_handler_field extends views_handler {
* Optional name of the field where the value is stored.
*/
function get_value($values, $field = NULL) {
$alias = isset($field) && isset($this->aliases[$field]) ? $this->aliases[$field] : $this->field_alias;
$alias = isset($field) ? $this->aliases[$field] : $this->field_alias;
if (isset($values->{$alias})) {
return $values->{$alias};
}

View File

@@ -158,13 +158,11 @@ class views_handler_filter_date extends views_handler_filter_numeric {
}
function op_between($field) {
$a = intval(strtotime($this->value['min'], 0));
$b = intval(strtotime($this->value['max'], 0));
// Use the substitutions to ensure a consistent timestamp.
$query_substitutions = views_views_query_substitutions($this->view);
$a = intval(strtotime($this->value['min'], $query_substitutions['***CURRENT_TIME***']));
$b = intval(strtotime($this->value['max'], $query_substitutions['***CURRENT_TIME***']));
if ($this->value['type'] == 'offset') {
$a = '***CURRENT_TIME***' . sprintf('%+d', $a); // keep sign
$b = '***CURRENT_TIME***' . sprintf('%+d', $b); // keep sign
}
// This is safe because we are manually scrubbing the values.
// It is necessary to do it this way because $a and $b are formulas when using an offset.
$operator = strtoupper($this->operator);
@@ -172,10 +170,10 @@ class views_handler_filter_date extends views_handler_filter_numeric {
}
function op_simple($field) {
$value = intval(strtotime($this->value['value'], 0));
if (!empty($this->value['type']) && $this->value['type'] == 'offset') {
$value = '***CURRENT_TIME***' . sprintf('%+d', $value); // keep sign
}
// Use the substitutions to ensure a consistent timestamp.
$query_substitutions = views_views_query_substitutions($this->view);
$value = intval(strtotime($this->value['value'], $query_substitutions['***CURRENT_TIME***']));
// This is safe because we are manually scrubbing the value.
// It is necessary to do it this way because $value is a formula when using an offset.
$this->query->add_where_expression($this->options['group'], "$field $this->operator $value");

View File

@@ -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;
@@ -127,12 +126,25 @@ function _views_data_process_entity_types(&$data) {
function _views_fetch_plugin_data($type = NULL, $plugin = NULL, $reset = FALSE) {
static $cache = NULL;
if (!isset($cache) || $reset) {
$start = microtime(TRUE);
views_include('plugins');
views_include_handlers();
$cache = views_discover_plugins();
// Load necessary code once.
if (!isset($cache)) {
views_include('plugins');
views_include_handlers();
}
// Because plugin data contains translated strings, and as such can be
// expensive to build, the results are cached per language.
global $language;
$cache_key = 'views:plugin_data:' . $language->language;
if (!$reset) {
if ($cache = cache_get($cache_key)) {
$cache = $cache->data;
}
}
// If not available in the cache, build it and cache it.
if (!$cache) {
$cache = views_discover_plugins();
cache_set($cache_key, $cache);
}
}
if (!$type && !$plugin) {

View File

@@ -107,7 +107,7 @@ class views_plugin_row_comment_rss extends views_plugin_row {
),
array(
'key' => 'dc:creator',
'value' => $comment->name,
'value' => format_username($comment),
),
array(
'key' => 'guid',

View File

@@ -117,7 +117,7 @@ class views_plugin_row_node_rss extends views_plugin_row {
),
array(
'key' => 'dc:creator',
'value' => $node->name,
'value' => format_username($node),
),
array(
'key' => 'guid',

View File

@@ -206,14 +206,14 @@ class views_plugin_cache extends views_plugin {
// Slightly less simple for CSS:
$css = drupal_add_css();
$css_start = isset($this->storage['css']) ? $this->storage['css'] : array();
$this->storage['css'] = $array_mapping_func($css, $css_start);
$this->storage['css'] = $this->assetDiff($css, $css_start, $array_mapping_func);
// Get javascript after/before views renders.
$js = drupal_add_js();
$js_start = isset($this->storage['js']) ? $this->storage['js'] : array();
// If there are any differences between the old and the new javascript then
// store them to be added later.
$this->storage['js'] = $array_mapping_func($js, $js_start);
$this->storage['js'] = $this->assetDiff($js, $js_start, $array_mapping_func);
// Special case the settings key and get the difference of the data.
$settings = isset($js['settings']['data']) ? $js['settings']['data'] : array();
@@ -224,6 +224,38 @@ class views_plugin_cache extends views_plugin {
$this->storage['headers'] = $array_mapping_func(drupal_get_http_header(), $this->storage['headers']);
}
/**
* Computes the differences between two JS/CSS asset arrays.
*
* @param array $assets
* The current asset array.
* @param array $start_assets
* The original asset array.
* @param string $diff_function
* The function that should be used for computing the diff.
*
* @return array
* A CSS or JS asset array that contains all entries that are new/different
* in $assets.
*/
protected function assetDiff(array $assets, array $start_assets, $diff_function) {
$diff = $diff_function($assets, $start_assets);
// Cleanup the resulting array since drupal_array_diff_assoc_recursive() can
// leave half populated arrays behind.
foreach ($diff as $key => $entry) {
// If only the weight was different we can remove this entry.
if (count($entry) == 1 && isset($entry['weight'])) {
unset($diff[$key]);
}
// If there are other differences we override with the latest entry.
elseif ($entry != $assets[$key]) {
$diff[$key] = $assets[$key];
}
}
return $diff;
}
/**
* Restore out of band data saved to cache. Copied from Panels.
*/

View File

@@ -2140,7 +2140,7 @@ class views_plugin_display extends views_plugin {
'#default_value' => $pager['type'],
);
$pager_plugin = views_fetch_plugin_data('pager', $pager['type'], array($this->view->base_table));
$pager_plugin = views_fetch_plugin_data('pager', $pager['type']);
if (!empty($pager_plugin['uses options'])) {
$form['markup'] = array(
'#prefix' => '<div class="form-item description">',

View File

@@ -227,6 +227,8 @@ class views_plugin_display_attachment extends views_plugin_display {
$args = $this->get_option('inherit_arguments') ? $this->view->args : array();
$view->set_arguments($args);
$exposed_input = $this->get_option('inherit_exposed_filters') ? $this->view->exposed_input : array();
$view->set_exposed_input($exposed_input);
$view->set_display($this->display->id);
if ($this->get_option('inherit_pager')) {
$view->display_handler->use_pager = $this->view->display[$display_id]->handler->use_pager();

View File

@@ -1322,6 +1322,10 @@ class views_plugin_query_default extends views_plugin_query {
if (count($this->having)) {
$this->has_aggregate = TRUE;
}
elseif (!$this->has_aggregate) {
// Allow 'GROUP BY' even no aggregation function has been set.
$this->has_aggregate = $this->view->display_handler->get_option('group_by');
}
if ($this->has_aggregate && (!empty($this->groupby) || !empty($non_aggregates))) {
$groupby = array_unique(array_merge($this->groupby, $non_aggregates));
foreach ($groupby as $field) {

View File

@@ -50,6 +50,21 @@ class ViewsHandlerFilterDateTest extends ViewsSqlTest {
$this->assertIdenticalResultset($view, $expected_result, $this->map);
$view->destroy();
// Test "first day of" type of relative dates for simple operator.
$view->set_display('default');
$view->init_handlers();
$view->filter['created']->operator = '<';
$view->filter['created']->value['type'] = 'offset';
$view->filter['created']->value['value'] = 'last day of January 1970';
$view->execute_display('default');
$expected_result = array(
array('nid' => $this->nodes[0]->nid),
array('nid' => $this->nodes[1]->nid),
array('nid' => $this->nodes[2]->nid),
);
$this->assertIdenticalResultset($view, $expected_result, $this->map);
$view->destroy();
// Test offset for between operator.
$view->set_display('default');
$view->init_handlers();
@@ -63,6 +78,22 @@ class ViewsHandlerFilterDateTest extends ViewsSqlTest {
);
$this->assertIdenticalResultset($view, $expected_result, $this->map);
$view->destroy();
// Test "first day of" type of relative dates for between operator.
$view->set_display('default');
$view->init_handlers();
$view->filter['created']->operator = 'between';
$view->filter['created']->value['type'] = 'offset';
$view->filter['created']->value['max'] = 'last day of January 1970';
$view->filter['created']->value['min'] = 'first day of January 1970';
$view->execute_display('default');
$expected_result = array(
array('nid' => $this->nodes[0]->nid),
array('nid' => $this->nodes[1]->nid),
array('nid' => $this->nodes[2]->nid),
);
$this->assertIdenticalResultset($view, $expected_result, $this->map);
$view->destroy();
}

View File

@@ -108,11 +108,14 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
}
/**
* @param $group_by
* Which group_by function should be used, for example sum or count.
* @param string|null $group_by
* (optional) Which group_by function should be used, for example sum or
* count. If omitted, the aggregation is tested with no group function.
* @param array|null $values
* (optional) Expected values.
*/
function GroupByTestHelper($group_by, $values) {
// Create 2 nodes of type1 and 3 nodes of type2
function GroupByTestHelper($group_by = NULL, $values = NULL) {
// Create 4 nodes of type1 and 3 nodes of type2
$type1 = $this->drupalCreateContentType();
$type2 = $this->drupalCreateContentType();
@@ -136,6 +139,19 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
$output = $view->execute_display();
$this->assertEqual(count($view->result), 2, 'Make sure the count of items is right.');
$results = array();
// There's no need for a function in order to have aggregation.
if (empty($group_by)) {
$types = array($type1->type, $type2->type);
$results = array_map(function ($item) { return $item->node_type; }, $view->result);
sort($types);
sort($results);
$this->assertIdentical($results, $types);
// Exit here with no aggregation function.
return;
}
// Group by nodetype to identify the right count.
foreach ($view->result as $item) {
$results[$item->node_type] = $item->nid;
@@ -144,7 +160,7 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
$this->assertEqual($results[$type2->type], $values[1]);
}
function viewsGroupByViewHelper($group_by) {
function viewsGroupByViewHelper($group_by = NULL) {
$view = new view;
$view->name = 'group_by_count';
$view->description = '';
@@ -164,21 +180,27 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Field: Content: Nid */
$handler->display->display_options['fields']['nid']['id'] = 'nid';
$handler->display->display_options['fields']['nid']['table'] = 'node';
$handler->display->display_options['fields']['nid']['field'] = 'nid';
$handler->display->display_options['fields']['nid']['group_type'] = $group_by;
$handler->display->display_options['fields']['nid']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['nid']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['nid']['alter']['trim'] = 0;
$handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['nid']['alter']['html'] = 0;
$handler->display->display_options['fields']['nid']['hide_empty'] = 0;
$handler->display->display_options['fields']['nid']['empty_zero'] = 0;
$handler->display->display_options['fields']['nid']['link_to_node'] = 0;
// The test view has 2 fields ('nid' and 'type'). Don't add 'nid' when
// having no aggregation function. We just want to aggregate on node type.
if (!empty($group_by)) {
/* Field: Content: Nid */
$handler->display->display_options['fields']['nid']['id'] = 'nid';
$handler->display->display_options['fields']['nid']['table'] = 'node';
$handler->display->display_options['fields']['nid']['field'] = 'nid';
$handler->display->display_options['fields']['nid']['group_type'] = $group_by;
$handler->display->display_options['fields']['nid']['alter']['alter_text'] = 0;
$handler->display->display_options['fields']['nid']['alter']['make_link'] = 0;
$handler->display->display_options['fields']['nid']['alter']['trim'] = 0;
$handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1;
$handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1;
$handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0;
$handler->display->display_options['fields']['nid']['alter']['html'] = 0;
$handler->display->display_options['fields']['nid']['hide_empty'] = 0;
$handler->display->display_options['fields']['nid']['empty_zero'] = 0;
$handler->display->display_options['fields']['nid']['link_to_node'] = 0;
}
/* Field: Content: Type */
$handler->display->display_options['fields']['type']['id'] = 'type';
$handler->display->display_options['fields']['type']['table'] = 'node';
@@ -218,6 +240,10 @@ class ViewsQueryGroupByTest extends ViewsSqlTest {
$this->GroupByTestHelper('max', array(4, 7));
}
function testGroupByNone() {
$this->GroupByTestHelper();
}
public function testGroupByCountOnlyFilters() {
// Check if GROUP BY and HAVING are included when a view
// Doesn't display SUM, COUNT, MAX... functions in SELECT statment

View File

@@ -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.');
}
/**

View File

@@ -5,9 +5,9 @@ core = 7.x
dependencies[] = views
hidden = TRUE
; Information added by Drupal.org packaging script on 2015-02-11
version = "7.x-3.10"
; Information added by Drupal.org packaging script on 2015-04-29
version = "7.x-3.11"
core = "7.x"
project = "views"
datestamp = "1423648085"
datestamp = "1430321048"

View File

@@ -1075,7 +1075,7 @@ function hook_views_query_alter(&$view, &$query) {
// Traverse through the 'where' part of the query.
foreach ($query->where as &$condition_group) {
foreach ($condition_group['conditions'] as &$condition) {
// If this is the part of the query filtering on title, chang the
// If this is the part of the query filtering on title, change the
// condition to filter on node ID.
if ($condition['field'] == 'node.title') {
$condition = array(

View File

@@ -318,9 +318,9 @@ files[] = tests/views_cache.test
files[] = tests/views_view.test
files[] = tests/views_ui.test
; Information added by Drupal.org packaging script on 2015-02-11
version = "7.x-3.10"
; Information added by Drupal.org packaging script on 2015-04-29
version = "7.x-3.11"
core = "7.x"
project = "views"
datestamp = "1423648085"
datestamp = "1430321048"

View File

@@ -7,9 +7,9 @@ dependencies[] = views
files[] = views_ui.module
files[] = plugins/views_wizard/views_ui_base_views_wizard.class.php
; Information added by Drupal.org packaging script on 2015-02-11
version = "7.x-3.10"
; Information added by Drupal.org packaging script on 2015-04-29
version = "7.x-3.11"
core = "7.x"
project = "views"
datestamp = "1423648085"
datestamp = "1430321048"