diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php index 911de6c..66e7424 100644 --- a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php +++ b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php @@ -343,6 +343,7 @@ public function save(EntityInterface $entity) { } $entity->preSave($this); + $this->invokeFieldMethod('preSave', $entity); $this->invokeHook('presave', $entity); // Create the storage record to be saved. diff --git a/core/lib/Drupal/Core/Entity/EntityNG.php b/core/lib/Drupal/Core/Entity/EntityNG.php index a2f90d1..bbfb77a 100644 --- a/core/lib/Drupal/Core/Entity/EntityNG.php +++ b/core/lib/Drupal/Core/Entity/EntityNG.php @@ -511,11 +511,12 @@ public function getTranslation($langcode) { else { // If we were given a valid language and there is no translation for it, // we return a new one. - $languages = language_list(); + $languages = language_list(Language::STATE_ALL); if (isset($languages[$langcode])) { - // If the entity language is not a configured language we fall back to - // the entity itself, since in this case it cannot have translations. - $translation = isset($languages[$this->getDefaultLanguage()->langcode]) ? $this->addTranslation($langcode) : $this; + // If the entity or the requested language is not a configured + // language, we fall back to the entity itself, since in this case it + // cannot have translations. + $translation = empty($this->getDefaultLanguage()->locked) && empty($languages[$langcode]->locked) ? $this->addTranslation($langcode) : $this; } } } diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php index 0893f43..ceaf8f1 100644 --- a/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php @@ -106,6 +106,7 @@ function testFieldFormTranslationRevisions() { $entity = entity_create($this->entity_type, array()); $available_langcodes = array_flip(field_available_languages($this->entity_type, $this->field)); unset($available_langcodes[Language::LANGCODE_NOT_SPECIFIED]); + unset($available_langcodes[Language::LANGCODE_NOT_APPLICABLE]); $field_name = $this->field['field_name']; // Store the field translations. diff --git a/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php b/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php index 737daf3..e62b777 100644 --- a/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php +++ b/core/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php @@ -321,7 +321,6 @@ function testFieldAttachSaveMissingData() { // Update: Field translation is missing but field is not empty. Translation // data should survive. - $entity->getTranslation($unavailable_langcode)->{$this->field_name} = mt_rand(1, 127); unset($entity->{$this->field_name}); field_attach_update($entity); $count = db_select($this->table)