InvalidArgumentException empty string

Created on 24 October 2022, about 2 years ago
Updated 8 June 2023, over 1 year ago

Problem/Motivation

The module produces this fatal error when I enabled it in views field format.

InvalidArgumentException: $string ("") must be a string. in Drupal\Core\StringTranslation\TranslatableMarkup->__construct() (line 132 of /app/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php).

πŸ› Bug report
Status

Closed: duplicate

Version

9.0

Component

Code

Created by

πŸ‡ͺπŸ‡ͺEstonia ram4nd Tallinn

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • @bbu23 opened merge request.
  • Status changed to Needs review over 1 year ago
  • πŸ‡·πŸ‡΄Romania bbu23

    Not sure exactly why the "single" option was removed, but the problem comes from this:

    if (!array_key_exists($delta, $elements)) {
      // No end date provided or end date equals start date use single formatting.
      $single_format = $this->getSetting('single');
      $elements[$delta] = ['#markup' => \Drupal::service('date.formatter')->format($start_date, 'custom', t($single_format))];
    }
    

    When the single option was removed, there was still this piece of code that was trying to get that setting and use it. I've replaced that with one_day, but also removed the if ($start_date !== $end_date) { earlier in the execution. Not sure why that "if" is needed, so please correct me if I'm wrong, but in that "if" we have the following:

    if (date('d.m.Y', $start_date) === date('d.m.Y', $end_date)) {
      $format = $this->getSetting('one_day');
    }
    

    So, if the start date and end date are equal, this line is never reached. This is why I removed it because if they're equal, it should go through the one_day setting (unless there's something I don't see).

  • Status changed to Closed: duplicate over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States jeffam

    There's a patch in πŸ› Passing empty value to t() when same day + time for start and end date RTBC that prevents the error, but doesn't quite fix the formatting issue.

Production build 0.71.5 2024