Warning: 'Undefined array key "separator"' when viewing revisions with Diff

Created on 7 November 2023, about 1 year ago
Updated 28 November 2023, about 1 year ago

Problem/Motivation

When using the Diff module to view differences between revisions, I see a number of warning messages at the top of my screen.

Warning: Undefined array key "separator" in /var/www/html/web/modules/contrib/office_hours/src/Plugin/Field/FieldType/OfficeHoursItem.php on line 444

When I view the code, I see:

$days_suffix = $settings['separator']['day_hours'];

The warning is because the the $settings array has no separator key defined.

Proposed resolution

Update the line to set a default separator in the case that the separator is empty. For example:

$days_suffix = $settings['separator']['day_hours'] ?? ' ';

Note: it looks like we'd have a similar issue with a grouped days separator (so I'd do a similar thing there).

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇺🇸United States sonfd Portland, ME

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

Comments & Activities

Production build 0.71.5 2024