Score:-3

I'm not quite sure what this error is but it's breaking my site

br flag

Can anyone help me in discovering what is wrong and what needs to be fixed? I did a bunch of updates and now certain portions of my site don't work. I get the following error:

The website encountered an unexpected error. Please try again later.

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

t() (Line: 81)
Drupal\date_range_formatter\Plugin\Field\FieldFormatter\DateRangeFormatterRangeFormatter->viewElements() (Line: 89)
Drupal\Core\Field\FormatterBase->view() (Line: 263)
Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple() (Line: 340)
Drupal\Core\Entity\EntityViewBuilder->buildComponents() (Line: 282)
Drupal\Core\Entity\EntityViewBuilder->buildMultiple() (Line: 18)
Drupal\paragraphs\ParagraphViewBuilder->buildMultiple() (Line: 239)
Drupal\Core\Entity\EntityViewBuilder->build()
call_user_func_array() (Line: 101)
Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 772)
Drupal\Core\Render\Renderer->doCallback() (Line: 363)
Drupal\Core\Render\Renderer->doRender() (Line: 201)
Drupal\Core\Render\Renderer->render() (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 67)
__TwigTemplate_1374a0db93cb5ffb66a86c8e82b2cfe483209a1e42126eef3a571177931e1ea8->doDisplay() (Line: 405)
Twig\Template->displayWithErrorHandling() (Line: 378)
Twig\Template->display() (Line: 390)
Twig\Template->render() (Line: 55)
twig_render_template() (Line: 384)
Drupal\Core\Theme\ThemeManager->render() (Line: 422)
Drupal\Core\Render\Renderer->doRender() (Line: 435)
Drupal\Core\Render\Renderer->doRender() (Line: 201)
Drupal\Core\Render\Renderer->render() (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 69)
__TwigTemplate_360f5440ca76b514a17b345e7d36b2699abc51c84808d584bd67804dbd080ed9->block_content() (Line: 182)
Twig\Template->displayBlock() (Line: 57)
__TwigTemplate_360f5440ca76b514a17b345e7d36b2699abc51c84808d584bd67804dbd080ed9->block_paragraph() (Line: 182)
Twig\Template->displayBlock() (Line: 45)
__TwigTemplate_360f5440ca76b514a17b345e7d36b2699abc51c84808d584bd67804dbd080ed9->doDisplay() (Line: 405)
Twig\Template->displayWithErrorHandling() (Line: 378)
Twig\Template->display() (Line: 390)
Twig\Template->render() (Line: 55)
twig_render_template() (Line: 384)
Drupal\Core\Theme\ThemeManager->render() (Line: 422)
Drupal\Core\Render\Renderer->doRender() (Line: 201)
Drupal\Core\Render\Renderer->render() (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 124)
__TwigTemplate_1374a0db93cb5ffb66a86c8e82b2cfe483209a1e42126eef3a571177931e1ea8->doDisplay() (Line: 405)
Twig\Template->displayWithErrorHandling() (Line: 378)
Twig\Template->display() (Line: 390)
Twig\Template->render() (Line: 55)
twig_render_template() (Line: 384)
Drupal\Core\Theme\ThemeManager->render() (Line: 422)
Drupal\Core\Render\Renderer->doRender() (Line: 435)
Drupal\Core\Render\Renderer->doRender() (Line: 201)
Drupal\Core\Render\Renderer->render() (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 110)
__TwigTemplate_34f26291d58dc980f31587baa8f8f2a6c0775ce1b84fbec586439fd99fe6c0eb->doDisplay() (Line: 405)
Twig\Template->displayWithErrorHandling() (Line: 378)
Twig\Template->display() (Line: 390)
Twig\Template->render() (Line: 55)
twig_render_template() (Line: 384)
Drupal\Core\Theme\ThemeManager->render() (Line: 422)
Drupal\Core\Render\Renderer->doRender() (Line: 201)
Drupal\Core\Render\Renderer->render() (Line: 241)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 242)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 132)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
call_user_func() (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 174)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 23)
Stack\StackedHttpKernel->handle() (Line: 709)
Drupal\Core\DrupalKernel->handle() (Line: 19)

I'm happy to supply whatever info you need, just let me know and I can add more.

id flag
Which precise updates did the site receive? Do you have a PHP debugger? Are there custom or pre-release modules installed? Are all installed contributed modules up-to-date?
Score:2
cn flag

Can anyone help me in discovering what is wrong?

When you look up this part of the stack trace:

t() (Line: 81)
Drupal\date_range_formatter\Plugin\Field\FieldFormatter\DateRangeFormatterRangeFormatter->viewElements() (Line: 89)

you find the error in these lines of the contrib module Date range formatter:

$single_format = $this->getSetting('single');
$elements[$delta] = ['#markup' => \Drupal::service('date.formatter')
  ->format($start_date, 'custom', t($single_format))];

The problem is a missing setting single, probably a date format string you have to set in the field display settings. If you can't find it in UI then export the config and check the YAML files of the content type where this field is configured.

... and what needs to be fixed?

It seems like this is already fixed in the modules issue queue. Try this patch:

diff --git a/src/Plugin/Field/FieldFormatter/DateRangeFormatterRangeFormatter.php b/src/Plugin/Field/FieldFormatter/DateRangeFormatterRangeFormatter.php
index 798ce2b..6635ac8 100644
--- a/src/Plugin/Field/FieldFormatter/DateRangeFormatterRangeFormatter.php
+++ b/src/Plugin/Field/FieldFormatter/DateRangeFormatterRangeFormatter.php
@@ -77,7 +77,7 @@ class DateRangeFormatterRangeFormatter extends DateTimeCustomFormatter {
         }
         if (!array_key_exists($delta, $elements)) {
           // No end date provided or end date equals start date use single formatting.
-          $single_format = $this->getSetting('single');
+          $single_format = $this->getSetting('one_day');
           $elements[$delta] = ['#markup' => \Drupal::service('date.formatter')->format($start_date, 'custom', t($single_format))];
         }
       }

https://www.drupal.org/project/date_range_formatter/issues/3309324#comment-14755079

ACanadianCoder avatar
br flag
Thank you @4uk4! Your answer was very helpful and also solved the problem on my site. The date_range_formatter part just sort of blended in with everything else so I felt lost lol. Thanks again!
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.