diff --git a/core/modules/contact/src/MessageForm.php b/core/modules/contact/src/MessageForm.php index 8cb7814..07f4818 100644 --- a/core/modules/contact/src/MessageForm.php +++ b/core/modules/contact/src/MessageForm.php @@ -279,7 +279,7 @@ protected function init(array &$form_state) { // Make the message inherit the current content language unless specifically // set. - if ($message->isNew()) { + if ($message->isNew() && !$message->language()) { $language_content = \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT); $message->langcode->value = $language_content->id; } diff --git a/core/modules/contact/src/Tests/ContactStorageTest.php b/core/modules/contact/src/Tests/ContactStorageTest.php index a05a803..c5784a7 100644 --- a/core/modules/contact/src/Tests/ContactStorageTest.php +++ b/core/modules/contact/src/Tests/ContactStorageTest.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\contact\Tests\ContactStorageTest. + * Contains \Drupal\contact\Tests\ContactStorageTest. */ namespace Drupal\contact\Tests; @@ -52,7 +52,7 @@ public function testContactStorage() { $this->addCategory($id = drupal_strtolower($this->randomName(16)), $label = $this->randomName(16), implode(',', array($mail)), '', TRUE); $this->assertRaw(t('Category %label has been added.', array('%label' => $label))); - // Ensure that the contact form is shown without a category selection input. + // Ensure that anonymous can submit site-wide contact form. user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form')); $this->drupalLogout(); $this->drupalGet('contact'); diff --git a/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module b/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module index 5a002bf..88f4e2e 100644 --- a/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module +++ b/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module @@ -17,6 +17,9 @@ function contact_storage_test_entity_base_field_info(\Drupal\Core\Entity\EntityT ->setLabel(t('Message ID')) ->setDescription(t('The message ID.')) ->setReadOnly(TRUE) + // Explicitly set this to 'contact' so that + // ContentEntityDatabaseStorage::usesDedicatedTable() doesn't attempt to + // put the ID in a dedicated table. ->setProvider('contact') ->setSetting('unsigned', TRUE); @@ -32,7 +35,7 @@ function contact_storage_test_entity_type_alter(array &$entity_types) { /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ // Set the controller class for nodes to an alternate implementation of the // Drupal\Core\Entity\EntityStorageInterface interface. - $entity_types['contact_message']->setStorageClass('\Drupal\contact_storage_test\ContactMessageStorage'); + $entity_types['contact_message']->setStorageClass('\Drupal\Core\Entity\ContentEntityDatabaseStorage'); $keys = $entity_types['contact_message']->getKeys(); $keys['id'] = 'id'; $entity_types['contact_message']->set('entity_keys', $keys); diff --git a/core/modules/contact/tests/modules/contact_storage_test/src/ContactMessageStorage.php b/core/modules/contact/tests/modules/contact_storage_test/src/ContactMessageStorage.php deleted file mode 100644 index 0246558..0000000 --- a/core/modules/contact/tests/modules/contact_storage_test/src/ContactMessageStorage.php +++ /dev/null @@ -1,29 +0,0 @@ -