Users receiving invalid warning emails

Created on 18 June 2025, about 1 month ago

Problem/Motivation

Roles with expiration period zero will get a warning email each time emails are sent.

Steps to reproduce

Configure user expire to have "Seconds of inactivity before expiring authenticated user users" set, and leave all other role settings at zero. "Send account expiration warning emails" should be checked.

  • For debugging set the "Notification frequency time (in seconds)" to 30 so you can run cron and see this each time.
  • Accounts with multiple roles will receive an email for each role, but this is more of a side-effect of this bug.

Proposed resolution

Add this line after line 325:
$rules = array_filter($rules);

Explanation

In user_expire_expire_by_role_warning() when looping through roles and the $inactivity_period is zero, a negative value gets passed on line 330:
$uids_to_warn = user_expire_find_users_to_expire_by_role($rid, $inactivity_period - $warning_offset);

This negative value is passed as $seconds_since_login so this evaluation will be a value in the future:
\Drupal::time()->getRequestTime() - $seconds_since_login

  • For example, if $warning_offset is 7 days, the access/created conditionals will check for any user that has last logged in any time before 7 days in the future.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States wsantell

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024