Commit cdd12a90 authored by alexpott's avatar alexpott

Issue #2455125 by mpdonadio, rteijeiro, jhodgdon, dawehner: Update...

Issue #2455125 by mpdonadio, rteijeiro, jhodgdon, dawehner: Update EntityViewsData use of generic timestamp to use Field API formatter
parent e50271a3
......@@ -79,7 +79,12 @@ display:
table: aggregator_item
field: timestamp
id: timestamp
plugin_id: date
type: timestamp
settings:
date_format: medium
custom_date_format: ''
timezone: ''
plugin_id: field
entity_type: aggregator_item
entity_field: timestamp
author:
......
......@@ -290,12 +290,14 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: true
entity_type: block_content
entity_field: changed
type: timestamp
settings:
date_format: short
custom_date_format: ''
timezone: ''
entity_type: block_content
entity_field: changed
plugin_id: date
plugin_id: field
operations:
id: operations
table: block_content
......
......@@ -119,7 +119,7 @@ display:
table: comment_field_data
field: changed
relationship: none
plugin_id: date
plugin_id: field
group_type: group
admin_label: ''
label: ''
......@@ -163,9 +163,11 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: true
date_format: 'time ago'
custom_date_format: ''
timezone: ''
type: timestamp_ago
settings:
future_format: '@interval hence'
past_format: '@interval ago'
granularity: 2
entity_type: comment
entity_field: changed
filters:
......
......@@ -246,10 +246,12 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: true
type: timestamp
settings:
date_format: long
custom_date_format: ''
timezone: ''
plugin_id: date
plugin_id: field
comment_body:
id: comment_body
table: comment__comment_body
......
......@@ -448,10 +448,12 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: true
type: timestamp
settings:
date_format: medium
custom_date_format: ''
timezone: ''
plugin_id: date
plugin_id: field
entity_type: file
entity_field: created
changed:
......@@ -502,10 +504,12 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: true
type: timestamp
settings:
date_format: medium
custom_date_format: ''
timezone: ''
plugin_id: date
plugin_id: field
entity_type: file
entity_field: changed
count:
......
......@@ -294,10 +294,12 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: true
type: timestamp
settings:
date_format: short
custom_date_format: ''
timezone: ''
plugin_id: date
plugin_id: field
entity_type: node
entity_field: changed
operations:
......
......@@ -172,8 +172,12 @@ display:
table: node_field_data
field: changed
label: 'Last update'
type: timestamp
settings:
date_format: long
plugin_id: date
custom_date_format: ''
timezone: ''
plugin_id: field
relationship: none
group_type: group
admin_label: ''
......@@ -217,8 +221,6 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: true
custom_date_format: ''
timezone: ''
entity_type: node
entity_field: changed
arguments:
......
......@@ -84,7 +84,11 @@ protected function defaultDisplayOptions() {
$display_options['fields']['changed']['alter']['html'] = FALSE;
$display_options['fields']['changed']['hide_empty'] = FALSE;
$display_options['fields']['changed']['empty_zero'] = FALSE;
$display_options['fields']['changed']['plugin_id'] = 'date';
$display_options['fields']['changed']['plugin_id'] = 'field';
$display_options['fields']['changed']['type'] = 'timestamp';
$display_options['fields']['changed']['settings']['date_format'] = 'medium';
$display_options['fields']['changed']['settings']['custom_date_format'] = '';
$display_options['fields']['changed']['settings']['timezone'] = '';
/* Field: Content revision: Title */
$display_options['fields']['title']['id'] = 'title';
......
......@@ -57,7 +57,12 @@ display:
id: created
table: views_test_data
field: created
plugin_id: date
type: timestamp
settings:
date_format: medium
custom_date_format: ''
timezone: ''
plugin_id: field
sorts:
created:
id: created
......
<?php
/**
* @file
* Contains database additions to drupal-8.bare.standard.php.gz for testing the
* upgrade path of https://www.drupal.org/node/2455125.
*/
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Structure of a view with timestamp fields.
$views_configs = [];
$views_configs[] = \Drupal\Component\Serialization\Yaml::decode(file_get_contents(__DIR__ . '/drupal-8.views-entity-views-data-2455125.yml'));
foreach ($views_configs as $views_config) {
$connection->insert('config')
->fields(array(
'collection',
'name',
'data',
))
->values(array(
'collection' => '',
'name' => 'views.view.' . $views_config['id'],
'data' => serialize($views_config),
))
->execute();
}
uuid: e693b165-0e14-4dee-9909-9f0892037c23
langcode: en
status: true
dependencies:
module:
- user
id: update_test
label: 'Update Test'
module: views
description: ''
tag: ''
base_table: users_field_data
base_field: uid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: perm
options:
perm: 'access user profiles'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: none
options:
items_per_page: 0
offset: 0
style:
type: default
row:
type: fields
fields:
name:
id: name
table: users_field_data
field: name
entity_type: user
entity_field: name
label: ''
alter:
alter_text: false
make_link: false
absolute: false
trim: false
word_boundary: false
ellipsis: false
strip_tags: false
html: false
hide_empty: false
empty_zero: false
plugin_id: field
relationship: none
group_type: group
admin_label: ''
exclude: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_alter_empty: true
click_sort_column: value
type: user_name
settings: { }
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
created:
id: created
table: users_field_data
field: created
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
date_format: long
custom_date_format: ''
timezone: Africa/Abidjan
entity_type: user
entity_field: created
plugin_id: date
created_1:
id: created_1
table: users_field_data
field: created
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
date_format: 'raw time ago'
custom_date_format: ''
timezone: ''
entity_type: user
entity_field: created
plugin_id: date
created_2:
id: created_2
table: users_field_data
field: created
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
date_format: 'time ago'
custom_date_format: ''
timezone: ''
entity_type: user
entity_field: created
plugin_id: date
filters: { }
sorts: { }
title: 'Update Test'
header: { }
footer: { }
empty: { }
relationships: { }
arguments: { }
display_extenders: { }
cache_metadata:
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- user.permissions
cacheable: false
block_1:
display_plugin: block
id: block_1
display_title: Block
position: 1
display_options:
display_extenders: { }
allow:
items_per_page: false
cache_metadata:
contexts:
- 'languages:language_content'
- 'languages:language_interface'
- user.permissions
cacheable: false
......@@ -396,10 +396,12 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: true
date_format: 'raw time ago'
custom_date_format: ''
timezone: ''
plugin_id: date
type: timestamp_ago
settings:
future_format: '@interval'
past_format: '@interval'
granularity: 2
plugin_id: field
entity_type: user
entity_field: created
access:
......@@ -450,10 +452,12 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: true
date_format: 'time ago'
custom_date_format: ''
timezone: ''
plugin_id: date
type: timestamp_ago
settings:
future_format: '@interval hence'
past_format: '@interval ago'
granularity: 2
plugin_id: field
entity_type: user
entity_field: access
operations:
......
......@@ -38,8 +38,12 @@ display:
table: users_field_data
field: changed
label: 'Updated date'
plugin_id: field
type: timestamp
settings:
date_format: html_date
plugin_id: date
custom_date_format: ''
timezone: ''
entity_type: user
entity_field: changed
filters: { }
......
......@@ -353,7 +353,7 @@ protected function mapSingleFieldViewsData($table, $field_name, $field_type, $co
case 'timestamp':
case 'created':
case 'changed':
$views_field['field']['id'] = 'date';
$views_field['field']['id'] = 'field';
$views_field['argument']['id'] = 'date';
$views_field['filter']['id'] = 'date';
$views_field['sort']['id'] = 'date';
......
......@@ -74,6 +74,7 @@ public function testGlossaryView() {
$this->assertPageCacheContextsAndTags(
$url,
[
'timezone',
'languages:' . LanguageInterface::TYPE_CONTENT,
'languages:' . LanguageInterface::TYPE_INTERFACE,
'theme',
......
<?php
/**
* @file
* Contains \Drupal\views\Tests\Update\EntityViewsDataUpdateTest.
*/
namespace Drupal\views\Tests\Update;
use Drupal\system\Tests\Update\UpdatePathTestBase;
use Drupal\views\Views;
/**
* Tests the upgrade path for views field plugins.
*
* @see https://www.drupal.org/node/2455125
*
* @group Update
*/
class EntityViewsDataUpdateTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.views-entity-views-data-2455125.php',
];
parent::setUp();
}
/**
* Tests that field plugins are updated properly.
*/
public function testUpdateHookN() {
$this->runUpdates();
// Load and initialize our test view.
$view = Views::getView('update_test');
$view->initHandlers();
// Extract the fields from the test view that were updated.
/** @var \Drupal\views\Plugin\views\field\Field $field */
$created = $view->field['created'];
/** @var \Drupal\views\Plugin\views\field\Field $field */
$created_1 = $view->field['created_1'];
/** @var \Drupal\views\Plugin\views\field\Field $field */
$created_2 = $view->field['created_2'];
// Make sure the plugins were converted from date to field.
$this->assertEqual($created->getPluginId(), 'field', 'created has correct plugin_id');
$this->assertEqual($created_1->getPluginId(), 'field', 'created has correct plugin_id');
$this->assertEqual($created_2->getPluginId(), 'field', 'created has correct plugin_id');
// Check options on 'created'.
$options = $created->options;
$this->assertEqual($options['type'], 'timestamp');
$this->assertFalse(array_key_exists('date_format', $options));
$this->assertFalse(array_key_exists('custom_date_format', $options));
$this->assertFalse(array_key_exists('timezone', $options));
$this->assertEqual($options['settings']['date_format'], 'long');
$this->assertEqual($options['settings']['custom_date_format'], '');
$this->assertEqual($options['settings']['timezone'], 'Africa/Abidjan');
// Check options on 'created'.
$options = $created_1->options;
$this->assertEqual($options['type'], 'timestamp_ago');
$this->assertFalse(array_key_exists('date_format', $options));
$this->assertFalse(array_key_exists('custom_date_format', $options));
$this->assertFalse(array_key_exists('timezone', $options));
$this->assertEqual($options['settings']['future_format'], '@interval');
$this->assertEqual($options['settings']['past_format'], '@interval');
$this->assertEqual($options['settings']['granularity'], 2);
// Check options on 'created'.
$options = $created_2->options;
$this->assertEqual($options['type'], 'timestamp_ago');
$this->assertFalse(array_key_exists('date_format', $options));
$this->assertFalse(array_key_exists('custom_date_format', $options));
$this->assertFalse(array_key_exists('timezone', $options));
$this->assertEqual($options['settings']['future_format'], '@interval hence');
$this->assertEqual($options['settings']['past_format'], '@interval ago');
$this->assertEqual($options['settings']['granularity'], 2);
}
}
......@@ -29,7 +29,12 @@ display:
table: views_test_data
field: created
label: created
plugin_id: date
plugin_id: field
type: timestamp
settings:
date_format: medium
custom_date_format: ''
timezone: ''
access:
type: none
cache:
......
......@@ -62,7 +62,12 @@ display:
field: created
id: created
table: node_field_data
plugin_id: date
plugin_id: field
type: timestamp
settings:
date_format: medium
custom_date_format: ''
timezone: ''
entity_type: node
entity_field: created
nid:
......