Follow up for #1498674: Refactor node properties to multilingual

Problem/Motivation

Simplify code

In 1498674 was the @todo

     // @todo: Wouldn't it be possible to use $this->base_table and no if here?

On the line in the patch in comment #303:
3698

The line of the final patch might change but that info might help to find them.

For example,

     // @todo: Wouldn't it be possible to use $this->base_table and no if here?
-    if ($view->storage->get('base_table') == 'node_revision') {
-      $this->additional_fields['nid'] = array('table' => 'node_revision', 'field' => 'nid');
+    if ($view->storage->get('base_table') == 'node_field_revision') {
+      $this->additional_fields['nid'] = array('table' => 'node_field_revision', 'field' => 'nid');
     }
     else {
       $this->additional_fields['nid'] = array('table' => 'node', 'field' => 'nid');

Proposed resolution

use $this->base_table and remove the if

Remaining Tasks

  • use git blame to identify the issue that added this @todo and link to it, and link it back to here.

User interface changes

No.

API changes

No.

Files: 
CommentFileSizeAuthor
#4 2004376-4.patch1.04 KBamateescu
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 87,070 pass(es).
[ View ]

Comments

herom’s picture

here's the commit that added the @todo. unfortunately, there's no issue.

amateescu’s picture

Issue summary:View changes
Status:Active» Needs review
StatusFileSize
new1.06 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 87,032 pass(es).
[ View ]

Let's see if anything breaks.

dawehner’s picture

+++ b/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php
@@ -67,13 +67,7 @@ public static function create(ContainerInterface $container, array $configuratio
-    // @todo: Wouldn't it be possible to use $this->base_table and no if here?
-    if ($view->storage->get('base_table') == 'node_field_revision') {
-      $this->additional_fields['nid'] = array('table' => 'node_field_revision', 'field' => 'nid');
-    }
-    else {
-      $this->additional_fields['nid'] = array('table' => 'node', 'field' => 'nid');
-    }
+    $this->additional_fields['nid'] = array('table' => $view->storage->get('base_table'), 'field' => 'nid');
   }

I would honestly prefer $this->table, given that we might change from 'node' to 'node_field_data' at some point.

amateescu’s picture

StatusFileSize
new1.04 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 87,070 pass(es).
[ View ]
new814 bytes

You got it.