diff --git a/core/modules/taxonomy/src/Entity/Term.php b/core/modules/taxonomy/src/Entity/Term.php index 0489903873..94a5ade439 100644 --- a/core/modules/taxonomy/src/Entity/Term.php +++ b/core/modules/taxonomy/src/Entity/Term.php @@ -270,7 +270,7 @@ public function getAncestors() { while ($tid = array_shift($search)) { foreach (static::load($tid)->getParents() as $id => $parent) { - if (!empty($parent) && !isset($this->ancestors[$id])) { + if ($parent && !isset($this->ancestors[$id])) { $this->ancestors[$id] = $parent; $search[] = $id; } diff --git a/core/modules/taxonomy/src/Entity/Vocabulary.php b/core/modules/taxonomy/src/Entity/Vocabulary.php index af115ae08a..fcd6dffcb8 100644 --- a/core/modules/taxonomy/src/Entity/Vocabulary.php +++ b/core/modules/taxonomy/src/Entity/Vocabulary.php @@ -184,7 +184,7 @@ public static function postDelete(EntityStorageInterface $storage, array $entiti * @todo Add this to \Drupal\taxonomy\VocabularyInterface in Drupal 9.0.x. * https://www.drupal.org/node/2785681 */ - public static function getTopLevelTids($vids) { + public static function getTopLevelTids(array $vids) { $tids = \Drupal::entityQuery('taxonomy_term') ->condition('vid', $vids, 'IN') ->condition('parent.target_id', 0) diff --git a/core/modules/taxonomy/src/TermStorageInterface.php b/core/modules/taxonomy/src/TermStorageInterface.php index 6b2431b09f..3dda2ce24a 100644 --- a/core/modules/taxonomy/src/TermStorageInterface.php +++ b/core/modules/taxonomy/src/TermStorageInterface.php @@ -43,7 +43,7 @@ public function updateTermHierarchy(EntityInterface $term); * @return \Drupal\taxonomy\TermInterface[] * An array of term objects which are the parents of the term $tid. * - * @deprecated in Drupal 8.2.x, will be removed in Drupal 9.0.0. Use + * @deprecated in Drupal 8.3.x, will be removed in Drupal 9.0.0. Use * \Drupal\taxonomy\Entity\Term::load($tid)->getParents() instead. */ public function loadParents($tid); @@ -57,7 +57,7 @@ public function loadParents($tid); * @return \Drupal\taxonomy\TermInterface[] * An array of term objects which are the ancestors of the term $tid. * - * @deprecated in Drupal 8.2.x, will be removed in Drupal 9.0.0. Use + * @deprecated in Drupal 8.3.x, will be removed in Drupal 9.0.0. Use * \Drupal\taxonomy\Entity\Term::load($tid)->getAncestors() instead. */ public function loadAllParents($tid); @@ -73,7 +73,7 @@ public function loadAllParents($tid); * @return \Drupal\taxonomy\TermInterface[] * An array of term objects that are the children of the term $tid. * - * @deprecated in Drupal 8.2.x, will be removed in Drupal 9.0.0. Use + * @deprecated in Drupal 8.3.x, will be removed in Drupal 9.0.0. Use * \Drupal\taxonomy\Entity\Term::load($tid)->getChildren($vid) instead. */ public function loadChildren($tid, $vid = NULL); diff --git a/core/modules/views/src/EntityViewsData.php b/core/modules/views/src/EntityViewsData.php index 5bce2c101b..61def5acd4 100644 --- a/core/modules/views/src/EntityViewsData.php +++ b/core/modules/views/src/EntityViewsData.php @@ -366,16 +366,18 @@ protected function mapFieldDefinition($table, $field_name, FieldDefinitionInterf $field_schema = $this->getFieldStorageDefinitions()[$field_name]->getSchema(); $field_definition_type = $field_definition->getType(); - // Add all properties to views table data. We need an entry for each // column of each field, with the first one given special treatment. // @todo Introduce concept of the "main" column for a field, rather than // assuming the first one is the main column. See also what the // mapSingleFieldViewsData() method does with $first. + $multiple = (count($field_column_mapping) > 1); $first = TRUE; foreach ($field_column_mapping as $field_column_name => $schema_field_name) { - $table_data[$schema_field_name] = $this->mapSingleFieldViewsData($table, $field_name, $field_definition_type, $field_column_name, $field_schema['columns'][$field_column_name]['type'], $first, $field_definition); - $table_data[$schema_field_name]['entity field'] = $field_name; + $views_field_name = ($multiple) ? $field_name . '__' . $field_column_name : $field_name; + $table_data[$views_field_name] = $this->mapSingleFieldViewsData($table, $field_name, $field_definition_type, $field_column_name, $field_schema['columns'][$field_column_name]['type'], $first, $field_definition); + + $table_data[$views_field_name]['entity field'] = $field_name; $first = FALSE; } } diff --git a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_entity_multivalue_basefield.yml b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_entity_multivalue_basefield.yml index d2ecb577bf..478071dfa7 100644 --- a/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_entity_multivalue_basefield.yml +++ b/core/modules/views/tests/modules/views_test_config/test_views/views.view.test_entity_multivalue_basefield.yml @@ -30,7 +30,7 @@ display: name: id: name table: entity_test_multivalue_basefield__name - field: name_value + field: name plugin_id: field entity_type: entity_test_multivalue_basefield entity_field: name diff --git a/core/modules/views/tests/src/Unit/EntityViewsDataTest.php b/core/modules/views/tests/src/Unit/EntityViewsDataTest.php index 131259e589..acb84e5f1e 100644 --- a/core/modules/views/tests/src/Unit/EntityViewsDataTest.php +++ b/core/modules/views/tests/src/Unit/EntityViewsDataTest.php @@ -527,12 +527,8 @@ public function testBaseTableFields() { $this->assertEquals('users_field_data', $relationship['base']); $this->assertEquals('uid', $relationship['base field']); - // The string field name should be used as the 'entity field' but the actual - // field should reflect what the column mapping is using for multi-value - // base fields NOT just the field name. The actual column name returned from - // mappings in the test mocks is 'value'. - $this->assertStringField($data['entity_test__string']['value']); - $this->assertField($data['entity_test__string']['value'], 'string'); + $this->assertStringField($data['entity_test__string']['string']); + $this->assertField($data['entity_test__string']['string'], 'string'); $this->assertEquals([ 'left_field' => 'id', 'field' => 'entity_id', @@ -686,8 +682,8 @@ public function testDataTableFields() { $this->assertEquals('users_field_data', $relationship['base']); $this->assertEquals('uid', $relationship['base field']); - $this->assertStringField($data['entity_test_mul__string']['value']); - $this->assertField($data['entity_test_mul__string']['value'], 'string'); + $this->assertStringField($data['entity_test_mul__string']['string']); + $this->assertField($data['entity_test_mul__string']['string'], 'string'); $this->assertEquals([ 'left_field' => 'id', 'field' => 'entity_id', @@ -745,7 +741,7 @@ public function testRevisionTableFields() { ['description', ['value' => 'description__value', 'format' => 'description__format']], ['homepage', ['value' => 'homepage']], ['user_id', ['target_id' => 'user_id']], - ['revision_id', ['value' => 'revision_id']], + ['revision_id', ['value' => 'id']], ['string', ['value' => 'value']], ]); $table_mapping->expects($this->any()) @@ -871,8 +867,8 @@ public function testRevisionTableFields() { $this->assertEquals('users_field_data', $relationship['base']); $this->assertEquals('uid', $relationship['base field']); - $this->assertStringField($data['entity_test_mulrev__string']['value']); - $this->assertField($data['entity_test_mulrev__string']['value'], 'string'); + $this->assertStringField($data['entity_test_mulrev__string']['string']); + $this->assertField($data['entity_test_mulrev__string']['string'], 'string'); $this->assertEquals([ 'left_field' => 'id', 'field' => 'entity_id', @@ -883,8 +879,8 @@ public function testRevisionTableFields() { ]], ], $data['entity_test_mulrev__string']['table']['join']['entity_test_mulrev_property_data']); - $this->assertStringField($data['entity_test_mulrev_revision__string']['value']); - $this->assertField($data['entity_test_mulrev_revision__string']['value'], 'string'); + $this->assertStringField($data['entity_test_mulrev_revision__string']['string']); + $this->assertField($data['entity_test_mulrev_revision__string']['string'], 'string'); $this->assertEquals([ 'left_field' => 'revision_id', 'field' => 'entity_id',