InvalidArgumentException: $string ("1") must be a string.

Created on 26 July 2024, 5 months ago

Problem/Motivation

Using Style Guide upon installation, I encountered this error:

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

t() (Line: 237)
__TwigTemplate_1187302a609a1238165d27d3136327f3->doDisplay() (Line: 360)
Twig\Template->yield() (Line: 41)
__TwigTemplate_bb6e7a3515e4fa69e1fc5504f482cb07->doDisplay() (Line: 360)
Twig\Template->yield() (Line: 335)
Twig\Template->render() (Line: 38)
Twig\TemplateWrapper->render() (Line: 33)
twig_render_template() (Line: 348)
Drupal\Core\Theme\ThemeManager->render() (Line: 491)
Drupal\Core\Render\Renderer->doRender() (Line: 504)
Drupal\Core\Render\Renderer->doRender() (Line: 248)
Drupal\Core\Render\Renderer->render() (Line: 475)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 63)
__TwigTemplate_3ee2ddcecac85699b6530b5e385cce5f->doDisplay() (Line: 360)
Twig\Template->yield() (Line: 335)
Twig\Template->render() (Line: 38)
Twig\TemplateWrapper->render() (Line: 33)
twig_render_template() (Line: 348)
Drupal\Core\Theme\ThemeManager->render() (Line: 491)
Drupal\Core\Render\Renderer->doRender() (Line: 504)
Drupal\Core\Render\Renderer->doRender() (Line: 248)
Drupal\Core\Render\Renderer->render() (Line: 475)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 40)
__TwigTemplate_d6b02a23d3115226a406ba6be7cca9bc->doDisplay() (Line: 360)
Twig\Template->yield() (Line: 335)
Twig\Template->render() (Line: 38)
Twig\TemplateWrapper->render() (Line: 33)
twig_render_template() (Line: 348)
Drupal\Core\Theme\ThemeManager->render() (Line: 491)
Drupal\Core\Render\Renderer->doRender() (Line: 504)
Drupal\Core\Render\Renderer->doRender() (Line: 248)
Drupal\Core\Render\Renderer->render() (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 231)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare() (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
call_user_func() (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 54)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->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: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Steps to reproduce

This issue was encountered upon installation. These are the environment details of my site:

Drupal: 10.3.1 (Varbase (varbase-10.0.0))
Apache/2.4.61 (Debian)
PHP 8.3.9
MySQL 8.0.39

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡΅πŸ‡­Philippines Squiggles

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

Comments & Activities

  • Issue created by @Squiggles
  • πŸ‡΅πŸ‡­Philippines mikeocana

    I can't reproduce the issue using D10.2.6. I will try using 10.3.1

  • πŸ‡ΊπŸ‡ΈUnited States dcam

    Just an educated guess, but a possible of this is line 109 of StyleguideController:

    $item['title'] = $this->t('@title', ['@title' => $item['title']]);
    

    As you know some parts of the styleguide are dynamically generated and are dependent on your specific site's configuration, namely the image styles and layouts. If any of them are named '1', then that's how this could happen. You can test it by casting the item title to a string like this:

    $item['title'] = $this->t('@title', ['@title' => (string) $item['title']]);
    
Production build 0.71.5 2024