Error when user is not found

Created on 18 July 2025, 18 days ago

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.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇮🇳India divyansh

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024