API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Authentic...

> If no provider set an active user then the user is set to anonymous.

I don't think that's technically true: AFAICT this class returns NULL if no provider sets an active user. It's true that Drupal *overall* sets the user to anonymous, but that sentence gives the inaccurate impression that the code in this class will be doing that.

Not sure what to suggest for better wording though!

Comments

joachim created an issue. See original summary.

christinlepson’s picture

StatusFileSize
new783 bytes

Patch to change
"If no provider set an active user then the user is set to anonymous."
to
"If no provider set an active user then NULL is returned, which results in the user being set to anonymous."

christinlepson’s picture

Status: Active » Needs review
Gnanasampandan Velmurgan’s picture

Status: Needs review » Needs work

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

onxze’s picture

I just tested this patch against 8.9.x-dev and I can verify that comment is changed to be more clearer and technically correct on file core/lib/Drupal/Core/Authentication/AuthenticationManager.php line 16.

onxze’s picture

Status: Needs work » Needs review
onxze’s picture

StatusFileSize
new783 bytes

Renamed the file to match naming convention.

onxze’s picture

Status: Needs review » Reviewed & tested by the community
onxze’s picture

StatusFileSize
new783 bytes

Updated the comment to be more clearer.

onxze’s picture

Status: Reviewed & tested by the community » Needs review
antojose’s picture

Status: Needs review » Reviewed & tested by the community
antojose’s picture

Tested the new patch. Looks good to go in.

antojose’s picture

.

alexpott’s picture

Title: AuthenticationManager's role in setting the current user to anymous is not clearly documented » AuthenticationManager's role in setting the current user to anonymous is not clearly documented
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/lib/Drupal/Core/Authentication/AuthenticationManager.php
@@ -13,7 +13,8 @@
+ * If no provider set an active user, then NULL is returned. This results in the

Returned by what? I'm not sure this is better wording.

  public function onKernelRequestAuthenticate(GetResponseEvent $event) {
    if ($event->isMasterRequest()) {
      $request = $event->getRequest();
      if ($this->authenticationProvider->applies($request)) {
        $account = $this->authenticationProvider->authenticate($request);
        if ($account) {
          $this->accountProxy->setAccount($account);
          return;
        }
      }
    }
  }

No user is set to anonymous. It reality the active user remains the anonymous user.

meenakshig’s picture

Status: Needs work » Needs review
StatusFileSize
new742 bytes

Fix the documentation as suggested.

longwave’s picture

Status: Needs review » Needs work
+++ b/core/lib/Drupal/Core/Authentication/AuthenticationManager.php
@@ -13,7 +13,7 @@
+ * If no provider set as an active user then the user remains anonymous.

The word "as" is not required.

meenakshig’s picture

Status: Needs work » Needs review
StatusFileSize
new739 bytes

Removed "as"

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Looks good now, thanks.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 7732e9d794 to 9.0.x and 46da1a6982 to 8.9.x and f2854ac58e to 8.8.x. Thanks!

Backported to 8.8.x as it is a docs fix.

diff --git a/core/lib/Drupal/Core/Authentication/AuthenticationManager.php b/core/lib/Drupal/Core/Authentication/AuthenticationManager.php
index 70c1c38655..d22a6c367c 100644
--- a/core/lib/Drupal/Core/Authentication/AuthenticationManager.php
+++ b/core/lib/Drupal/Core/Authentication/AuthenticationManager.php
@@ -13,7 +13,7 @@
  * provider detecting credentials for its method wins. No further provider will
  * get triggered.
  *
- * If no provider set an active user then the user remains anonymous.
+ * If no provider sets an active user then the user remains anonymous.
  */
 class AuthenticationManager implements AuthenticationProviderInterface, AuthenticationProviderFilterInterface, AuthenticationProviderChallengeInterface {
 

Updated for English grammar rules.

  • alexpott committed 7732e9d on 9.0.x
    Issue #3055374 by onxze, Meenakshi.g, christinlepson, joachim, longwave...

  • alexpott committed 46da1a6 on 8.9.x
    Issue #3055374 by onxze, Meenakshi.g, christinlepson, joachim, longwave...

  • alexpott committed f2854ac on 8.8.x
    Issue #3055374 by onxze, Meenakshi.g, christinlepson, joachim, longwave...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.