diff --git a/core/lib/Drupal/Core/Session/AccountInterface.php b/core/lib/Drupal/Core/Session/AccountInterface.php index a52195c46091e317971071f7093b8957063b61ab..fa437c0205c6508b0e75dbd708ecb5e704457076 100644 --- a/core/lib/Drupal/Core/Session/AccountInterface.php +++ b/core/lib/Drupal/Core/Session/AccountInterface.php @@ -57,30 +57,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. * @@ -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 eae71e7731db84450748fcd79ed8961f417e53f4..ff5c4f4b513e48f4c82bb4a353d2eb151b17f887 100644 --- a/core/lib/Drupal/Core/Session/AccountProxy.php +++ b/core/lib/Drupal/Core/Session/AccountProxy.php @@ -80,13 +80,6 @@ public function getRoles($exclude_locked_roles = FALSE) { return $this->getAccount()->getRoles($exclude_locked_roles); } - /** - * {@inheritdoc} - */ - public function getHostname() { - return $this->getAccount()->getHostname(); - } - /** * {@inheritdoc} */ @@ -94,27 +87,6 @@ public function hasPermission($permission) { return $this->getAccount()->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} */ diff --git a/core/lib/Drupal/Core/Session/AnonymousUserSession.php b/core/lib/Drupal/Core/Session/AnonymousUserSession.php index 56e065ccf0d02dddc44a8aa5da7551fffbc06ad0..de0527d394dc1b3c0faa50b021a707d37540b5a3 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 6181f244ebcf3ef129104f7f519cf9fdd8902610..ce4b5081dc093c854b50ec82c663ede023c360c3 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. @@ -93,13 +72,6 @@ class UserSession implements AccountInterface { */ protected $timezone; - /** - * The hostname for this user session. - * - * @var string - */ - protected $hostname = ''; - /** * Constructs a new user session. * @@ -144,27 +116,6 @@ public function hasPermission($permission) { return $this->getRoleStorage()->isPermissionInRoles($permission, $this->getRoles()); } - /** - * {@inheritdoc} - */ - public function getSecureSessionId() { - return $this->ssid; - } - - /** - * {@inheritdoc} - */ - public function getSessionData() { - return $this->session; - } - - /** - * {@inheritdoc} - */ - public function getSessionId() { - return $this->sid; - } - /** * {@inheritdoc} */ @@ -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 bac9e15396ca84555977639756bba2b387cff484..22ac903705ab4cc4da1c54dd5147804e856d8545 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 1a78c98a987520315e9ce1be72199ead2d912f22..fa4db6ffef5615f02ed85c115ed847d1d50d3269 100644 --- a/core/modules/user/src/Entity/User.php +++ b/core/modules/user/src/Entity/User.php @@ -69,13 +69,6 @@ class User extends ContentEntityBase implements UserInterface { */ protected static $anonymousUser; - /** - * The hostname for this user. - * - * @var string - */ - protected $hostname; - /** * {@inheritdoc} */ @@ -170,37 +163,6 @@ public function getRoles($exclude_locked_roles = FALSE) { return $roles; } - /** - * {@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} */ diff --git a/core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php b/core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php index 4ac0c76ce6db214c580c26d4a044b7f0a11bd326..043e17ecf0c1d9cae78c7ba88e6142ee9226c23b 100644 --- a/core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php +++ b/core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php @@ -21,42 +21,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. *