Problem/Motivation

When a user enters an invalid Drupal.org username during registration, the following fatal error occurs:

Error: Call to a member function __isset() on null in Drupal\do_username\DOUserInfoRetriever->isValidUser() (line 79 of modules/contrib/do_username/src/DOUserInfoRetriever.php)

This happens because the code attempts to call __isset() on a null value when the user validation fails.

Steps to reproduce

  1. Install the do_username module.
  2. Configure a field using the module in a user profile (e.g., using the Profile module).
  3. Visit the user registration page.
  4. Enter an invalid Drupal.org username.
  5. Submit the form.

Expected behavior: A validation message should appear stating that the username is invalid.

Actual behavior: A fatal error is thrown.

Proposed resolution

Add a null check to ensure that getUserInformation() returns a valid value before calling __isset() or any other method on it.

Remaining tasks

  • Add null check in DOUserInfoRetriever::isValidUser().
  • Write/update test coverage (if applicable).
  • Review and merge the patch.

User interface changes

None.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#5 Add user _ DrupalPod.jpeg630.97 KBbhogue
#2 3536828-2.patch529 bytesdivyansh
Command icon 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

divyansh created an issue. See original summary.

divyansh’s picture

StatusFileSize
new529 bytes

Split null check and method call to prevent fatal error when getUserInformation() returns NULL for non-existent drupal.org users.

divyansh’s picture

Assigned: divyansh » Unassigned
divyansh’s picture

Status: Active » Needs review
bhogue’s picture

StatusFileSize
new630.97 KB

Can confirm.

I replicated issue on a DrupalPod environment, getting the same error as above when entering an invalid Drupal.org username using the field provided by the module.

After applying the patch and again supplying an invalid Drupal.org username, an error message appears on the form and the field is highlighted as an error.

Screenshot of People form with new error messaging

divyansh’s picture

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

I think this also happens when drupal.org is down like on Tuesday.