X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FEntity%2FQuery%2FSql%2FTables.php;h=1f99d0f7716b74c734e6ffb99d7fa750964fee5a;hb=1c1cb0980bfa6caf0c24cce671b6bb541dc87583;hp=0c54dc45884f494c8e1c101b5021dddfa7951e87;hpb=af6d1fb995500ae68849458ee10d66abbdcfb252;p=yaffs-website diff --git a/web/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php b/web/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php index 0c54dc458..1f99d0f77 100644 --- a/web/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php +++ b/web/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php @@ -94,9 +94,11 @@ class Tables implements TablesInterface { $specifier = $specifiers[$key]; if (isset($field_storage_definitions[$specifier])) { $field_storage = $field_storage_definitions[$specifier]; + $column = $field_storage->getMainPropertyName(); } else { $field_storage = FALSE; + $column = NULL; } // If there is revision support, only the current revisions are being @@ -121,8 +123,6 @@ class Tables implements TablesInterface { // Check whether this field is stored in a dedicated table. if ($field_storage && $table_mapping->requiresDedicatedTableStorage($field_storage)) { $delta = NULL; - // Find the field column. - $column = $field_storage->getMainPropertyName(); if ($key < $count) { $next = $specifiers[$key + 1]; @@ -176,10 +176,6 @@ class Tables implements TablesInterface { } $table = $this->ensureFieldTable($index_prefix, $field_storage, $type, $langcode, $base_table, $entity_id_field, $field_id_field, $delta); $sql_column = $table_mapping->getFieldColumnName($field_storage, $column); - $property_definitions = $field_storage->getPropertyDefinitions(); - if (isset($property_definitions[$column])) { - $this->caseSensitiveFields[$field] = $property_definitions[$column]->getSetting('case_sensitive'); - } } // The field is stored in a shared table. else { @@ -188,6 +184,7 @@ class Tables implements TablesInterface { // finds the property first. The data table is preferred, which is why // it gets added before the base table. $entity_tables = []; + $revision_table = NULL; if ($all_revisions && $field_storage && $field_storage->isRevisionable()) { $data_table = $entity_type->getRevisionDataTable(); $entity_base_table = $entity_type->getRevisionTable(); @@ -195,11 +192,18 @@ class Tables implements TablesInterface { else { $data_table = $entity_type->getDataTable(); $entity_base_table = $entity_type->getBaseTable(); + + if ($field_storage && $field_storage->isRevisionable() && in_array($field_storage->getName(), $entity_type->getRevisionMetadataKeys())) { + $revision_table = $entity_type->getRevisionTable(); + } } if ($data_table) { $this->sqlQuery->addMetaData('simple_query', FALSE); $entity_tables[$data_table] = $this->getTableMapping($data_table, $entity_type_id); } + if ($revision_table) { + $entity_tables[$revision_table] = $this->getTableMapping($revision_table, $entity_type_id); + } $entity_tables[$entity_base_table] = $this->getTableMapping($entity_base_table, $entity_type_id); $sql_column = $specifier; @@ -239,18 +243,17 @@ class Tables implements TablesInterface { } $table = $this->ensureEntityTable($index_prefix, $sql_column, $type, $langcode, $base_table, $entity_id_field, $entity_tables); + } - // If there is a field storage (some specifiers are not), check for case - // sensitivity. - if ($field_storage) { - $column = $field_storage->getMainPropertyName(); - $base_field_property_definitions = $field_storage->getPropertyDefinitions(); - if (isset($base_field_property_definitions[$column])) { - $this->caseSensitiveFields[$field] = $base_field_property_definitions[$column]->getSetting('case_sensitive'); - } + // If there is a field storage (some specifiers are not) and a field + // column, check for case sensitivity. + if ($field_storage && $column) { + $property_definitions = $field_storage->getPropertyDefinitions(); + if (isset($property_definitions[$column])) { + $this->caseSensitiveFields[$field] = $property_definitions[$column]->getSetting('case_sensitive'); } - } + // If there are more specifiers to come, it's a relationship. if ($field_storage && $key < $count) { // Computed fields have prepared their property definition already, do @@ -414,8 +417,10 @@ class Tables implements TablesInterface { * @param string $table * The table name. * - * @return array|bool - * The table field mapping for the given table or FALSE if not available. + * @return array|false + * An associative array of table field mapping for the given table, keyed by + * columns name and values are just incrementing integers. If the table + * mapping is not available, FALSE is returned. */ protected function getTableMapping($table, $entity_type_id) { $storage = $this->entityManager->getStorage($entity_type_id);