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 bynotifyUser(), the pre-deletion heads-up.'purge_users'— written bynotifyUserToPurge(), 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
- Create a policy with the Users pre-notified only condition.
- Seed a user with only a
'purge_users'row inpurge_users_notifications(no'notification_users'row). - 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 (onlynotification_users, onlypurge_users, both, none).
User interface changes
None.
API changes
None.
Data model changes
None.
Related
Issue fork purge_users-3585521
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 #4
mably commented