summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2014-04-12 18:50:12 (GMT)
committerAlex Pott2014-04-12 18:50:12 (GMT)
commit1c11d16419b0ff0209a68822dea2ff6877d99d60 (patch)
treea5f54b1fa6cd26cf533ecdcbd4fe66cfa5cf7f1f
parent455840f75d75722e15000e17c7f53ac0852ffd72 (diff)
Issue #2223611 by cs_shadow, ACF, dman, visabhishek, vintorezxxi: ContactFormController passed user name field list object to watchdog.
-rw-r--r--core/modules/contact/lib/Drupal/contact/MessageFormController.php6
-rw-r--r--core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php17
2 files changed, 18 insertions, 5 deletions
diff --git a/core/modules/contact/lib/Drupal/contact/MessageFormController.php b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
index 2058887..da17847 100644
--- a/core/modules/contact/lib/Drupal/contact/MessageFormController.php
+++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
@@ -245,16 +245,16 @@ class MessageFormController extends ContentEntityFormController {
$this->flood->register('contact', $config->get('flood.interval'));
if (!$message->isPersonal()) {
watchdog('contact', '%sender-name (@sender-from) sent an e-mail regarding %category.', array(
- '%sender-name' => $sender->name,
+ '%sender-name' => $sender->getUsername(),
'@sender-from' => $sender->getEmail(),
'%category' => $category->label(),
));
}
else {
watchdog('contact', '%sender-name (@sender-from) sent %recipient-name an e-mail.', array(
- '%sender-name' => $sender->name,
+ '%sender-name' => $sender->getUsername(),
'@sender-from' => $sender->getEmail(),
- '%recipient-name' => $message->recipient->name,
+ '%recipient-name' => $message->getPersonalRecipient()->getUsername(),
));
}
diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php
index c7056a7..f1df078 100644
--- a/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php
+++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php
@@ -7,6 +7,7 @@
namespace Drupal\contact\Tests;
+use Drupal\Component\Utility\String;
use Drupal\simpletest\WebTestBase;
/**
@@ -19,7 +20,7 @@ class ContactPersonalTest extends WebTestBase {
*
* @var array
*/
- public static $modules = array('contact');
+ public static $modules = array('contact', 'dblog');
/**
* A user with some administrative permissions.
@@ -54,7 +55,7 @@ class ContactPersonalTest extends WebTestBase {
parent::setUp();
// Create an admin user.
- $this->admin_user = $this->drupalCreateUser(array('administer contact forms', 'administer users', 'administer account settings'));
+ $this->admin_user = $this->drupalCreateUser(array('administer contact forms', 'administer users', 'administer account settings', 'access site reports'));
// Create some normal users with their contact forms enabled by default.
\Drupal::config('contact.settings')->set('user_default_enabled', 1)->save();
@@ -85,6 +86,18 @@ class ContactPersonalTest extends WebTestBase {
$this->assertTrue(strpos($mail['body'], t('Hello !recipient-name,', $variables)) !== FALSE, 'Recipient name is in sent message.');
$this->assertTrue(strpos($mail['body'], $this->web_user->getUsername()) !== FALSE, 'Sender name is in sent message.');
$this->assertTrue(strpos($mail['body'], $message['message']) !== FALSE, 'Message body is in sent message.');
+
+ // Check there was no problems raised during sending.
+ $this->drupalLogout();
+ $this->drupalLogin($this->admin_user);
+ // Verify that the correct watchdog message has been logged.
+ $this->drupalGet('/admin/reports/dblog');
+ $placeholders = array(
+ '@sender_name' => $this->web_user->username,
+ '@sender_email' => $this->web_user->getEmail(),
+ '@recipient_name' => $this->contact_user->getUsername()
+ );
+ $this->assertText(String::format('@sender_name (@sender_email) sent @recipient_name an e-mail.', $placeholders));
}
/**