Hook maestro_zero_user_notification triggered when no notifications are set on task

Created on 18 January 2024, 5 months ago
Updated 8 March 2024, 4 months ago

Problem/Motivation

Finding a proper title for this issue is tricky, but the issue is that the maestro_zero_user_notification may be triggered when no notifications are set on a task. See Steps to reproduce for details.

Steps to reproduce

  1. Create a Maestro task
  2. Edit the task and set up a notification
  3. Edit the task and remove the notification

The task configuration now contains (excerpt)

tasks:
  my_task:
    notifications:
      notification_assignments: ''
      …

i.e. notification_assignments is present, but empty.

This triggers a bug in https://git.drupalcode.org/project/maestro/-/blob/3.1.0/src/Engine/Maest...

  1. $notifications will equal [""]
  2. $thisNotification will become [""]
  3. $thisNotification[3] == $notificationType is FALSE (it triggers Warning: Undefined array key 3)

We end up in https://git.drupalcode.org/project/maestro/-/blob/3.1.0/src/Engine/Maest... with an empty $notificationList and maestro_zero_user_notification is triggered (if maestro_token_zero_user is set).

Proposed resolution

The patch https://github.com/itk-dev/os2forms_selvbetjening/blob/b7f3b9c81bc9bba03a1b4b7e4c726bea0e64e2db/patches/drupal/maestro/maestro_notification.patch contains a quick fix.

A better fix will do something like checking that count($thisNotification) === 4 and set a boolean variable to tell that some notifications have been asked for. maestro_zero_user_notification should then only be triggered said boolean variable is set.

πŸ› Bug report
Status

Fixed

Version

3.1

Component

Code

Created by

πŸ‡©πŸ‡°Denmark rimi@aarhus.dk

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

Comments & Activities

Production build 0.69.0 2024