diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php index 3361010..fc9c154 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -179,7 +179,7 @@ protected function initTableLayout() { if ($this->entityType->isRevisionable()) { $this->revisionKey = $this->entityType->getKey('revision') ?: 'revision_id'; } - if ($translatable = $this->entityType->isTranslatable()) { + if ($this->entityType->isTranslatable()) { $this->langcodeKey = $this->entityType->getKey('langcode'); $this->defaultLangcodeKey = $this->entityType->getKey('default_langcode'); } @@ -251,7 +251,7 @@ public function getTableMapping(array $storage_definitions = NULL) { // and new storage schema, we compute the table mapping without caching. if (!isset($this->tableMapping) || $storage_definitions) { $definitions = $storage_definitions ?: $this->entityManager->getFieldStorageDefinitions($this->entityTypeId); - $table_mapping = new DefaultTableMapping($this->entityType, $definitions); + $table_mapping = new DefaultTableMapping($this->entityType, is_array($definitions) ? $definitions : []); // Cache the computed table mapping only if we are using our internal // storage definitions. diff --git a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php index 5ec25d1..361ff17 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php @@ -154,7 +154,7 @@ public function providerTestGetBaseTable() { // Test that the entity type's base table is used, if provided. ['entity_test', 'entity_test'], // Test that the storage falls back to the entity type ID. - [[], 'entity_test'], + [NULL, 'entity_test'], ]; } @@ -173,7 +173,7 @@ public function providerTestGetBaseTable() { * @dataProvider providerTestGetRevisionTable */ public function testGetRevisionTable($revision_table, $expected) { - $this->entityType->expects($this->any()) + $this->entityType->expects($this->exactly(3)) ->method('isRevisionable') ->will($this->returnValue(TRUE)); $this->entityType->expects($this->once()) @@ -214,12 +214,15 @@ public function providerTestGetRevisionTable() { * @covers ::getDataTable */ public function testGetDataTable() { - $this->entityType->expects($this->once()) + $this->entityType->expects($this->exactly(3)) ->method('isTranslatable') ->will($this->returnValue(TRUE)); $this->entityType->expects($this->exactly(1)) ->method('getDataTable') ->will($this->returnValue('entity_test_field_data')); + $this->entityType->expects($this->any()) + ->method('getRevisionMetadataKeys') + ->willReturn([]); $this->setUpEntityStorage(); @@ -241,10 +244,10 @@ public function testGetDataTable() { * @dataProvider providerTestGetRevisionDataTable */ public function testGetRevisionDataTable($revision_data_table, $expected) { - $this->entityType->expects($this->once()) + $this->entityType->expects($this->exactly(3)) ->method('isRevisionable') ->will($this->returnValue(TRUE)); - $this->entityType->expects($this->once()) + $this->entityType->expects($this->exactly(3)) ->method('isTranslatable') ->will($this->returnValue(TRUE)); $this->entityType->expects($this->exactly(1)) @@ -253,6 +256,9 @@ public function testGetRevisionDataTable($revision_data_table, $expected) { $this->entityType->expects($this->once()) ->method('getRevisionDataTable') ->will($this->returnValue($revision_data_table)); + $this->entityType->expects($this->any()) + ->method('getRevisionMetadataKeys') + ->willReturn([]); $this->setUpEntityStorage(); @@ -526,7 +532,7 @@ public function testGetTableMappingRevisionable(array $entity_keys) { 'uuid' => $entity_keys['uuid'], ]; - $this->entityType->expects($this->exactly(2)) + $this->entityType->expects($this->exactly(3)) ->method('isRevisionable') ->will($this->returnValue(TRUE)); $this->entityType->expects($this->any()) @@ -599,7 +605,7 @@ public function testGetTableMappingRevisionableWithFields(array $entity_keys) { $field_names = array_merge($field_names, $revisionable_field_names); $this->fieldDefinitions += $this->mockFieldDefinitions(array_merge($revisionable_field_names, array_values($revision_metadata_field_names)), ['isRevisionable' => TRUE]); - $this->entityType->expects($this->exactly(2)) + $this->entityType->expects($this->exactly(3)) ->method('isRevisionable') ->will($this->returnValue(TRUE)); $this->entityType->expects($this->any())