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
Issue fork content_moderation_notifications-3291658
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 #3
akalam commentedComment #5
bkosborneMakes sense. Thanks!