Undefined array key scheduled in WorkflowTransitionTimestamp.php

Created on 30 October 2024, 3 months ago

When a user edits a node with a workflow, we sometimes get this:

Warning: Undefined array key "scheduled" in Drupal\workflow\Element\WorkflowTransitionTimestamp::valueCallback() (regel 52 van /data/code/jobbonus/www/modules/contrib/workflow/src/Element/WorkflowTransitionTimestamp.php)

Looking at the current code:

 public static function valueCallback(&$element, $input, FormStateInterface $form_state) {
 ...
    // Fetch $timestamp from widget for scheduled transitions.
    $scheduled = (bool) $input['scheduled'] ?? '0';
    if ($scheduled) {
      $schedule_values = $input['date_time'];

I think changing it to this will fix the warning (and be more correct):

 public static function valueCallback(&$element, $input, FormStateInterface $form_state) {
 ...
    // Fetch $timestamp from widget for scheduled transitions.
    $scheduled = (bool)($input['scheduled'] ?? false);
    if ($scheduled) {
      $schedule_values = $input['date_time'];

- Changing '0' to false (why an extra conversion?)
- Extra () around the expression so the coalescing happens first

🐛 Bug report
Status

Active

Version

1.8

Component

Code

Created by

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024