Problem/Motivation
The return type for \Drupal\openid_connect\OpenIDConnect::createUser is UserInterface|null but it can never return null. This means that external code using this function needs to handle the null case, even though it doesn't exist.
Currently ::createUser calls \Drupal\externalauth\ExternalAuthInterface::register which only returns UserInterface. Following through to the implementation of that function confirms that null is never returned. Instead, if there is an issue creating a user then an exception is thrown.
Steps to reproduce
Proposed resolution
Drop null from the return type and documented typehint.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork openid_connect-3504426
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 #3
mstrelan commentedComment #4
pfrillingThe code looks fine to me. I left a comment on the MR about handling the exception. What do you think?
Comment #5
mstrelan commentedThat's a tricky one to answer. The only place this module is calling createUser is in
OpenIDConnect::completeAuthorization, and that already has checks to see if the user already exists. In that case it would be fine for the exception to bubble up. The doc block for\Drupal\externalauth\ExternalAuthInterface::registerdoesn't mention that it throws that exception either, so in theory any concrete class implementing that interface doesn't need to throw that exception either. So I think bubbling up would be fine.Comment #6
pfrillingThanks for the validation @mstrelan. I think this all looks good.
Comment #7
pfrillingComment #9
joseph.olstadAlpha6 causes an issue in keycloak reported by two others
I'm not sure which change in alpha6 is causing this.
Comment #10
mstrelan commentedRemoving (un)-related issue