Problem/Motivation
The formatter shows an empty row: Closed, with no day label. This happens whenever:
- Number of days to show: Show only current day is enabled, and
- Group consecutive days with same hours into one set is enabled, and
- today is grouped with other days and
- today is not the last day of its group.
Each rendering logs these PHP warnings:
Warning: Undefined array key "day" in OfficeHoursItemListFormatter->formatComments()
Warning: Undefined array key "items" in OfficeHoursItemListFormatter->formatComments()
Warning: Undefined array key "label" in OfficeHoursThemeHooks->preprocessOfficeHours()
Deprecated function: mb_strlen(): Passing null to parameter #1 ($string)With Monday–Friday 9:00–17:00, it is wrong Monday to Thursday and right on Friday. With the same hours every day, it is wrong six days a week.
Function groupDays() keeps a group under the key of its last day, with its first and last day in 'day' and 'endday'.
Function keepCurrentDay() looks today up by its own key:
$result[$day_number] = $office_hours[$day_number] ?? [];
if (!$result) {
foreach ($office_hours as $key => $info) {
// Because of grouped days, no direct read possible.
By then $result already holds the empty row, so !$result is never true and the loop meant for grouped days never runs. Even if it ran, the loop could not find a group that runs past Saturday into Sunday ('day' 6, 'endday' 0), as its
@todo says. That happens when the first day of the week is not Sunday.
Related: #3022029: Error in "Show only current day" depending on start of week, an earlier fix of 'Show only current day' depending on the first day of the week.
Steps to reproduce
1. Create an office_hours field with Monday–Friday 09:00–17:00.
2. Set its formatter to Show only current day, with Group consecutive days with same hours on.
3. View it on a Monday, Tuesday, Wednesday or Thursday: it shows Closed with no day, and warnings appear in the log.
With Group consecutive days off, or on a Friday, it shows the day and its hours.

Proposed resolution
Look today up by its key. If it isn't there, return the row of the group that contains it. A new isDayInGroup() does this by counting the days from the first day of the group, so a group running into Sunday is found too. It leaves the
season and exception captions out.
The current day of a group is then shown with the label of the group (Monday - Friday: 9:00-17:00), as Show next open day already does.
A new kernel test, OfficeHoursCurrentDayKernelTest, covers:
- the same hours every day, with each first day of the week from Sunday to Saturday. This puts today at the first day of the group, its last day, in between, and in a group that runs into Sunday;
- a group of closed days around today.
Both tests fail on 8.x-1.x (06f122b). They pass with the change, and so do the existing Kernel and Unit tests.
Remaining tasks
- Review.
- Decide whether the current day should keep its own label (Tuesday) instead of the group's.
AI Disclosure
This came up while generating a demo for #3630716: Office Hours example module.
I validated the issue, but the analysis, recommendations, and patch need thorough review.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | Screenshot 2026-10-13 at 13-31-49 Manage display Office Hours demo.png | 78.93 KB | mortona2k |
| current-day-grouped-greenleaf.png | 64.6 KB | mortona2k |
Issue fork office_hours-3630718
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 #2
mortona2k commentedComment #4
mortona2k commentedComment #5
mortona2k commentedComment #6
mortona2k commentedThe fix in place corrects the empty day when today is in a group.
But setting "show next open day" or "show only current day" implies showing only the next day, not the next group.
This screenshot shows the existing, fixed, and alternative displays.
___
I updated the Group consecutive days description to clarify that it groups items when show current/next day is set, and only the one day when unset.
We may want to expand on this in the future, to be able to show the current day hours in the current status settings, and something else beneath it, like the full schedule with groups.
Comment #7
mortona2k commentedUpdated setting description:

Comment #8
johnvComment #10
johnvThanks. Committed a shorter version.
Comment #12
mortona2k commentedClaude code review of committed change:
Comment #13
johnvComment #16
johnvPlease try again.
I added cloning of $items, to avoid severl formatters to influence eachother. That was already in place in other locations.
Comment #18
mortona2k commentedClaude found numerous issues including #12 is not fixed and #16 is not accurate, and there are a handful of code issues.
Comment #19
johnvComment #20
johnvOK, AI sneaked in a requirement that was not in OP: First day of week is not Sunday.
Indeed, I noticed that while investigating the problem, and left it as a to-do.
We need a new ticket for that, since the initial problem is fixed.
Comment #22
johnvIt should now be fixed.
The only problem left seems to: 'Show only open days' when a week or season has no open days. Then, no caption 'Closed' is displayed.
Comment #26
johnv