Day 0 missing in 1.9 on PHP8

Created on 26 May 2023, over 1 year ago
Updated 9 June 2023, over 1 year ago

Problem/Motivation

When using 1.9 of the module, when you go to enter a new office hours, Sunday is missing.

Steps to reproduce

Add office hours field, try to edit new office hours and the Sunday is missing (Chrome and Firefox for sure):

Once you save the node and then try to edit it again, two Mondays appear:

Proposed resolution

Trying to find the solution but having issues, any suggestions would help?

🐛 Bug report
Status

Fixed

Version

1.9

Component

Code - widget

Created by

🇨🇦Canada ebremner

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

Comments & Activities

  • Issue created by @ebremner
  • 🇳🇱Netherlands johnv

    Please check dev. It must be solved. If so, i Will create a New release asap.

  • 🇨🇦Canada ebremner

    Still happening in dev.

  • 🇳🇱Netherlands johnv

    Ok, I misread your post.
    you have no yrouble with the data, but only with the title of the aunday weekday. Correct?

    BTW, please Share your field setting. I do not know how you get the HTML5 ampm output. I cannot reproduceren that.

  • 🇨🇦Canada ebremner

    See screenshots attached for all field settings.

  • 🇨🇭Switzerland pvbergen

    We encountered the same problem after upgrading to 1.9. from 1.8 in several of our projects.
    Comparing the database backups before and after the upgrade shows a change in the field tables (node__field_ZZZ, node_revision__field_ZZZ) on column `field_ZZZ_day`.

    Before update

    After update

    This happens for all revisions, so I assume office_hours_update_8005 is the cause.
    My working theory is that updating the schema update somehow causes to misalign the indexing and causing it to shift.
    I'm not sure how exactly this would happen, though.

    Quick fix
    For now, we could resolve the issue by downgrading to 1.8 and reset/manually re-enter the values from the backup.
    This seems to work reliably.

  • 🇨🇭Switzerland pvbergen

    Ignore my previous comment about the update hook. The data changes only after saving the node with 1.9.
    The update hook does not change the values in the database.

  • 🇨🇭Switzerland pvbergen

    After digging through the code I found the issue and provided a fix in the MR.

    OfficeHoursItem::formatValue checks whether the day within the data is valid and is called in OfficeHoursItem::setValue.
    In 1.9 there was code introduced to handle exception days: https://git.drupalcode.org/project/office_hours/-/compare/8.x-1.8...8.x-...

    On the above line, it checks whether $day is an exception from the schedule.
    Unfortunately, ((int) 0 == 'exception_day_delta') === TRUE , setting $day = $previous_day; // $previous_day = 6 and thus making all sundays into saturdays.

    I've manually testet that changing this to (int) 0 === 'exception_day_delta' resolves the issue for us.

    As this causes data corruption/loss I increase the priority to "Critical".

  • Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    Waiting for branch to pass
  • @pvbergen opened merge request.
  • Status changed to Needs review over 1 year ago
  • 🇳🇱Netherlands johnv

    Thanks,
    i will add the proposed solution.

  • Status changed to Fixed over 1 year ago
  • 🇳🇱Netherlands johnv

    Thanks for the fix. apparently, I am still developing on PHP7.

    @Eric, please confirm that dev now works fine.

  • 🇨🇦Canada ebremner

    Hey it works now, thanks for the quick fix. Are you going re-release 1.9 or make a 1.10 release?

    Thanks!!

  • 🇳🇱Netherlands johnv

    Perfect. There will be a new version within 2 weeks.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024