Problem/Motivation

Under some circumstances, the list_builder may loop into the $transitions variable while the variable isn't defined, causing a warning error. Even if the transitions field is required in the form, that's not consistent at data level. I fall on this while doing a custom integration where transitions are empty and the notification is triggered by an event subscriber. Here is the responsible code:

// Loop through the saved transitions.
    if ($entity->transitions) {
      $transitions = array_keys(array_filter($entity->transitions));
    }
    foreach ($transitions as $transition) {
      if (!empty($workflow_transitions[$transition])) {
        $transition_strings[] = $workflow_transitions[$transition]->label();
      }
    }

Steps to reproduce

- Create a notification
- Edit the config entity with drush cedit and make "transitions" an empty array
- Access /admin/config/workflow/notifications

Proposed resolution

Loop $transitions only if $transitions exist.

Remaining tasks

- Patch
- Review
- Test

User interface changes

None

API changes

None

Data model changes

None

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

akalam created an issue. See original summary.

akalam’s picture

Status: Active » Needs review

bkosborne made their first commit to this issue’s fork.

bkosborne’s picture

Status: Needs review » Fixed

Makes sense. Thanks!

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

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

Maintainers, please credit people who helped resolve this issue.

  • bkosborne committed dda733b3 on 8.x-3.x authored by akalam
    [#3291658] fix: list_builder may loop on $transitions when the variable...

Status: Fixed » Closed (fixed)

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