Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Since \Drupal::currentUser() returns AccountProxyInterface
, it is a very common misunderstanding to type hint to that interface. However, doing so precludes using loaded User
entities or UserSessions
in many cases where there is no reason to do so.
Proposed resolution
Add a line or two of clarifying comments.
Comment | File | Size | Author |
---|---|---|---|
#2 | 2936253-2-accountproxyinterface-documentation.patch | 680 bytes | gabesullice |
Comments
Comment #2
gabesulliceComment #3
Wim LeersComment #5
gabesulliceHm, doubt that...
Comment #7
larowlanShould we mark this as @internal as well then - to further communicate that - discuss/thoughts?
Would also require a change record.
Comment #8
Wim LeersI don't think we need to mark this
@internal
. Nor can we, because there are contrib modules (e.g. https://www.drupal.org/project/masquerade) using it.Leaving NR so @gabesullice can agree/disagree and if agree, re-RTBC.
Comment #9
gabesulliceI agree w/ @Wim Leers. The AccountProxyInterface is useful if you need to do any kind of account substitution, which might be useful for all kinds of things (masquerade is just one example, creating email digests might be another).
Comment #12
larowlanThanks, looks like d.o ate my comment, - committed this to 8.6.x and cherry-picked to 8.5.x