Problem/Motivation
The following error occurs when the retrieval of user information fails and $userinfo becomes NULL.
TypeError: Argument 1 passed to mymodule_openid_connect_userinfo_alter() must be of the type array, null given
Steps to reproduce
Proposed resolution
Allow NULL for hook_openid_connect_userinfo_alter():
- function hook_openid_connect_userinfo_alter(array &$userinfo, array $context) {
+ function hook_openid_connect_userinfo_alter(?array &$userinfo, array $context) {
or make sure that $userinfo is array:
// Drupal\openid_connect\OpenIDConnect::buildContext()
if ($plugin->usesUserInfo()) {
- $userinfo = $plugin->retrieveUserInfo($tokens['access_token']);
+ $userinfo = $plugin->retrieveUserInfo($tokens['access_token']) ?: [];
}
Remaining tasks
n/a
User interface changes
n/a
API changes
n/a
Data model changes
n/a
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 3243493-6.patch | 595 bytes | pcate |
Issue fork openid_connect-3243493
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
mohit.bansal623 commentedPlease review the merge request.
Comment #5
mohit.bansal623 commentedComment #8
pcate commentedMade a minor update to the MR to only call the
retrieveUserInfomethod once, which I think was the cause of the previous test failure. I also changed the branch from 2.x to 3.x since I'm not sure if development will stop on 2.x when Drupal 9 support ends. Either way the change can be merged into both 2.x and 3.x.Setting the NR.
Comment #9
pcate commentedAttached patch of the change as well in case that is more convenient.
Comment #12
pfrillingI reviewed and manually tested and all seems correct to me. I added test coverage to validate.
Comment #13
pfrillingAdded to the merge train. Thanks everyone!