Start date of weekly reccurring event jumps incorrectly

Created on 31 May 2024, 6 months ago
Updated 26 June 2024, 5 months ago

Problem/Motivation

When creating an event series with the recurrence type weekly_recurring_date, the module attempts to determine the date of the first instance based on the start_date and the selected weekdays.

For example, if an event series is created with a start_date of 08-08-2024 and an end_date of 08-23-2024, with Thursday selected as the recurrence day, the module should create an instance for every Thursday within these dates.

In this example, 08-08-2024 is a Thursday, so it should be expected that the dates 08-08-2024, 08-15-2024, and 08-22-2024 would be created.

However, I have discovered that if the weekdays are translated using Drupal's translation system, the module does not create an instance for 08-08-2024. This occurs because the comparison between the weekday of the start_date and the selected weekday is not using the same language.

If the current language in the admin interface is different from English, the weekday of the start_date will be translated to the selected admin language. This results in a mismatch with the weekdays saved in the database, which are always in English.

Steps to reproduce

1. Ensure that your site has multiple languages, that the admin interface is set to a language other than English, and the day your are testing (thursday, in this example) is translated.
2. Create an event series with the following details:
- start_date: 08-08-2024
- end_date: 08-23-2024
- Recurrence day: Thursday
3. Save the event series and check the created instances.

Expected behavior: Instances should be created for 08-08-2024, 08-15-2024, and 08-22-2024.

Actual behavior: The instance for 08-08-2024 is not created.

4 (Optionally). Switch your language back to english, redo the process and verify that the instance for 08-08-2024 is created.

Proposed resolution

Replacing format('l') with getPhpDateTime()->format('l') ensures the weekday comparison uses a standard PHP DateTime object, avoiding translation issues and keeping the comparison consistent regardless of the admin interface language.

Remaining tasks

n/a

User interface changes

n/a

API changes

n/a

Data model changes

n/a

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Recurring Events (Main module)

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