Problem/Motivation
My site is giving the following error: Warning: Undefined array key "all_day_format" in Drupal\office_hours\Plugin\Field\FieldType\OfficeHoursItemList->formatTimeSlots() (line 511 of /modules/contrib/office_hours/src/OfficeHoursFormatterTrait.php)
Steps to reproduce
Go to a node that does not have all_day_format but does have the office hours enabled. Then you will see the following notice in the log when visiting the node.
Proposed resolution
Apply patch / merge the following code.
Remaining tasks
Make a merge request.
User interface changes
None
API changes
None
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| added-office-hours-fix.patch | 642 bytes | remco hoeneveld |
Issue fork office_hours-3460118
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 #4
rishabjasrotia commentedComment #5
abhiyanshu commentedThe attached patch is working fine, and I am no longer getting the warning of an undefined array.
Moving it to RTBC. Thanks!
Comment #6
johnvWow, this is an example of fast cooperation.
Alas, the suggested patch/MR only repairs the symptom.
Following a 'root cause analysis' approach, the function
formatTimeSlots(array $office_hours, array $settings, array $field_settings)receives the$settingsarray, which should have passed theOfficeHoursFOrmatterBase::defaultSettings()function, that fills the required field.The correct patch should ensure that this happens.
Comment #7
johnvOh, and line 511 is not relevant for this issue in the dev version.
I guess, OP uses 1.17 version, not dev version. Please state correct version, then test with current dev version. The error should not appear (at least, I cannot reproduce the error.)
Comment #8
remco hoeneveld commentedAah check thanks for letting us know ill test with latest version, i was indeed working with 1.17 version.
Comment #9
johnvComment #10
johnvFor the same problem, I opened and fixed #3475522: Warning: Undefined array key "all_day_format" in OfficeHoursItemList->formatTimeSlots() (line 531 of \OfficeHoursFormatterTrait.php), having forgotten the existence of this issue.
Please check the latest version (1.19 or dev) and close the issue if the problem is solved, or re-open if not.
Comment #11
rishabjasrotia commented