diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php index 685bd4f..f0d1ee5 100644 --- a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php +++ b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php @@ -247,22 +247,19 @@ protected function attachLoad(&$queried_entities, $load_revision = FALSE) { protected function mapFromStorageRecords(array $records, $load_revision = FALSE) { $entities = array(); foreach ($records as $id => $record) { - // If we have no multilingual values we can instantiate entity objecs - // right now. - $values = array(); + $entities[$id] = array(); foreach ($record as $name => $value) { // Skip the item delta and item value levels but let the field assign // the value as suiting. This avoids unnecessary array hierarchies and // saves memory here. - $values[$name][LANGUAGE_DEFAULT] = $value; + $entities[$id][$name][LANGUAGE_DEFAULT] = $value; } + // If we have no multilingual values we can instantiate entity objecs + // right now, otherwise we need to collect all the field values first. if (!$this->dataTable) { $bundle = $this->bundleKey ? $record->{$this->bundleKey} : FALSE; // Turn the record into an entity class. - $entities[$id] = new $this->entityClass($values, $this->entityType, $bundle); - } - else { - $entities[$id] = &$values; + $entities[$id] = new $this->entityClass($entities[$id], $this->entityType, $bundle); } } $this->attachPropertyData($entities, $load_revision); diff --git a/core/lib/Drupal/Core/Entity/EntityNG.php b/core/lib/Drupal/Core/Entity/EntityNG.php index d9d17c2..914d8de 100644 --- a/core/lib/Drupal/Core/Entity/EntityNG.php +++ b/core/lib/Drupal/Core/Entity/EntityNG.php @@ -327,6 +327,7 @@ public function getTranslation($langcode, $strict = TRUE) { */ public function getTranslationLanguages($include_default = TRUE) { $translations = array(); + $definitions = $this->getPropertyDefinitions(); // Build an array with the translation langcodes set as keys. Empty // translations should not be included and must be skipped. foreach ($this->getProperties() as $name => $property) { @@ -338,7 +339,7 @@ public function getTranslationLanguages($include_default = TRUE) { foreach ($this->values[$name] as $langcode => $values) { // If a value is there but the field object is empty, it has been // unset, so we need to skip the field also. - if ($values && !(isset($this->fields[$name][$langcode]) && $this->fields[$name][$langcode]->isEmpty())) { + if ($values && !empty($definitions[$name]['translatable']) && !(isset($this->fields[$name][$langcode]) && $this->fields[$name][$langcode]->isEmpty())) { $translations[$langcode] = TRUE; } }