diff --git a/core/includes/common.inc b/core/includes/common.inc index fdd9eac..a0621aa 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -33,7 +33,7 @@ use Drupal\Core\Routing\GeneratorNotInitializedException; use Drupal\Core\Template\Attribute; use Drupal\Core\Render\Element; -use Drupal\Core\Authentication\AnonymousUserSession; +use Drupal\Core\Authentication\AnonymousUser; /** * @defgroup php_wrappers PHP wrapper functions diff --git a/core/lib/Drupal/Core/Authentication/AccountProxy.php b/core/lib/Drupal/Core/Authentication/AccountProxy.php index 3d915f0..07b9549 100644 --- a/core/lib/Drupal/Core/Authentication/AccountProxy.php +++ b/core/lib/Drupal/Core/Authentication/AccountProxy.php @@ -59,7 +59,7 @@ public function getAccount() { $this->account = $this->loadUserEntity($this->initialAccountId); } else { - $this->account = new AnonymousUserSession(); + $this->account = new AnonymousUser(); } } diff --git a/core/lib/Drupal/Core/Authentication/AnonymousUserSession.php b/core/lib/Drupal/Core/Authentication/AnonymousUser.php similarity index 76% rename from core/lib/Drupal/Core/Authentication/AnonymousUserSession.php rename to core/lib/Drupal/Core/Authentication/AnonymousUser.php index 4025862..67c4af1 100644 --- a/core/lib/Drupal/Core/Authentication/AnonymousUserSession.php +++ b/core/lib/Drupal/Core/Authentication/AnonymousUser.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\Core\Authentication\AnonymousUserSession. + * Contains \Drupal\Core\Authentication\AnonymousUser. */ namespace Drupal\Core\Authentication; @@ -12,7 +12,7 @@ /** * An account implementation representing an anonymous user. */ -class AnonymousUserSession extends UserSession { +class AnonymousUser extends UserSession { /** * Constructs a new anonymous user session. diff --git a/core/lib/Drupal/Core/Cron.php b/core/lib/Drupal/Core/Cron.php index 1fec276..dec9dad 100644 --- a/core/lib/Drupal/Core/Cron.php +++ b/core/lib/Drupal/Core/Cron.php @@ -12,7 +12,7 @@ use Drupal\Core\State\StateInterface; use Drupal\Core\Lock\LockBackendInterface; use Drupal\Core\Queue\QueueFactory; -use Drupal\Core\Authentication\AnonymousUserSession; +use Drupal\Core\Authentication\AnonymousUser; use Drupal\Core\Authentication\AccountSwitcherInterface; use Drupal\Core\Queue\SuspendQueueException; use Psr\Log\LoggerInterface; @@ -108,7 +108,7 @@ public function run() { // Force the current user to anonymous to ensure consistent permissions on // cron runs. - $this->accountSwitcher->switchTo(new AnonymousUserSession()); + $this->accountSwitcher->switchTo(new AnonymousUser()); // Try to allocate enough time to run all the hook_cron implementations. drupal_set_time_limit(240); diff --git a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php index 474259e..7349579 100644 --- a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php +++ b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php @@ -16,7 +16,7 @@ use Drupal\Core\Routing\UrlGeneratorTrait; use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\Field\FieldItemBase; -use Drupal\Core\Authentication\AnonymousUserSession; +use Drupal\Core\Authentication\AnonymousUser; /** * Plugin implementation of the 'comment' field type. @@ -109,7 +109,7 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { $settings = $this->getSettings(); - $anonymous_user = new AnonymousUserSession(); + $anonymous_user = new AnonymousUser(); $element['default_mode'] = array( '#type' => 'checkbox', diff --git a/core/modules/comment/src/Tests/CommentFieldAccessTest.php b/core/modules/comment/src/Tests/CommentFieldAccessTest.php index 0eb27bf..271a32c 100644 --- a/core/modules/comment/src/Tests/CommentFieldAccessTest.php +++ b/core/modules/comment/src/Tests/CommentFieldAccessTest.php @@ -9,7 +9,7 @@ use Drupal\comment\Entity\Comment; use Drupal\comment\Entity\CommentType; use Drupal\Component\Utility\SafeMarkup; -use Drupal\Core\Authentication\AnonymousUserSession; +use Drupal\Core\Authentication\AnonymousUser; use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\simpletest\TestBase; @@ -127,7 +127,7 @@ public function testAccessToAdministrativeFields() { $role->grantPermission('post comments') ->save(); - $anonymous_user = new AnonymousUserSession(); + $anonymous_user = new AnonymousUser(); // Add two fields. $this->addDefaultCommentField('entity_test', 'entity_test', 'comment'); diff --git a/core/modules/comment/src/Tests/Views/CommentFieldNameTest.php b/core/modules/comment/src/Tests/Views/CommentFieldNameTest.php index 4ac63a8..7872269 100644 --- a/core/modules/comment/src/Tests/Views/CommentFieldNameTest.php +++ b/core/modules/comment/src/Tests/Views/CommentFieldNameTest.php @@ -8,7 +8,7 @@ namespace Drupal\comment\Tests\Views; use Drupal\comment\Entity\Comment; -use Drupal\Core\Authentication\AnonymousUserSession; +use Drupal\Core\Authentication\AnonymousUser; use Drupal\user\RoleInterface; use Drupal\views\Views; @@ -81,7 +81,7 @@ public function testCommentFieldName() { // Grant permission to properly check view access on render. user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access comments']); - $this->container->get('account_switcher')->switchTo(new AnonymousUserSession()); + $this->container->get('account_switcher')->switchTo(new AnonymousUser()); $view = Views::getView('test_comment_field_name'); $this->executeView($view); // Test that data rendered. diff --git a/core/modules/comment/src/Tests/Views/CommentUserNameTest.php b/core/modules/comment/src/Tests/Views/CommentUserNameTest.php index 3f7e4d4..ab2d710 100644 --- a/core/modules/comment/src/Tests/Views/CommentUserNameTest.php +++ b/core/modules/comment/src/Tests/Views/CommentUserNameTest.php @@ -8,7 +8,7 @@ namespace Drupal\comment\Tests\Views; use Drupal\comment\Entity\Comment; -use Drupal\Core\Authentication\AnonymousUserSession; +use Drupal\Core\Authentication\AnonymousUser; use Drupal\user\Entity\Role; use Drupal\user\Entity\User; use Drupal\views\Entity\View; @@ -150,7 +150,7 @@ public function testUsername() { $this->assertLink($this->adminUser->label()); $this->assertLink('barry (not verified)'); - $account_switcher->switchTo(new AnonymousUserSession()); + $account_switcher->switchTo(new AnonymousUser()); $executable = Views::getView($view_id); $build = $executable->preview(); $this->setRawContent($renderer->render($build)); diff --git a/core/modules/filter/src/Tests/FilterAPITest.php b/core/modules/filter/src/Tests/FilterAPITest.php index dc2e684..9438c3d 100644 --- a/core/modules/filter/src/Tests/FilterAPITest.php +++ b/core/modules/filter/src/Tests/FilterAPITest.php @@ -9,7 +9,7 @@ use Drupal\Core\Language\LanguageInterface; use Drupal\Component\Utility\SafeMarkup; -use Drupal\Core\Authentication\AnonymousUserSession; +use Drupal\Core\Authentication\AnonymousUser; use Drupal\Core\TypedData\OptionsProviderInterface; use Drupal\Core\TypedData\DataDefinition; use Drupal\filter\Plugin\DataType\FilterFormat; @@ -284,7 +284,7 @@ function testTypedDataAPI() { )); // Test with anonymous user. - $user = new AnonymousUserSession(); + $user = new AnonymousUser(); \Drupal::currentUser()->setAccount($user); $expected_available_options = array( diff --git a/core/modules/simpletest/src/BrowserTestBase.php b/core/modules/simpletest/src/BrowserTestBase.php index 1b99ac2..7c8a984 100644 --- a/core/modules/simpletest/src/BrowserTestBase.php +++ b/core/modules/simpletest/src/BrowserTestBase.php @@ -20,7 +20,7 @@ use Drupal\Core\Database\Database; use Drupal\Core\DrupalKernel; use Drupal\Core\Authentication\AccountInterface; -use Drupal\Core\Authentication\AnonymousUserSession; +use Drupal\Core\Authentication\AnonymousUser; use Drupal\Core\Session\UserSession; use Drupal\Core\Site\Settings; use Drupal\Core\StreamWrapper\StreamWrapperInterface; @@ -725,7 +725,7 @@ protected function drupalLogout() { // @see BrowserTestBase::drupalUserIsLoggedIn() unset($this->loggedInUser->sessionId); $this->loggedInUser = FALSE; - $this->container->get('current_user')->setAccount(new AnonymousUserSession()); + $this->container->get('current_user')->setAccount(new AnonymousUser()); } /** diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index c64ffe2..5baa2ab 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -22,7 +22,7 @@ use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Render\Element; use Drupal\Core\Authentication\AccountInterface; -use Drupal\Core\Authentication\AnonymousUserSession; +use Drupal\Core\Authentication\AnonymousUser; use Drupal\Core\Session\UserSession; use Drupal\Core\Site\Settings; use Drupal\Core\StreamWrapper\PublicStream; @@ -744,7 +744,7 @@ protected function drupalLogout() { // @see WebTestBase::drupalUserIsLoggedIn() unset($this->loggedInUser->session_id); $this->loggedInUser = FALSE; - $this->container->get('current_user')->setAccount(new AnonymousUserSession()); + $this->container->get('current_user')->setAccount(new AnonymousUser()); } } diff --git a/core/modules/system/src/Tests/Form/FormCacheTest.php b/core/modules/system/src/Tests/Form/FormCacheTest.php index 1809b38..3b34130 100644 --- a/core/modules/system/src/Tests/Form/FormCacheTest.php +++ b/core/modules/system/src/Tests/Form/FormCacheTest.php @@ -8,7 +8,7 @@ namespace Drupal\system\Tests\Form; use Drupal\Core\Form\FormState; -use Drupal\Core\Authentication\AnonymousUserSession; +use Drupal\Core\Authentication\AnonymousUser; use Drupal\Core\Session\UserSession; use Drupal\simpletest\KernelTestBase; @@ -91,7 +91,7 @@ function testCacheToken() { function testNoCacheToken() { // Switch to a anonymous user account. $account_switcher = \Drupal::service('account_switcher'); - $account_switcher->switchTo(new AnonymousUserSession()); + $account_switcher->switchTo(new AnonymousUser()); $this->formState->set('example', $this->randomMachineName()); \Drupal::formBuilder()->setCache($this->formBuildId, $this->form, $this->formState); diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 6a3003b..3c21c5e 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -10,7 +10,7 @@ use Drupal\Core\Render\Element; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Authentication\AccountInterface; -use Drupal\Core\Authentication\AnonymousUserSession; +use Drupal\Core\Authentication\AnonymousUser; use Drupal\Core\Site\Settings; use Drupal\Core\Url; use Drupal\user\Entity\Role; @@ -443,7 +443,7 @@ function user_template_preprocess_default_variables_alter(&$variables) { * \Drupal\Component\Utility\Xss::filter(). */ function template_preprocess_username(&$variables) { - $account = $variables['account'] ?: new AnonymousUserSession(); + $account = $variables['account'] ?: new AnonymousUser(); $variables['extra'] = ''; $variables['uid'] = $account->id(); @@ -749,7 +749,7 @@ function _user_cancel($edit, $account, $method) { // regenerate it because batch API uses the session ID, we will regenerate it // in _user_cancel_session_regenerate(). if ($account->id() == \Drupal::currentUser()->id()) { - \Drupal::currentUser()->setAccount(new AnonymousUserSession()); + \Drupal::currentUser()->setAccount(new AnonymousUser()); } } @@ -1388,7 +1388,7 @@ function user_logout() { // lead to the creation of spurious session records in the database. // @see https://github.com/symfony/symfony/issues/12375 \Drupal::service('session_manager')->destroy(); - $user->setAccount(new AnonymousUserSession()); + $user->setAccount(new AnonymousUser()); } /** diff --git a/core/modules/views/src/Tests/Plugin/DisplayPageTest.php b/core/modules/views/src/Tests/Plugin/DisplayPageTest.php index 8aac4ad..80306ad 100644 --- a/core/modules/views/src/Tests/Plugin/DisplayPageTest.php +++ b/core/modules/views/src/Tests/Plugin/DisplayPageTest.php @@ -8,7 +8,7 @@ namespace Drupal\views\Tests\Plugin; use Drupal\Core\Menu\MenuTreeParameters; -use Drupal\Core\Authentication\AnonymousUserSession; +use Drupal\Core\Authentication\AnonymousUser; use Drupal\views\Views; use Drupal\views\Tests\ViewUnitTestBase; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; @@ -58,7 +58,7 @@ protected function setUp() { * Checks the behavior of the page for access denied/not found behaviors. */ public function testPageResponses() { - \Drupal::currentUser()->setAccount(new AnonymousUserSession()); + \Drupal::currentUser()->setAccount(new AnonymousUser()); $subrequest = Request::create('/test_page_display_403', 'GET'); $response = $this->container->get('http_kernel')->handle($subrequest, HttpKernelInterface::SUB_REQUEST); $this->assertEqual($response->getStatusCode(), 403); diff --git a/core/tests/Drupal/Tests/Core/Authentication/AnonymousUserSessionTest.php b/core/tests/Drupal/Tests/Core/Authentication/AnonymousUserTest.php similarity index 71% rename from core/tests/Drupal/Tests/Core/Authentication/AnonymousUserSessionTest.php rename to core/tests/Drupal/Tests/Core/Authentication/AnonymousUserTest.php index df4563f..a7b7a88 100644 --- a/core/tests/Drupal/Tests/Core/Authentication/AnonymousUserSessionTest.php +++ b/core/tests/Drupal/Tests/Core/Authentication/AnonymousUserTest.php @@ -2,20 +2,20 @@ /** * @file - * Contains \Drupal\Tests\Core\Authentication\AnonymousUserSessionTest. + * Contains \Drupal\Tests\Core\Authentication\AnonymousUserTest. */ namespace Drupal\Tests\Core\Authentication; use Drupal\Tests\UnitTestCase; -use Drupal\Core\Authentication\AnonymousUserSession; +use Drupal\Core\Authentication\AnonymousUser; use Drupal\user\RoleInterface; /** - * @coversDefaultClass \Drupal\Core\Authentication\AnonymousUserSession + * @coversDefaultClass \Drupal\Core\Authentication\AnonymousUser * @group Session */ -class AnonymousUserSessionTest extends UnitTestCase { +class AnonymousUserTest extends UnitTestCase { /** * Tests the method getRoles exclude or include locked roles based in param. @@ -24,7 +24,7 @@ class AnonymousUserSessionTest extends UnitTestCase { * @todo Move roles constants to a class/interface */ public function testUserGetRoles() { - $anonymous_user = new AnonymousUserSession(); + $anonymous_user = new AnonymousUser(); $this->assertEquals(array(RoleInterface::ANONYMOUS_ID), $anonymous_user->getRoles()); $this->assertEquals(array(), $anonymous_user->getRoles(TRUE)); }