Commit 8e23b465 authored by alexpott's avatar alexpott

Issue #2045275 by Berdir: Convert user properties to methods.

parent 4c52a6e3
...@@ -1898,8 +1898,8 @@ function drupal_get_user_timezone() { ...@@ -1898,8 +1898,8 @@ function drupal_get_user_timezone() {
global $user; global $user;
$config = config('system.timezone'); $config = config('system.timezone');
if ($user && $config->get('user.configurable') && $user->id() && $user->timezone) { if ($user && $config->get('user.configurable') && $user->isAuthenticated() && $user->getTimezone()) {
return $user->timezone; return $user->getTimezone();
} }
else { else {
// Ignore PHP strict notice if time zone has not yet been set in the php.ini // Ignore PHP strict notice if time zone has not yet been set in the php.ini
......
...@@ -4181,7 +4181,7 @@ function drupal_render_cid_parts($granularity = NULL) { ...@@ -4181,7 +4181,7 @@ function drupal_render_cid_parts($granularity = NULL) {
// resource drag for sites with many users, so when a module is being // resource drag for sites with many users, so when a module is being
// equivocal, we favor the less expensive 'PER_ROLE' pattern. // equivocal, we favor the less expensive 'PER_ROLE' pattern.
if ($granularity & DRUPAL_CACHE_PER_ROLE) { if ($granularity & DRUPAL_CACHE_PER_ROLE) {
$cid_parts[] = 'r.' . implode(',', $user->roles); $cid_parts[] = 'r.' . implode(',', $user->getRoles());
} }
elseif ($granularity & DRUPAL_CACHE_PER_USER) { elseif ($granularity & DRUPAL_CACHE_PER_USER) {
$cid_parts[] = 'u.' . $user->id(); $cid_parts[] = 'u.' . $user->id();
......
...@@ -2537,8 +2537,8 @@ function install_configure_form_submit($form, &$form_state) { ...@@ -2537,8 +2537,8 @@ function install_configure_form_submit($form, &$form_state) {
// We precreated user 1 with placeholder values. Let's save the real values. // We precreated user 1 with placeholder values. Let's save the real values.
$account = user_load(1); $account = user_load(1);
$account->init = $account->mail = $form_state['values']['account']['mail']; $account->init = $account->mail = $form_state['values']['account']['mail'];
$account->roles = !empty($account->roles) ? $account->roles : array(); $account->roles = $account->getRoles();
$account->status = 1; $account->activate();
$account->timezone = $form_state['values']['date_default_timezone']; $account->timezone = $form_state['values']['date_default_timezone'];
$account->pass = $form_state['values']['account']['pass']; $account->pass = $form_state['values']['account']['pass'];
$account->name = $form_state['values']['account']['name']; $account->name = $form_state['values']['account']['name'];
......
...@@ -84,7 +84,7 @@ function _drupal_session_read($sid) { ...@@ -84,7 +84,7 @@ function _drupal_session_read($sid) {
// cookies (eg. web crawlers). // cookies (eg. web crawlers).
$insecure_session_name = substr(session_name(), 1); $insecure_session_name = substr(session_name(), 1);
if (!isset($_COOKIE[session_name()]) && !isset($_COOKIE[$insecure_session_name])) { if (!isset($_COOKIE[session_name()]) && !isset($_COOKIE[$insecure_session_name])) {
$user = drupal_anonymous_user(); $user = new UserSession();
return ''; return '';
} }
...@@ -106,30 +106,25 @@ function _drupal_session_read($sid) { ...@@ -106,30 +106,25 @@ function _drupal_session_read($sid) {
$values = db_query("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = :sid", array(':sid' => $sid))->fetchAssoc(); $values = db_query("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = :sid", array(':sid' => $sid))->fetchAssoc();
} }
if ($values) {
$user = new UserSession($values);
}
// We found the client's session record and they are an authenticated, // We found the client's session record and they are an authenticated,
// active user. // active user.
if ($values && $values['uid'] > 0 && $values['status'] == 1) { if ($values && $values['uid'] > 0 && $values['status'] == 1) {
$user = new UserSession($values);
// Add roles element to $user. // Add roles element to $user.
$rids = db_query("SELECT ur.rid FROM {users_roles} ur WHERE ur.uid = :uid", array(':uid' => $user->id()))->fetchCol(); $rids = db_query("SELECT ur.rid FROM {users_roles} ur WHERE ur.uid = :uid", array(':uid' => $values['uid']))->fetchCol();
$user->roles = array_merge(array(DRUPAL_AUTHENTICATED_RID), $rids); $values['roles'] = array_merge(array(DRUPAL_AUTHENTICATED_RID), $rids);
$user = new UserSession($values);
} }
elseif ($user) { elseif ($values) {
// The user is anonymous or blocked. Only preserve two fields from the // The user is anonymous or blocked. Only preserve two fields from the
// {sessions} table. // {sessions} table.
$account = drupal_anonymous_user(); $user = new UserSession(array(
$account->session = $user->session; 'session' => $values['session'],
$account->timestamp = $user->timestamp; 'access' => $values['access'],
$user = $account; ));
} }
else { else {
// The session has expired. // The session has expired.
$user = drupal_anonymous_user(); $user = new UserSession();
$user->session = '';
} }
// Store the session that was read for comparison in _drupal_session_write(). // Store the session that was read for comparison in _drupal_session_write().
...@@ -177,7 +172,7 @@ function _drupal_session_write($sid, $value) { ...@@ -177,7 +172,7 @@ function _drupal_session_write($sid, $value) {
// For performance reasons, do not update the sessions table, unless // For performance reasons, do not update the sessions table, unless
// $_SESSION has changed or more than 180 has passed since the last update. // $_SESSION has changed or more than 180 has passed since the last update.
if ($is_changed || !isset($user->timestamp) || REQUEST_TIME - $user->timestamp > settings()->get('session_write_interval', 180)) { if ($is_changed || !$user->getLastAccessedTime() || REQUEST_TIME - $user->getLastAccessedTime() > settings()->get('session_write_interval', 180)) {
// Either ssid or sid or both will be added from $key below. // Either ssid or sid or both will be added from $key below.
$fields = array( $fields = array(
'uid' => $user->id(), 'uid' => $user->id(),
...@@ -214,7 +209,7 @@ function _drupal_session_write($sid, $value) { ...@@ -214,7 +209,7 @@ function _drupal_session_write($sid, $value) {
} }
// Likewise, do not update access time more than once per 180 seconds. // Likewise, do not update access time more than once per 180 seconds.
if ($user->isAuthenticated() && REQUEST_TIME - $user->access > settings()->get('session_write_interval', 180)) { if ($user->isAuthenticated() && REQUEST_TIME - $user->getLastAccessedTime() > settings()->get('session_write_interval', 180)) {
db_update('users') db_update('users')
->fields(array( ->fields(array(
'access' => REQUEST_TIME 'access' => REQUEST_TIME
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
namespace Drupal\Core\Password; namespace Drupal\Core\Password;
use Drupal\user\UserInterface;
/** /**
* Secure password hashing functions for user authentication. * Secure password hashing functions for user authentication.
*/ */
...@@ -32,13 +34,13 @@ public function hash($password); ...@@ -32,13 +34,13 @@ public function hash($password);
* *
* @param string $password * @param string $password
* A plain-text password * A plain-text password
* @param Drupal\user\User * @param \Drupal\user\UserInterface $account
* A user object with at least the fields from the {users} table. * A user entity.
* *
* @return bolean. * @return bool
* TRUE or FALSE. * TRUE if the password is valid, FALSE if not.
*/ */
public function check($password, $account); public function check($password, UserInterface $account);
/** /**
* Check whether a user's hashed password needs to be replaced with a new hash. * Check whether a user's hashed password needs to be replaced with a new hash.
...@@ -53,12 +55,12 @@ public function check($password, $account); ...@@ -53,12 +55,12 @@ public function check($password, $account);
* Alternative implementations of this function might use other criteria based * Alternative implementations of this function might use other criteria based
* on the fields in $account. * on the fields in $account.
* *
* @param Drupal\user\User * @param \Drupal\user\UserInterface $account
* A user object with at least the fields from the {users} table. * A user entity.
* *
* @return boolean * @return boolean
* TRUE or FALSE. * TRUE or FALSE.
*/ */
public function userNeedsNewHash($account); public function userNeedsNewHash(UserInterface $account);
} }
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Drupal\Core\Password; namespace Drupal\Core\Password;
use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Crypt;
use Drupal\user\UserInterface;
/** /**
* Secure password hashing functions based on the Portable PHP password * Secure password hashing functions based on the Portable PHP password
...@@ -214,16 +215,16 @@ public function hash($password) { ...@@ -214,16 +215,16 @@ public function hash($password) {
/** /**
* Implements Drupal\Core\Password\PasswordInterface::checkPassword(). * Implements Drupal\Core\Password\PasswordInterface::checkPassword().
*/ */
public function check($password, $account) { public function check($password, UserInterface $account) {
if (substr($account->pass, 0, 2) == 'U$') { if (substr($account->getPassword(), 0, 2) == 'U$') {
// This may be an updated password from user_update_7000(). Such hashes // This may be an updated password from user_update_7000(). Such hashes
// have 'U' added as the first character and need an extra md5() (see the // have 'U' added as the first character and need an extra md5() (see the
// Drupal 7 documentation). // Drupal 7 documentation).
$stored_hash = substr($account->pass, 1); $stored_hash = substr($account->getPassword(), 1);
$password = md5($password); $password = md5($password);
} }
else { else {
$stored_hash = $account->pass; $stored_hash = $account->getPassword();
} }
$type = substr($stored_hash, 0, 3); $type = substr($stored_hash, 0, 3);
...@@ -248,14 +249,14 @@ public function check($password, $account) { ...@@ -248,14 +249,14 @@ public function check($password, $account) {
/** /**
* Implements Drupal\Core\Password\PasswordInterface::userNeedsNewHash(). * Implements Drupal\Core\Password\PasswordInterface::userNeedsNewHash().
*/ */
public function userNeedsNewHash($account) { public function userNeedsNewHash(UserInterface $account) {
// Check whether this was an updated password. // Check whether this was an updated password.
if ((substr($account->pass, 0, 3) != '$S$') || (strlen($account->pass) != static::HASH_LENGTH)) { if ((substr($account->getPassword(), 0, 3) != '$S$') || (strlen($account->getPassword()) != static::HASH_LENGTH)) {
return TRUE; return TRUE;
} }
// Ensure that $count_log2 is within set bounds. // Ensure that $count_log2 is within set bounds.
$count_log2 = $this->enforceLog2Boundaries($this->countLog2); $count_log2 = $this->enforceLog2Boundaries($this->countLog2);
// Check whether the iteration count used differs from the standard number. // Check whether the iteration count used differs from the standard number.
return ($this->getCountLog2($account->pass) !== $count_log2); return ($this->getCountLog2($account->getPassword()) !== $count_log2);
} }
} }
...@@ -125,4 +125,30 @@ public function getPreferredAdminLangcode($default = NULL); ...@@ -125,4 +125,30 @@ public function getPreferredAdminLangcode($default = NULL);
*/ */
public function getUsername(); public function getUsername();
/**
* Returns the e-mail address of this account.
*
* @return string
* The e-mail address.
*/
public function getEmail();
/**
* Returns the timezone of this account.
*
* @return string
* Name of the timezone.
*/
public function getTimeZone();
/**
* The timestamp when the account last accessed the site.
*
* A value of 0 means the user has never accessed the site.
*
* @return int
* Timestamp of the last access.
*/
public function getLastAccessedTime();
} }
...@@ -19,23 +19,16 @@ class UserSession implements AccountInterface { ...@@ -19,23 +19,16 @@ class UserSession implements AccountInterface {
* *
* @var int * @var int
*/ */
protected $uid; protected $uid = 0;
/**
* Session hostname.
*
* @todo: This does not seem to be used, remove?
*
* @var string
*/
public $hostname;
/** /**
* List of the roles this user has. * List of the roles this user has.
* *
* Defaults to the anonymous role.
*
* @var array * @var array
*/ */
public $roles; protected $roles = array('anonymous');
/** /**
* Session ID. * Session ID.
...@@ -63,7 +56,7 @@ class UserSession implements AccountInterface { ...@@ -63,7 +56,7 @@ class UserSession implements AccountInterface {
* *
* @var string. * @var string.
*/ */
public $timestamp; protected $timestamp;
/** /**
* The name of this account. * The name of this account.
...@@ -86,6 +79,20 @@ class UserSession implements AccountInterface { ...@@ -86,6 +79,20 @@ class UserSession implements AccountInterface {
*/ */
protected $preferred_admin_langcode; protected $preferred_admin_langcode;
/**
* The e-mail address of this account.
*
* @var string
*/
protected $mail;
/**
* The timezone of this account.
*
* @var string
*/
protected $timezone;
/** /**
* Constructs a new user session. * Constructs a new user session.
* *
...@@ -202,4 +209,25 @@ public function getUsername() { ...@@ -202,4 +209,25 @@ public function getUsername() {
return $name; return $name;
} }
/**
* {@inheritdoc}
*/
public function getEmail() {
return $this->mail;
}
/**
* {@inheritdoc}
*/
public function getTimeZone() {
return $this->timezone;
}
/**
* {@inheritdoc}
*/
public function getLastAccessedTime() {
return $this->timestamp;
}
} }
...@@ -42,7 +42,7 @@ protected function checkAccess(EntityInterface $entity, $operation, $langcode, A ...@@ -42,7 +42,7 @@ protected function checkAccess(EntityInterface $entity, $operation, $langcode, A
// For blocks with roles associated, if none of the user's roles matches // For blocks with roles associated, if none of the user's roles matches
// the settings from this block, access is denied. // the settings from this block, access is denied.
$visibility = $entity->get('visibility'); $visibility = $entity->get('visibility');
if (!empty($visibility['role']['roles']) && !array_intersect(array_filter($visibility['role']['roles']), $user->roles)) { if (!empty($visibility['role']['roles']) && !array_intersect(array_filter($visibility['role']['roles']), $user->getRoles())) {
// No match. // No match.
return FALSE; return FALSE;
} }
......
...@@ -46,7 +46,7 @@ function setUp() { ...@@ -46,7 +46,7 @@ function setUp() {
$this->normal_user_alt = $this->drupalCreateUser(); $this->normal_user_alt = $this->drupalCreateUser();
// Sync the roles, since drupalCreateUser() creates separate roles for // Sync the roles, since drupalCreateUser() creates separate roles for
// the same permission sets. // the same permission sets.
$this->normal_user_alt->roles = $this->normal_user->roles; $this->normal_user_alt->roles = $this->normal_user->getRoles();
$this->normal_user_alt->save(); $this->normal_user_alt->save();
// Enable our test block. // Enable our test block.
......
...@@ -1429,7 +1429,7 @@ function comment_preview(Comment $comment) { ...@@ -1429,7 +1429,7 @@ function comment_preview(Comment $comment) {
if ($account->id()) { if ($account->id()) {
$comment->uid->target_id = $account->id(); $comment->uid->target_id = $account->id();
$comment->name->value = check_plain($account->name); $comment->name->value = check_plain($account->getUsername());
} }
elseif (empty($comment->name->value)) { elseif (empty($comment->name->value)) {
$comment->name->value = config('user.settings')->get('anonymous'); $comment->name->value = config('user.settings')->get('anonymous');
...@@ -1530,8 +1530,8 @@ function template_preprocess_comment(&$variables) { ...@@ -1530,8 +1530,8 @@ function template_preprocess_comment(&$variables) {
$variables['user_picture'] = array(); $variables['user_picture'] = array();
} }
if (config('user.settings')->get('signatures') && !empty($account->signature)) { if (config('user.settings')->get('signatures') && $account->getSignature()) {
$variables['signature'] = check_markup($account->signature, $account->signature_format, '', TRUE) ; $variables['signature'] = check_markup($account->getSignature(), $account->getSignatureFormat(), '', TRUE) ;
} }
else { else {
$variables['signature'] = ''; $variables['signature'] = '';
......
...@@ -139,8 +139,7 @@ function comment_tokens($type, $tokens, array $data = array(), array $options = ...@@ -139,8 +139,7 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
case 'mail': case 'mail':
if ($comment->uid->target_id != 0) { if ($comment->uid->target_id != 0) {
$account = user_load($comment->uid->target_id); $mail = $comment->uid->entity->getEmail();
$mail = $account->mail;
} }
else { else {
$mail = $comment->mail->value; $mail = $comment->mail->value;
......
...@@ -66,7 +66,7 @@ public function form(array $form, array &$form_state) { ...@@ -66,7 +66,7 @@ public function form(array $form, array &$form_state) {
} }
else { else {
if ($user->isAuthenticated()) { if ($user->isAuthenticated()) {
$author = $user->name; $author = $user->getUsername();
} }
else { else {
$author = ($comment->name->value ? $comment->name->value : ''); $author = ($comment->name->value ? $comment->name->value : '');
......
...@@ -302,7 +302,7 @@ public function preSave(EntityStorageControllerInterface $storage_controller) { ...@@ -302,7 +302,7 @@ public function preSave(EntityStorageControllerInterface $storage_controller) {
// We test the value with '===' because we need to modify anonymous // We test the value with '===' because we need to modify anonymous
// users as well. // users as well.
if ($this->uid->target_id === $user->id() && $user->isAuthenticated()) { if ($this->uid->target_id === $user->id() && $user->isAuthenticated()) {
$this->name->value = $user->name; $this->name->value = $user->getUsername();
} }
// Add the values which aren't passed into the function. // Add the values which aren't passed into the function.
$this->thread->value = $thread; $this->thread->value = $thread;
......
...@@ -70,7 +70,7 @@ function testAnonymous() { ...@@ -70,7 +70,7 @@ function testAnonymous() {
// Ensure anonymous users cannot post in the name of registered users. // Ensure anonymous users cannot post in the name of registered users.
$langcode = Language::LANGCODE_NOT_SPECIFIED; $langcode = Language::LANGCODE_NOT_SPECIFIED;
$edit = array( $edit = array(
'name' => $this->admin_user->name, 'name' => $this->admin_user->getUsername(),
'mail' => $this->randomName() . '@example.com', 'mail' => $this->randomName() . '@example.com',
'subject' => $this->randomName(), 'subject' => $this->randomName(),
"comment_body[$langcode][0][value]" => $this->randomName(), "comment_body[$langcode][0][value]" => $this->randomName(),
......
...@@ -80,8 +80,8 @@ function testCommentInterface() { ...@@ -80,8 +80,8 @@ function testCommentInterface() {
// Test changing the comment author to a verified user. // Test changing the comment author to a verified user.
$this->drupalGet('comment/' . $comment->id() . '/edit'); $this->drupalGet('comment/' . $comment->id() . '/edit');
$comment = $this->postComment(NULL, $comment->comment_body->value, $comment->subject->value, array('name' => $this->web_user->name)); $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->subject->value, array('name' => $this->web_user->getUsername()));
$this->assertTrue($comment->name->value == $this->web_user->name && $comment->uid->target_id == $this->web_user->id(), 'Comment author successfully changed to a registered user.'); $this->assertTrue($comment->name->value == $this->web_user->getUsername() && $comment->uid->target_id == $this->web_user->id(), 'Comment author successfully changed to a registered user.');
$this->drupalLogout(); $this->drupalLogout();
......
...@@ -52,7 +52,7 @@ function testCommentLinks() { ...@@ -52,7 +52,7 @@ function testCommentLinks() {
// Remove additional user permissions from $this->web_user added by setUp(), // Remove additional user permissions from $this->web_user added by setUp(),
// since this test is limited to anonymous and authenticated roles only. // since this test is limited to anonymous and authenticated roles only.
$roles = $this->web_user->roles; $roles = $this->web_user->getRoles();
entity_delete_multiple('user_role', array(reset($roles))); entity_delete_multiple('user_role', array(reset($roles)));
// Matrix of possible environmental conditions and configuration settings. // Matrix of possible environmental conditions and configuration settings.
......
...@@ -92,7 +92,7 @@ function testCommentEditPreviewSave() { ...@@ -92,7 +92,7 @@ function testCommentEditPreviewSave() {
$date = new DrupalDateTime('2008-03-02 17:23'); $date = new DrupalDateTime('2008-03-02 17:23');
$edit['subject'] = $this->randomName(8); $edit['subject'] = $this->randomName(8);
$edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16); $edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16);
$edit['name'] = $web_user->name; $edit['name'] = $web_user->getUsername();
$edit['date[date]'] = $date->format('Y-m-d'); $edit['date[date]'] = $date->format('Y-m-d');
$edit['date[time]'] = $date->format('H:i:s'); $edit['date[time]'] = $date->format('H:i:s');
$raw_date = $date->getTimestamp(); $raw_date = $date->getTimestamp();
......
...@@ -56,7 +56,7 @@ function testCommentTokenReplacement() { ...@@ -56,7 +56,7 @@ function testCommentTokenReplacement() {
$tests['[comment:cid]'] = $comment->id(); $tests['[comment:cid]'] = $comment->id();
$tests['[comment:hostname]'] = check_plain($comment->hostname->value); $tests['[comment:hostname]'] = check_plain($comment->hostname->value);
$tests['[comment:name]'] = filter_xss($comment->name->value); $tests['[comment:name]'] = filter_xss($comment->name->value);
$tests['[comment:mail]'] = check_plain($this->admin_user->mail); $tests['[comment:mail]'] = check_plain($this->admin_user->getEmail());
$tests['[comment:homepage]'] = check_url($comment->homepage->value); $tests['[comment:homepage]'] = check_url($comment->homepage->value);
$tests['[comment:title]'] = filter_xss($comment->subject->value); $tests['[comment:title]'] = filter_xss($comment->subject->value);
$tests['[comment:body]'] = $comment->comment_body->processed; $tests['[comment:body]'] = $comment->comment_body->processed;
...@@ -69,7 +69,7 @@ function testCommentTokenReplacement() { ...@@ -69,7 +69,7 @@ function testCommentTokenReplacement() {
$tests['[comment:node:nid]'] = $comment->nid->target_id; $tests['[comment:node:nid]'] = $comment->nid->target_id;
$tests['[comment:node:title]'] = check_plain($node->title); $tests['[comment:node:title]'] = check_plain($node->title);
$tests['[comment:author:uid]'] = $comment->uid->target_id; $tests['[comment:author:uid]'] = $comment->uid->target_id;
$tests['[comment:author:name]'] = check_plain($this->admin_user->name); $tests['[comment:author:name]'] = check_plain($this->admin_user->getUsername());
// Test to make sure that we generated something for each token. // Test to make sure that we generated something for each token.
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
...@@ -82,13 +82,13 @@ function testCommentTokenReplacement() { ...@@ -82,13 +82,13 @@ function testCommentTokenReplacement() {
// Generate and test unsanitized tokens. // Generate and test unsanitized tokens.
$tests['[comment:hostname]'] = $comment->hostname->value; $tests['[comment:hostname]'] = $comment->hostname->value;
$tests['[comment:name]'] = $comment->name->value; $tests['[comment:name]'] = $comment->name->value;
$tests['[comment:mail]'] = $this->admin_user->mail; $tests['[comment:mail]'] = $this->admin_user->getEmail();
$tests['[comment:homepage]'] = $comment->homepage->value; $tests['[comment:homepage]'] = $comment->homepage->value;
$tests['[comment:title]'] = $comment->subject->value; $tests['[comment:title]'] = $comment->subject->value;
$tests['[comment:body]'] = $comment->comment_body->value; $tests['[comment:body]'] = $comment->comment_body->value;
$tests['[comment:parent:title]'] = $parent_comment->subject->value; $tests['[comment:parent:title]'] = $parent_comment->subject->value;
$tests['[comment:node:title]'] = $node->title; $tests['[comment:node:title]'] = $node->title;
$tests['[comment:author:name]'] = $this->admin_user->name; $tests['[comment:author:name]'] = $this->admin_user->getUsername();
foreach ($tests as $input => $expected) { foreach ($tests as $input => $expected) {
$output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->id, 'sanitize' => FALSE)); $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->id, 'sanitize' => FALSE));
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
use Drupal\contact\Plugin\Core\Entity\Category; use Drupal\contact\Plugin\Core\Entity\Category;
use Drupal\user\UserInterface;
/** /**
* Implements hook_help(). * Implements hook_help().
...@@ -122,7 +123,7 @@ function contact_menu() { ...@@ -122,7 +123,7 @@ function contact_menu() {
* *
* @see contact_menu() * @see contact_menu()
*/ */
function _contact_personal_tab_access($account) { function _contact_personal_tab_access(UserInterface $account) {
global $user; global $user;