Problem/Motivation

The NotificationRequiredCondition plugin (id purge_users:notification_required, labeled Users pre-notified only) is supposed to allow purging only for users who have received the pre-deletion notification. Today it is too permissive: it does an INNER JOIN on purge_users_notifications without filtering on the type column, so any row satisfies the condition — including rows with type = 'purge_users' written by UserManagementService::notifyUserToPurge() right before deletion.

The purge_users_notifications table carries two type values:

  • 'notification_users' — written by notifyUser(), the pre-deletion heads-up.
  • 'purge_users' — written by notifyUserToPurge(), the last-minute mail sent at deletion time.

Only the first type represents a "pre-notification", so only it should satisfy the Users pre-notified only condition.

For reference, the global path PurgeUsersHelper::checkNotification() introduced by MR !51 on #3521201 already filters ->condition('pun.type', 'notification_users'). The condition path should match.

Steps to reproduce

  1. Create a policy with the Users pre-notified only condition.
  2. Seed a user with only a 'purge_users' row in purge_users_notifications (no 'notification_users' row).
  3. Run the purge. Observe: the user is purged even though they were never pre-notified.

Proposed resolution

In src/Plugin/Condition/NotificationRequiredCondition.php, extend the innerJoin predicate:

$query->innerJoin(
  'purge_users_notifications',
  'pun',
  'pun.uid = u.uid AND pun.timestamp < :delay AND pun.type = :type',
  [':delay' => $notification_delay, ':type' => 'notification_users']
);

Remaining tasks

  • Add the type filter to the inner join.
  • Add kernel coverage for the condition's behavior across the four type-combinations (only notification_users, only purge_users, both, none).

User interface changes

None.

API changes

None.

Data model changes

None.

Related

  • #3521201 — global path introducing checkNotification() with the type filter.
  • #3585503 — auto-flagging users with unsendable emails (relies on consistent condition semantics).
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

mably created an issue. See original summary.

  • mably committed dd5fe2b6 on 5.x
    fix: #3585521 NotificationRequiredCondition should filter...
mably’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.