Event add to calendar - wrong formatting + PHP deprecation when end date is not filled in

Created on 21 July 2023, over 1 year ago
Updated 28 February 2024, 9 months ago

Problem/Motivation

When adding new event without an end date we can get following PHP deprecation:

Deprecated: DateTime::__construct(): Passing null to parameter #1 ($datetime) of type string is deprecated in /var/www/html/docroot/profiles/open_social/modules/social_features/social_event/modules/social_event_addtocal/src/Plugin/SocialAddToCalendarBase.php on line 104

Also the Add to cal link generates wrong/strange dates, when trying to add event to google calendar the end date becomes event creation date which isn't always correct.

Example:
- Event start date: 13 September 2023 14:42
- Event end date: N/A

Result link for google calendar:
http://www.google.com/calendar/event?action=TEMPLATE&text=Test%20Event&d...

Steps to reproduce

1. Use open social_event_addtocal module with php 8.x
2. Try to create new event without end date filled in

Proposed resolution

Refactor code in the plugin base:
https://github.com/goalgorilla/open_social/blob/main/modules/social_feat...

Do not process end date if it's not filled in - if the dates string in URL does not contain end date, it should fallback to event start date + 1 hour , example:
http://www.google.com/calendar/event?action=TEMPLATE&text=Test%20Event&d...

Remaining tasks

Create a patch

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Needs review

Version

11.9

Component

Code (back-end)

Created by

πŸ‡΅πŸ‡±Poland sandboxpl Poland πŸ‡΅πŸ‡±

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

Comments & Activities

Production build 0.71.5 2024