diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 82fbe7a..ed15979 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -433,9 +433,7 @@ public function set($property_name, $value, $notify = TRUE) { $this->get($property_name)->setValue($value, FALSE); if ($property_name == 'langcode') { - // Avoid using unset as this unnecessarily triggers magic methods later - // on. - $this->language = NULL; + $this->onChange($property_name); } } diff --git a/core/modules/field/field.multilingual.inc b/core/modules/field/field.multilingual.inc index 01c1af8..2ea2bf1 100644 --- a/core/modules/field/field.multilingual.inc +++ b/core/modules/field/field.multilingual.inc @@ -21,11 +21,11 @@ * @endcode * Every field can hold a single or multiple value for each language code * belonging to the available language codes set: - * - For untranslatable fields this set only contains Language::LANGCODE_NOT_SPECIFIED. + * - For untranslatable fields this set is only Language::LANGCODE_DEFAULT. * - For translatable fields this set can contain any language code. By default * it is the list returned by field_content_languages(), which contains all - * installed languages with the addition of Language::LANGCODE_NOT_SPECIFIED. This - * default can be altered by modules implementing + * installed languages with the addition of Language::LANGCODE_NOT_SPECIFIED. + * This default can be altered by modules implementing * hook_field_available_languages_alter(). * * The available language codes for a particular field are returned by @@ -69,10 +69,10 @@ * Collects the available language codes for the given entity type and field. * * If the given field has language support enabled, an array of available - * language codes will be returned, otherwise only Language::LANGCODE_NOT_SPECIFIED will - * be returned. Since the default value for a 'translatable' entity property is - * FALSE, we ensure that only entities that are able to handle translations - * actually get translatable fields. + * language codes will be returned, otherwise only Language::LANGCODE_DEFAULT + * will be returned. Since the default value for a 'translatable' entity + * property is FALSE, we ensure that only entities that are able to handle + * translations actually get translatable fields. * * @param $entity_type * The type of the entity the field is attached to, e.g. 'node' or 'user'. @@ -92,8 +92,7 @@ function field_available_languages($entity_type, FieldInterface $field) { if (!isset($field_langcodes[$entity_type][$field_name])) { // If the field has language support enabled we retrieve an (alterable) list - // of enabled languages, otherwise we return just - // Language::LANGCODE_DEFAULT. + // of enabled languages, otherwise we return Language::LANGCODE_DEFAULT. if (field_is_translatable($entity_type, $field)) { $langcodes = field_content_languages(); // Let other modules alter the available languages. diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php index de2dd94..5b370a0 100644 --- a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php @@ -142,7 +142,7 @@ function testFieldAvailableLanguages() { $this->field->translatable = FALSE; $this->field->save(); $available_langcodes = field_available_languages($this->entity_type, $this->field); - $this->assertTrue(count($available_langcodes) == 1 && $available_langcodes[0] === Language::LANGCODE_NOT_SPECIFIED, 'For untranslatable fields only Language::LANGCODE_NOT_SPECIFIED is available.'); + $this->assertTrue(count($available_langcodes) == 1 && $available_langcodes[0] === Language::LANGCODE_DEFAULT, 'For untranslatable fields only Language::LANGCODE_NOT_SPECIFIED is available.'); } /**