Problem/Motivation

After updating a site to Drupal 11, the Message Recipient UI fails with a fatal error when opening the Recipients Collectors configuration form.

Drupal 11 introduced stricter typing for Drupal\Component\Utility\Html::escape(), which now requires a plain string as its argument. The Message Recipient module currently passes a TranslatableMarkup object directly to Html::escape(), resulting in a TypeError.

TypeError: Drupal\Component\Utility\Html::escape(): Argument #1 ($text) must be of type string, Drupal\Core\StringTranslation\TranslatableMarkup given, called in /modules/contrib/message_recipient/src/RecipientsCollectorManager.php on line 49 Drupal\Component\Utility\Html::escape() Drupal\message_recipient\RecipientsCollectorManager->getDefinitionsListOptionsGroupedByCategory() Drupal\message_recipient_ui\Form\RecipientsCollectorsForm->buildForm()

Steps to reproduce

Install Message Recipient on a Drupal 11 site.
Navigate to the Message Recipient UI configuration page that displays recipient collectors.
Open the form that triggers RecipientsCollectorsForm::buildForm().

Proposed resolution

Render the TranslatableMarkup object before passing it to Html::escape().
Alternatively, cast/render the value to a string before calling Html::escape().

Comments

peter_serfozo created an issue. See original summary.

peter_serfozo’s picture

peter_serfozo’s picture

Status: Active » Needs review
angel_devoeted’s picture

StatusFileSize
new6.59 KB
new21.23 KB

Tested patch on a clean Drupal 11 environment via DrupalPod.

Opening the recipients collectors form initially throws a fatal TypeError in Html::escape(). With the patch applied, the form loads successfully without any issues and logs remain clean.

The fix looks solid.
@peter_serfozo, if possible, please consider converting this patch into a Merge Request.

before

after

shank115’s picture

Can confirm, patch worked for me as well. Thanks!!