TranslatableMarkup trigger InvalidArgumentException: $string ("...") must be a string

Created on 12 January 2024, 10 months ago
Updated 26 January 2024, 10 months ago

Problem/Motivation

Error log message should be a TranslatableMarkup message too. If so, not the rendered string/message will be sent (inserted to queue), but another error will be thrown:
InvalidArgumentException: $string ("...") must be a string. in Drupal\Core\StringTranslation\TranslatableMarkup->__construct()

Steps to reproduce

Trigger an error, where the error message is TranslatableMarkup.

I checked with the feeds module, with invalid items, and got:
InvalidArgumentException: $string ("@feed: Failed importing @count @item.@feed: Failed importing @count @items.") must be a string

With purge module:
InvalidArgumentException: $string ("Exception while trying to invalidate the items: @error") must be a string.

Proposed resolution

Transfer/render TranslatableMarkup to string.

🐛 Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

🇭🇺Hungary szato

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

Comments & Activities

Production build 0.71.5 2024