diff --git a/core/lib/Drupal/Core/Session/AccountInterface.php b/core/lib/Drupal/Core/Session/AccountInterface.php index a52195c..fa437c0 100644 --- a/core/lib/Drupal/Core/Session/AccountInterface.php +++ b/core/lib/Drupal/Core/Session/AccountInterface.php @@ -58,30 +58,6 @@ public function getRoles($exclude_locked_roles = FALSE); public function hasPermission($permission); /** - * Returns the session ID. - * - * @return string|null - * The session ID or NULL if this user does not have an active session. - */ - public function getSessionId(); - - /** - * Returns the secure session ID. - * - * @return string|null - * The session ID or NULL if this user does not have an active secure session. - */ - public function getSecureSessionId(); - - /** - * Returns the session data. - * - * @return array - * Array with the session data that belongs to this object. - */ - public function getSessionData(); - - /** * Returns TRUE if the account is authenticated. * * @return bool @@ -173,11 +149,4 @@ public function getTimeZone(); */ public function getLastAccessedTime(); - /** - * Returns the session hostname. - * - * @return string - */ - public function getHostname(); - } diff --git a/core/lib/Drupal/Core/Session/AccountProxy.php b/core/lib/Drupal/Core/Session/AccountProxy.php index eae71e7..ff5c4f4 100644 --- a/core/lib/Drupal/Core/Session/AccountProxy.php +++ b/core/lib/Drupal/Core/Session/AccountProxy.php @@ -83,13 +83,6 @@ public function getRoles($exclude_locked_roles = FALSE) { /** * {@inheritdoc} */ - public function getHostname() { - return $this->getAccount()->getHostname(); - } - - /** - * {@inheritdoc} - */ public function hasPermission($permission) { return $this->getAccount()->hasPermission($permission); } @@ -97,27 +90,6 @@ public function hasPermission($permission) { /** * {@inheritdoc} */ - public function getSessionId() { - return $this->getAccount()->getSessionId(); - } - - /** - * {@inheritdoc} - */ - public function getSecureSessionId() { - return $this->getAccount()->getSecureSessionId(); - } - - /** - * {@inheritdoc} - */ - public function getSessionData() { - return $this->getAccount()->getSessionData(); - } - - /** - * {@inheritdoc} - */ public function isAuthenticated() { return $this->getAccount()->isAuthenticated(); } diff --git a/core/lib/Drupal/Core/Session/AnonymousUserSession.php b/core/lib/Drupal/Core/Session/AnonymousUserSession.php index 56e065c..de0527d 100644 --- a/core/lib/Drupal/Core/Session/AnonymousUserSession.php +++ b/core/lib/Drupal/Core/Session/AnonymousUserSession.php @@ -18,9 +18,6 @@ class AnonymousUserSession extends UserSession { * Intentionally don't allow parameters to be passed in like UserSession. */ public function __construct() { - if (\Drupal::hasRequest()) { - $this->hostname = \Drupal::request()->getClientIp(); - } } } diff --git a/core/lib/Drupal/Core/Session/UserSession.php b/core/lib/Drupal/Core/Session/UserSession.php index 6181f24..ce4b508 100644 --- a/core/lib/Drupal/Core/Session/UserSession.php +++ b/core/lib/Drupal/Core/Session/UserSession.php @@ -31,32 +31,11 @@ class UserSession implements AccountInterface { protected $roles = array(AccountInterface::ANONYMOUS_ROLE); /** - * Session ID. + * The Unix timestamp when the user last accessed the site. * * @var string. */ - public $sid; - - /** - * Secure session ID. - * - * @var string. - */ - public $ssid; - - /** - * Session data. - * - * @var array. - */ - public $session; - - /** - * The Unix timestamp when this session last requested a page. - * - * @var string. - */ - protected $timestamp; + protected $access; /** * The name of this account. @@ -94,13 +73,6 @@ class UserSession implements AccountInterface { protected $timezone; /** - * The hostname for this user session. - * - * @var string - */ - protected $hostname = ''; - - /** * Constructs a new user session. * * @param array $values @@ -147,27 +119,6 @@ public function hasPermission($permission) { /** * {@inheritdoc} */ - public function getSecureSessionId() { - return $this->ssid; - } - - /** - * {@inheritdoc} - */ - public function getSessionData() { - return $this->session; - } - - /** - * {@inheritdoc} - */ - public function getSessionId() { - return $this->sid; - } - - /** - * {@inheritdoc} - */ public function isAuthenticated() { return $this->uid > 0; } @@ -232,14 +183,7 @@ public function getTimeZone() { * {@inheritdoc} */ public function getLastAccessedTime() { - return $this->timestamp; - } - - /** - * {@inheritdoc} - */ - public function getHostname() { - return $this->hostname; + return $this->access; } /** diff --git a/core/modules/user/src/Authentication/Provider/Cookie.php b/core/modules/user/src/Authentication/Provider/Cookie.php index bac9e15..22ac903 100644 --- a/core/modules/user/src/Authentication/Provider/Cookie.php +++ b/core/modules/user/src/Authentication/Provider/Cookie.php @@ -81,11 +81,6 @@ protected function getUserFromSession(SessionInterface $session) { // Check if the user data was found and the user is active. if (!empty($values) && $values['status'] == 1) { - // UserSession::getLastAccessedTime() returns session save timestamp, - // while User::getLastAccessedTime() returns the user 'access' - // timestamp. This ensures they are synchronized. - $values['timestamp'] = $values['access']; - // Add the user's roles. $rids = $this->connection ->query('SELECT roles_target_id FROM {user__roles} WHERE entity_id = :uid', [':uid' => $values['uid']]) diff --git a/core/modules/user/src/Entity/User.php b/core/modules/user/src/Entity/User.php index 1a78c98..fa4db6f 100644 --- a/core/modules/user/src/Entity/User.php +++ b/core/modules/user/src/Entity/User.php @@ -70,13 +70,6 @@ class User extends ContentEntityBase implements UserInterface { protected static $anonymousUser; /** - * The hostname for this user. - * - * @var string - */ - protected $hostname; - - /** * {@inheritdoc} */ public function isNew() { @@ -173,37 +166,6 @@ public function getRoles($exclude_locked_roles = FALSE) { /** * {@inheritdoc} */ - public function getSecureSessionId() { - return NULL; - } - - /** - * {@inheritdoc} - */ - public function getSessionData() { - return array(); - } - /** - * {@inheritdoc} - */ - public function getSessionId() { - return NULL; - } - - /** - * {@inheritdoc} - */ - public function getHostname() { - if (!isset($this->hostname) && \Drupal::hasRequest()) { - $this->hostname = \Drupal::request()->getClientIp(); - } - - return $this->hostname; - } - - /** - * {@inheritdoc} - */ public function hasRole($rid) { return in_array($rid, $this->getRoles()); } diff --git a/core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php b/core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php index 4ac0c76..043e17e 100644 --- a/core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php +++ b/core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php @@ -22,42 +22,6 @@ class AnonymousUserSessionTest extends UnitTestCase { /** - * Tests creating an AnonymousUserSession when the request is available. - * - * @covers ::__construct - */ - public function testAnonymousUserSessionWithRequest() { - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); - $request->expects($this->once()) - ->method('getClientIp') - ->will($this->returnValue('test')); - $container = new ContainerBuilder(); - $requestStack = new RequestStack(); - $requestStack->push($request); - $container->set('request_stack', $requestStack); - \Drupal::setContainer($container); - - $anonymous_user = new AnonymousUserSession(); - - $this->assertSame('test', $anonymous_user->getHostname()); - } - - /** - * Tests creating an AnonymousUserSession when the request is not available. - * - * @covers ::__construct - */ - public function testAnonymousUserSessionWithNoRequest() { - $container = new ContainerBuilder(); - - \Drupal::setContainer($container); - - $anonymous_user = new AnonymousUserSession(); - - $this->assertSame('', $anonymous_user->getHostname()); - } - - /** * Tests the method getRoles exclude or include locked roles based in param. * * @covers ::getRoles