diff -u b/core/modules/language/lib/Drupal/language/Entity/Language.php b/core/modules/language/lib/Drupal/language/Entity/Language.php --- b/core/modules/language/lib/Drupal/language/Entity/Language.php +++ b/core/modules/language/lib/Drupal/language/Entity/Language.php @@ -125,12 +125,7 @@ */ public function isDefault() { if (!isset($this->default)) { - if (static::getDefaultLangcode() == $this->id()) { - return TRUE; - } - else { - return FALSE; - } + return static::getDefaultLangcode() == $this->id(); } return $this->default; } @@ -156,6 +151,8 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); + // Only set the default language and save it to system.site configuration if + // it needs to updated. if ($this->isDefault() && static::getDefaultLangcode() != $this->id()) { // Update the config. Saving the configuration fires and event that causes // the container to be rebuilt. @@ -174,8 +171,8 @@ // flushed. language_negotiation_url_prefixes_update(); - // If after adding this language the site will become multilingual, we need to - // rebuild language services. + // If after adding this language the site will become multilingual, we need + // to rebuild language services. if (!$this->preSaveMultilingual && !$update && $language_manager instanceof ConfigurableLanguageManagerInterface) { $language_manager::rebuildServices(); } @@ -207,9 +204,9 @@ * @throws \RuntimeException */ public static function preDelete(EntityStorageInterface $storage, array $entities) { - $default_language = static::getDefaultLangcode(); + $default_langcode = static::getDefaultLangcode(); foreach ($entities as $entity) { - if ($entity->id() == $default_language->id && !$entity->isUninstalling()) { + if ($entity->id() == $default_langcode && !$entity->isUninstalling()) { throw new DeleteDefaultLanguageException('Can not delete the default language'); } }