Problem/Motivation

API documentation for \Drupal\Core\Session\AccountInterface::getEmail is incorrect. When the method is called from the anonymous user (User::load(0);, NULL value is returned

Proposed resolution

Change/update return type and description.

Remaining tasks

Update API docs.

User interface changes

Nil

API changes

Only docs.

Data model changes

Nil

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dpi created an issue. See original summary.

gaurav.kapoor’s picture

Status: Active » Needs review
FileSize
628 bytes

Did the required changes.

dpi’s picture

Status: Needs review » Needs work
  1. +++ b/core/lib/Drupal/Core/Session/AccountInterface.php
    @@ -146,9 +146,10 @@ public function getAccountName();
    +   * Returns the email address of this account.For anonymous user NULL value is
    

    The short comment should not wrap. One line only.

  2. +++ b/core/lib/Drupal/Core/Session/AccountInterface.php
    @@ -146,9 +146,10 @@ public function getAccountName();
        *   The email address.
    

    return comment should specify what happens when there is no address.

neelam.chaudhary’s picture

Status: Needs work » Needs review
FileSize
644 bytes

Fixing #3 points.

mohit1604’s picture

Status: Needs review » Needs work
mohit1604’s picture

Status: Needs work » Reviewed & tested by the community

Thanks, neelam.chaudhary for the patch #4.

neelam.chaudhary’s picture

FileSize
644 bytes

@Mohit Malik Please do not delete or hide the patch if its working fine.
Adding the patch again as Mohit has hide the patch.

mohit1604’s picture

@neelam.chaudhary Thanks for the patch mam ! . Patch was hidden/delete by mistake due to some network issues !

larowlan’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/lib/Drupal/Core/Session/AccountInterface.php
@@ -146,10 +146,10 @@ public function getAccountName();
+   *   The email address, or NULL if the account is anonymous.

The email field is now optional too, so this can return NULL for more than the anonymous users. Can we update this to reflect that? Possibly The email address, or NULL if the account is anonymous or the user does not have an email address

gaurav.kapoor’s picture

Status: Needs work » Needs review
FileSize
708 bytes

Did changes as per suggestion in #10.

jeetendrakumar’s picture

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

Patch is working find for me
Changing status to RTBC

larowlan’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/lib/Drupal/Core/Session/AccountInterface.php
@@ -146,10 +146,11 @@ public function getAccountName();
+   * Returns the email address of this account if exists.

Can we make this 'if it exists'

Sorry for being pedantic.

Berdir’s picture

Do we even need to change that line when we have the explicit documentation on the @return? I'd vote to just leave that initial line unchanged, seems enough to have that below?

larowlan’s picture

Do we even need to change that line when we have the explicit documentation on the @return? I'd vote to just leave that initial line unchanged, seems enough to have that below?

Agree, that is much simpler

gaurav.kapoor’s picture

Status: Needs work » Needs review
FileSize
608 bytes

Adding a patch based on suggestions in #14.

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

Yes, that is enough I think.

harsha012’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
705 bytes

fixed nit pick

jeetendrakumar’s picture

Status: Needs review » Reviewed & tested by the community

@Berdir

I think #18 patch have right documentation.

gaurav.kapoor’s picture

@harsha012
This change isn't required

-   * Returns the email address of this account.
+   * Returns the email address of this account if it exists.

And which nitpick did you fix in #18?

The last submitted patch, , failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

larowlan’s picture

Patch #16 is the correct one

larowlan’s picture

Status: Reviewed & tested by the community » Needs work

Adding review credit for

+++ b/core/lib/Drupal/Core/Session/AccountInterface.php
@@ -148,8 +148,9 @@ public function getDisplayName();
+   * @return string|NULL

this needs to be string|null, not string|NULL, for coding standards.

For whoever rerolls this, please use patch 16, not 18

harsha012’s picture

Status: Needs work » Needs review
FileSize
705 bytes
493 bytes

please see comment #26

harsha012’s picture

harsha012’s picture

fixed the nit picks as per #23

gaurav.kapoor’s picture

Status: Needs review » Reviewed & tested by the community

Since all the concerns have been addressed changing to RTBC.

larowlan’s picture

Removing myself from issue credits

  • larowlan committed 354462c on 8.5.x
    Issue #2932774 by harsha012, gaurav.kapoor, neelam.chaudhary, dpi:...
larowlan’s picture

Version: 8.5.x-dev » 8.4.x-dev

Committed as 354462c and pushed to 8.5.x

Leaving at RTBC and changing to 8.4.x.

Will cherry-pick to 8.4.x tomorrow after commit freeze for 8.4.4 is over.

larowlan’s picture

Issue tags: +8.4.4 Commit freeze

inventing a tag for myself

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 26: 2932774-25.patch, failed testing. View results

  • larowlan committed 4364f36 on 8.4.x
    Issue #2932774 by harsha012, gaurav.kapoor, neelam.chaudhary, dpi:...
larowlan’s picture

Status: Needs work » Fixed
Issue tags: -8.4.4 Commit freeze

Cherry-picked as 4364f36 and pushed to 8.4.x.

  • larowlan committed be8d160 on 8.4.x
    Revert "Issue #2932774 by harsha012, gaurav.kapoor, neelam.chaudhary,...
larowlan’s picture

Version: 8.4.x-dev » 8.5.x-dev

As per https://www.drupal.org/core/release-cycle-overview#current-development-c... 8.4 is in 'critical fixes only', so I reverted this from 8.4

Status: Fixed » Closed (fixed)

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