calendar_link() fails silently if date is string but can't be parsed

Created on 10 October 2023, about 1 year ago

Problem/Motivation

If the input date value is a string but does not contain a parseable <time>, the Twig function throws a TypeError rather than a Twig RuntimeError.

This is because \Drupal\calendar_link\Twig\CalendarLinkTwigExtension::getDateTime() calls get_class() which can only be used on objects.

Steps to reproduce

{% set link = calendar_link('ics', "Test", 'Dec 16, 2021', 'Dec 17, 2021', "Description", "Title") %}
<a href="{{ link }}">Add to calendar</a>

Observed on drupal/calendar_link:3.0.2.

Proposed resolution

We're already throwing an exception here, we just don't throw the one we'd expect to.

Not critical but figured I'd raise it while I saw it.

Remaining tasks

  1. Add test coverage
  2. Implement fix

User interface changes

API changes

Data model changes

๐Ÿ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand xurizaemon ลŒtepoti, Aotearoa ๐Ÿ

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