- π¬π§United Kingdom catch
The re-roll in #60 was posted less then 24 hours after the patch in #58 and doesn't change anything from that patch. I'm removing issue credit.
UserInterface
defines the hasRole()
method, but the Drupal::currentUser()
returns an object implementing AccountInterface
, which does not have this method unless the current user is authenticated, in which case a UserInterface
object is returned.
Because of this, hasRole()
cannot be used without first checking the object type.
Since UserInterface
extends AccountInterface
, move the hasRole
method there.
Quoting @catch from #28 π Add hasRole() method to AccountProxy and UserSession classes Fixed :
We do allow adding methods to interfaces that aren't explicitly tagged with @api, see https://www.drupal.org/about/core/policies/core-change-policies/drupal-8 β ...
However in practice, we'd want to avoid breakage in a minor for this change, so I think we should grep contrib.
If we can't change the interface in a Drupal 9 minor, we could still add the implementations of the method, and document that the additional method will be on the interface in Drupal 10 etc. just without changing the interface itself.
And @xjm:
So, I think we should do what @catch says in the second part of his comment in #28.
To summarize:
In this task, we add hasRole()
implementations to AccountInterface
implementations: AccountProxy
and UserSession
.
In the follow-up task, we add a method to AccountInterface
in Drupal 10 -
#3228209: Move hasRole() method from UserInterface to AccountInterface β
.
Review https://git.drupalcode.org/project/drupal/-/merge_requests/1059;
Address comment #42;
Commit;
Drupal\Core\Session\AccountProxy
and Drupal\Core\Session\UserSession
now implement hasRole()
method. See the change record:
https://www.drupal.org/node/3002289 β
Fixed
10.1 β¨
Last updated
Enhances developer experience.
It is used to alert the release manager core committer(s) that an issue significantly affects the overall technical debt or release timeline of Drupal, and their signoff is needed. See the governance policy draft for more information.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
The re-roll in #60 was posted less then 24 hours after the patch in #58 and doesn't change anything from that patch. I'm removing issue credit.