Commit ebcca481 authored by webchick's avatar webchick

Issue #2429447 by dawehner, jhodgdon, xjm, jibran: Use data table as views base table, if available

parent 975121d4
......@@ -9,7 +9,7 @@ label: form
module: views
description: ''
tag: ''
base_table: node
base_table: node_field_data
base_field: nid
core: 8.x
display:
......
......@@ -21,7 +21,7 @@ public function getViewsData() {
$data = parent::getViewsData();
$data['block_content']['id']['field']['id'] = 'block_content';
$data['block_content_field_data']['id']['field']['id'] = 'block_content';
$data['block_content_field_data']['info']['field']['id'] = 'block_content';
$data['block_content_field_data']['info']['field']['link_to_entity default'] = TRUE;
......
......@@ -8,7 +8,7 @@ label: test_block_content_view
module: views
description: ''
tag: ''
base_table: block_content
base_table: block_content_field_data
base_field: id
core: 8.x
display:
......@@ -70,7 +70,7 @@ display:
fields:
id:
id: id
table: block_content
table: block_content_field_data
field: id
relationship: none
group_type: group
......@@ -123,7 +123,7 @@ display:
sorts:
id:
id: id
table: block_content
table: block_content_field_data
field: id
relationship: none
group_type: group
......@@ -144,7 +144,7 @@ display:
arguments:
type:
id: type
table: block_content
table: block_content_field_data
field: type
relationship: none
group_type: group
......
......@@ -8,7 +8,7 @@ label: 'Test field filters'
module: views
description: ''
tag: ''
base_table: block_content
base_table: block_content_field_data
base_field: id
core: 8.x
display:
......
......@@ -8,7 +8,7 @@ label: ''
module: views
description: ''
tag: ''
base_table: block_content
base_table: block_content_field_data
base_field: id
core: '8'
display:
......
......@@ -26,7 +26,7 @@ function comment_views_data_alter(&$data) {
continue;
}
$fields = \Drupal::service('comment.manager')->getFields($entity_type_id);
$base_table = $entity_type->getBaseTable();
$base_table = $entity_type->getDataTable() ?: $entity_type->getBaseTable();
$args = array('@entity_type' => $entity_type_id);
if ($fields) {
......
......@@ -9,7 +9,7 @@ label: 'Recent comments'
module: views
description: 'Recent comments.'
tag: default
base_table: comment
base_table: comment_field_data
base_field: cid
core: 8.x
display:
......@@ -208,7 +208,7 @@ display:
entity_field: created
cid:
id: cid
table: comment
table: comment_field_data
field: cid
relationship: none
group_type: group
......
......@@ -20,16 +20,16 @@ class CommentViewsData extends EntityViewsData {
public function getViewsData() {
$data = parent::getViewsData();
$data['comment']['table']['base']['help'] = t('Comments are responses to content.');
$data['comment']['table']['base']['access query tag'] = 'comment_access';
$data['comment_field_data']['table']['base']['help'] = t('Comments are responses to content.');
$data['comment_field_data']['table']['base']['access query tag'] = 'comment_access';
$data['comment']['table']['wizard_id'] = 'comment';
$data['comment_field_data']['table']['wizard_id'] = 'comment';
$data['comment_field_data']['subject']['title'] = t('Title');
$data['comment_field_data']['subject']['help'] = t('The title of the comment.');
$data['comment_field_data']['subject']['field']['id'] = 'comment';
$data['comment']['cid']['field']['id'] = 'comment';
$data['comment_field_data']['cid']['field']['id'] = 'comment';
$data['comment_field_data']['name']['title'] = t('Author');
$data['comment_field_data']['name']['help'] = t("The name of the comment's author. Can be rendered as a link to the author's homepage.");
......@@ -190,7 +190,7 @@ public function getViewsData() {
'relationship' => array(
'title' => $entity_type->getLabel(),
'help' => t('The @entity_type to which the comment is a reply to.', array('@entity_type' => $entity_type->getLabel())),
'base' => $entity_type->getBaseTable(),
'base' => $entity_type->getDataTable() ?: $entity_type->getBaseTable(),
'base field' => $entity_type->getKey('id'),
'relationship field' => 'entity_id',
'id' => 'standard',
......@@ -245,7 +245,7 @@ public function getViewsData() {
// {comment_entity_statistics} for each field as multiple joins between
// the same two tables is not supported.
if (\Drupal::service('comment.manager')->getFields($type)) {
$data['comment_entity_statistics']['table']['join'][$entity_type->getBaseTable()] = array(
$data['comment_entity_statistics']['table']['join'][$entity_type->getDataTable() ?: $entity_type->getBaseTable()] = array(
'type' => 'INNER',
'left_field' => $entity_type->getKey('id'),
'field' => 'entity_id',
......
......@@ -86,7 +86,7 @@ public function query($group_by = FALSE) {
$this->ensureMyTable();
// Use the table definition to correctly add this user ID condition.
if ($this->table != 'comment') {
if ($this->table != 'comment_field_data') {
$subselect = $this->database->select('comment_field_data', 'c');
$subselect->addField('c', 'cid');
$subselect->condition('c.uid', $this->argument);
......
......@@ -20,7 +20,7 @@ class StatisticsLastUpdated extends Date {
public function query() {
$this->ensureMyTable();
$this->node_table = $this->query->ensureTable('node', $this->relationship);
$this->node_table = $this->query->ensureTable('node_field_data', $this->relationship);
$this->field_alias = $this->query->addField(NULL, "GREATEST(" . $this->node_table . ".changed, " . $this->tableAlias . ".last_comment_timestamp)", $this->tableAlias . '_' . $this->field);
}
......
......@@ -18,7 +18,7 @@
* help = @Translation("Display the comment as RSS."),
* theme = "views_view_row_rss",
* register_theme = FALSE,
* base = {"comment"},
* base = {"comment_field_data"},
* display_types = {"feed"}
* )
*/
......@@ -27,7 +27,7 @@ class Rss extends RssPluginBase {
/**
* {@inheritdoc}
*/
protected $base_table = 'comment';
protected $base_table = 'comment_field_data';
/**
* {@inheritdoc}
......
......@@ -19,7 +19,7 @@
*
* @ViewsWizard(
* id = "comment",
* base_table = "comment",
* base_table = "comment_field_data",
* title = @Translation("Comments")
* )
*/
......
......@@ -14,7 +14,7 @@ label: 'Comments by node'
module: views
description: ''
tag: ''
base_table: comment
base_table: comment_field_data
base_field: cid
core: 8.x
display:
......
......@@ -10,7 +10,7 @@ label: test_comment_row
module: views
description: ''
tag: ''
base_table: comment
base_table: comment_field_data
base_field: cid
core: 8.x
display:
......
......@@ -10,7 +10,7 @@ label: test_comment_rss
module: views
description: ''
tag: ''
base_table: comment
base_table: comment_field_data
base_field: cid
core: 8.x
display:
......
......@@ -11,7 +11,7 @@ label: test_comment_user_uid
module: comment_test_views
description: ''
tag: default
base_table: node
base_table: node_field_data
base_field: nid
core: '8'
display:
......@@ -41,7 +41,7 @@ display:
nid:
field: nid
id: nid
table: node
table: node_field_data
plugin_id: node
entity_type: node
entity_field: nid
......
......@@ -10,7 +10,7 @@ label: 'Test field filters'
module: views
description: ''
tag: ''
base_table: comment
base_table: comment_field_data
base_field: cid
core: 8.x
display:
......
......@@ -9,7 +9,7 @@ label: People
module: views
description: ''
tag: ''
base_table: users
base_table: users_field_data
base_field: uid
core: 8.x
display:
......@@ -75,7 +75,7 @@ display:
filters:
uid_raw:
id: uid_raw
table: users
table: users_field_data
field: uid_raw
operator: '!='
value:
......
......@@ -118,7 +118,7 @@ public function testSelectionHandlerRelationship() {
$view->displayHandlers->get('default')->setOption('relationships', array(
'test_relationship' => array(
'id' => 'uid',
'table' => 'users',
'table' => 'node_field_data',
'field' => 'uid',
),
));
......@@ -127,7 +127,7 @@ public function testSelectionHandlerRelationship() {
$view->displayHandlers->get('default')->setOption('filters', array(
'uid' => array(
'id' => 'uid',
'table' => 'users',
'table' => 'users_field_data',
'field' => 'uid',
'relationship' => 'test_relationship',
)
......
......@@ -11,7 +11,7 @@ label: 'Entity reference'
module: entity_reference_test
description: ''
tag: ''
base_table: node
base_table: node_field_data
base_field: nid
core: '8'
display:
......
......@@ -77,28 +77,28 @@ public function getViewsData() {
'field' => 'fid',
'left_field' => 'fid',
),
// Link ourself to the {node} table
// Link ourself to the {node_field_data} table
// so we can provide node->file relationships.
'node' => array(
'node_field_data' => array(
'field' => 'id',
'left_field' => 'nid',
'extra' => array(array('field' => 'type', 'value' => 'node')),
),
// Link ourself to the {users} table
// Link ourself to the {users_field_data} table
// so we can provide user->file relationships.
'users' => array(
'users_field_data' => array(
'field' => 'id',
'left_field' => 'uid',
'extra' => array(array('field' => 'type', 'value' => 'user')),
),
// Link ourself to the {comment} table
// Link ourself to the {comment_field_data} table
// so we can provide comment->file relationships.
'comment' => array(
'field' => 'id',
'left_field' => 'cid',
'extra' => array(array('field' => 'type', 'value' => 'comment')),
),
// Link ourself to the {taxonomy_term_data} table
// Link ourself to the {taxonomy_term_field_data} table
// so we can provide taxonomy_term->file relationships.
'taxonomy_term_data' => array(
'field' => 'id',
......@@ -119,12 +119,12 @@ public function getViewsData() {
'help' => t('Content that is associated with this file, usually because this file is in a field on the content.'),
// Only provide this field/relationship/etc.,
// when the 'file_managed' base table is present.
'skip base' => array('node', 'node_field_revision', 'users', 'comment', 'taxonomy_term_data'),
'skip base' => array('node_field_data', 'node_field_revision', 'users_field_data', 'comment_field_data', 'taxonomy_term_field_data'),
'real field' => 'id',
'relationship' => array(
'title' => t('Content'),
'label' => t('Content'),
'base' => 'node',
'base' => 'node_field_data',
'base field' => 'nid',
'relationship field' => 'id',
'extra' => array(array('table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'node')),
......@@ -135,7 +135,7 @@ public function getViewsData() {
'help' => t('A file that is associated with this node, usually because it is in a field on the node.'),
// Only provide this field/relationship/etc.,
// when the 'node' base table is present.
'skip base' => array('file_managed', 'users', 'comment', 'taxonomy_term_data'),
'skip base' => array('file_managed', 'users_field_data', 'comment_field_data', 'taxonomy_term_field_data'),
'real field' => 'fid',
'relationship' => array(
'title' => t('File'),
......@@ -152,7 +152,7 @@ public function getViewsData() {
'help' => t('A user that is associated with this file, usually because this file is in a field on the user.'),
// Only provide this field/relationship/etc.,
// when the 'file_managed' base table is present.
'skip base' => array('node', 'node_field_revision', 'users', 'comment', 'taxonomy_term_data'),
'skip base' => array('node_field_data', 'node_field_revision', 'users_field_data', 'comment_field_data', 'taxonomy_term_field_data'),
'real field' => 'id',
'relationship' => array(
'title' => t('User'),
......@@ -168,7 +168,7 @@ public function getViewsData() {
'help' => t('A file that is associated with this user, usually because it is in a field on the user.'),
// Only provide this field/relationship/etc.,
// when the 'users' base table is present.
'skip base' => array('file_managed', 'node', 'node_field_revision', 'comment', 'taxonomy_term_data'),
'skip base' => array('file_managed', 'node_field_data', 'node_field_revision', 'comment_field_data', 'taxonomy_term_field_data'),
'real field' => 'fid',
'relationship' => array(
'title' => t('File'),
......@@ -185,12 +185,12 @@ public function getViewsData() {
'help' => t('A comment that is associated with this file, usually because this file is in a field on the comment.'),
// Only provide this field/relationship/etc.,
// when the 'file_managed' base table is present.
'skip base' => array('node', 'node_field_revision', 'users', 'comment', 'taxonomy_term_data'),
'skip base' => array('node_field_data', 'node_field_revision', 'users_field_data', 'comment_field_data', 'taxonomy_term_field_data'),
'real field' => 'id',
'relationship' => array(
'title' => t('Comment'),
'label' => t('Comment'),
'base' => 'comment',
'base' => 'comment_field_data',
'base field' => 'cid',
'relationship field' => 'id',
'extra' => array(array('table' => 'file_usage', 'field' => 'type', 'operator' => '=', 'value' => 'comment')),
......@@ -201,7 +201,7 @@ public function getViewsData() {
'help' => t('A file that is associated with this comment, usually because it is in a field on the comment.'),
// Only provide this field/relationship/etc.,
// when the 'comment' base table is present.
'skip base' => array('file_managed', 'node', 'node_field_revision', 'users', 'taxonomy_term_data'),
'skip base' => array('file_managed', 'node_field_data', 'node_field_revision', 'users_field_data', 'taxonomy_term_field_data'),
'real field' => 'fid',
'relationship' => array(
'title' => t('File'),
......@@ -218,7 +218,7 @@ public function getViewsData() {
'help' => t('A taxonomy term that is associated with this file, usually because this file is in a field on the taxonomy term.'),
// Only provide this field/relationship/etc.,
// when the 'file_managed' base table is present.
'skip base' => array('node', 'node_field_revision', 'users', 'comment', 'taxonomy_term_data'),
'skip base' => array('node_field_data', 'node_field_revision', 'users_field_data', 'comment_field_data', 'taxonomy_term_field_data'),
'real field' => 'id',
'relationship' => array(
'title' => t('Taxonomy Term'),
......@@ -234,7 +234,7 @@ public function getViewsData() {
'help' => t('A file that is associated with this taxonomy term, usually because it is in a field on the taxonomy term.'),
// Only provide this field/relationship/etc.,
// when the 'taxonomy_term_data' base table is present.
'skip base' => array('file_managed', 'node', 'node_field_revision', 'users', 'comment'),
'skip base' => array('file_managed', 'node_field_data', 'node_field_revision', 'users_field_data', 'comment_field_data'),
'real field' => 'fid',
'relationship' => array(
'title' => t('File'),
......
......@@ -9,7 +9,7 @@ label: test_file_user_file_data
module: views
description: ''
tag: ''
base_table: users
base_table: users_field_data
base_field: uid
core: 8.x
display:
......
......@@ -19,7 +19,7 @@ function history_views_data() {
// Explain how this table joins to others.
$data['history']['table']['join'] = array(
// Directly links to node table.
'node' => array(
'node_field_data' => array(
'table' => 'history',
'left_field' => 'nid',
'field' => 'nid',
......
......@@ -9,7 +9,7 @@ label: test_image_user_image_data
module: views
description: ''
tag: ''
base_table: users
base_table: users_field_data
base_field: uid
core: 8.x
display:
......
......@@ -8,7 +8,7 @@ label: Archive
module: node
description: 'All content, by month.'
tag: default
base_table: node
base_table: node_field_data
base_field: nid
core: '8'
display:
......
......@@ -9,7 +9,7 @@ label: Content
module: node
description: 'Find and manage content.'
tag: default
base_table: node
base_table: node_field_data
base_field: nid
core: 8.x
display:
......
......@@ -9,7 +9,7 @@ label: 'Recent content'
module: node
description: 'Recent content.'
tag: default
base_table: node
base_table: node_field_data
base_field: nid
core: 8.x
display:
......
......@@ -9,7 +9,7 @@ label: Frontpage
module: node
description: 'All content promoted to the front page.'
tag: default
base_table: node
base_table: node_field_data
base_field: nid
core: 8.x
display:
......
......@@ -9,7 +9,7 @@ label: Glossary
module: node
description: 'All content, by letter.'
tag: default
base_table: node
base_table: node_field_data
base_field: nid
core: '8'
display:
......
......@@ -20,12 +20,12 @@ class NodeViewsData extends EntityViewsData {
public function getViewsData() {
$data = parent::getViewsData();
$data['node']['table']['base']['weight'] = -10;
$data['node']['table']['base']['access query tag'] = 'node_access';
$data['node']['table']['wizard_id'] = 'node';
$data['node_field_data']['table']['base']['weight'] = -10;
$data['node_field_data']['table']['base']['access query tag'] = 'node_access';
$data['node_field_data']['table']['wizard_id'] = 'node';
$data['node']['nid']['field']['id'] = 'node';
$data['node']['nid']['field']['argument'] = [
$data['node_field_data']['nid']['field']['id'] = 'node';
$data['node_field_data']['nid']['field']['argument'] = [
'id' => 'node_nid',
'name field' => 'title',
'numeric' => TRUE,
......@@ -255,41 +255,41 @@ public function getViewsData() {
$data['node_field_data']['uid_revision']['filter']['id'] = 'node_uid_revision';
$data['node_field_data']['uid_revision']['argument']['id'] = 'node_uid_revision';
$data['node_revision']['table']['wizard_id'] = 'node_revision';
$data['node_field_revision']['table']['wizard_id'] = 'node_revision';
// Advertise this table as a possible base table.
$data['node_revision']['table']['base']['help'] = t('Content revision is a history of changes to content.');
$data['node_revision']['table']['base']['defaults']['title'] = 'title';
$data['node_field_revision']['table']['base']['help'] = t('Content revision is a history of changes to content.');
$data['node_field_revision']['table']['base']['defaults']['title'] = 'title';
$data['node_revision']['nid']['argument'] = [
$data['node_field_revision']['nid']['argument'] = [
'id' => 'node_nid',
'numeric' => TRUE,
];
// @todo the NID field needs different behaviour on revision/non-revision
// tables. It would be neat if this could be encoded in the base field
// definition.
$data['node_revision']['nid']['relationship']['id'] = 'standard';
$data['node_revision']['nid']['relationship']['base'] = 'node';
$data['node_revision']['nid']['relationship']['base field'] = 'nid';
$data['node_revision']['nid']['relationship']['title'] = t('Content');
$data['node_revision']['nid']['relationship']['label'] = t('Get the actual content from a content revision.');
$data['node_field_revision']['nid']['relationship']['id'] = 'standard';
$data['node_field_revision']['nid']['relationship']['base'] = 'node_field_data';
$data['node_field_revision']['nid']['relationship']['base field'] = 'nid';
$data['node_field_revision']['nid']['relationship']['title'] = t('Content');
$data['node_field_revision']['nid']['relationship']['label'] = t('Get the actual content from a content revision.');
$data['node_revision']['vid'] = array(
$data['node_field_revision']['vid'] = array(
'argument' => array(
'id' => 'node_vid',
'numeric' => TRUE,
),
'relationship' => array(
'id' => 'standard',
'base' => 'node',
'base' => 'node_field_data',
'base field' => 'vid',
'title' => t('Content'),
'label' => t('Get the actual content from a content revision.'),
),
) + $data['node_revision']['vid'];
$data['node_revision']['langcode']['help'] = t('The language the original content is in.');
$data['node_revision']['langcode']['field']['id'] = 'node_language';
$data['node_field_revision']['langcode']['help'] = t('The language the original content is in.');
$data['node_field_revision']['langcode']['field']['id'] = 'node_language';
$data['node_revision']['revision_log']['field']['id'] = 'xss';
......@@ -298,8 +298,8 @@ public function getViewsData() {
$data['node_field_revision']['table']['wizard_id'] = 'node_field_revision';
$data['node_field_revision']['table']['join']['node']['left_field'] = 'vid';
$data['node_field_revision']['table']['join']['node']['field'] = 'vid';
$data['node_field_revision']['table']['join']['node_field_data']['left_field'] = 'vid';
$data['node_field_revision']['table']['join']['node_field_data']['field'] = 'vid';
$data['node_field_revision']['status']['field']['output formats'] = [
'published-notpublished' => [t('Published'), t('Not published')],
......@@ -346,7 +346,7 @@ public function getViewsData() {
// For other base tables, explain how we join.
$data['node_access']['table']['join'] = array(
'node' => array(
'node_field_data' => array(
'left_field' => 'nid',
'field' => 'nid',
),
......@@ -379,11 +379,10 @@ public function getViewsData() {
// Use a Views table alias to allow other modules to use this table too,
// if they use the search index.
$data['node_search_index']['table']['join'] = array(
'node' => array(
'node_field_data' => array(
'left_field' => 'nid',
'field' => 'sid',
'table' => 'search_index',
'left_table' => 'node_field_data',
'extra' => "node_search_index.type = 'node_search' AND node_search_index.langcode = node_field_data.langcode",
)
);
......
......@@ -33,7 +33,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
// Don't add the additional fields to groupby
if (!empty($this->options['link_to_node'])) {
$this->additional_fields['nid'] = array('table' => 'node', 'field' => 'nid');
$this->additional_fields['nid'] = array('table' => 'node_field_data', 'field' => 'nid');
}
}
......
......@@ -29,7 +29,7 @@ class RevisionLink extends Link {
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
$this->additional_fields['node_vid'] = array('table' => 'node_revision', 'field' => 'vid');
$this->additional_fields['node_vid'] = array('table' => 'node_field_revision', 'field' => 'vid');
}
/**
......
......@@ -24,14 +24,14 @@
* help = @Translation("Display the content with standard node view."),
* theme = "views_view_row_rss",
* register_theme = FALSE,
* base = {"node"},
* base = {"node_field_data"},
* display_types = {"feed"}