- Issue created by @nicrodgers
- 🇳🇿New Zealand quietone
Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to our policies.
The signature for EntityInterface::label():
/**
* Gets the label of the entity.
*
* @return string|\Drupal\Core\StringTranslation\TranslatableMarkup|null
* The label of the entity, or NULL if there is no label defined.
*/
public function label();
It allows an entity to return NULL as a label, which basically means that the entity does not have a label at all.
ContentTranslationHandler::entityFormAlter has this line:
$t_args = ['%language' => $languages[$form_langcode]->getName(), '%title' => $entity->label(), '@title' => $title];
But since this change → in Drupal 11, it is not allowed to use a NULL value as an argument value. That means these pages become unavailable because of this.
The website encountered an unexpected error. Try again later.
TypeError: Drupal\Component\Utility\Html::escape(): Argument #1 ($text) must be of type string, null given, called in /var/www/html/web/core/lib/Drupal/Component/Render/FormattableMarkup.php on line 256
Create an entity without a label.
Go to translate it.
Change the code to handle null labels, perhaps something like this?
$label = $entity->label() ?? $entity->getEntityType()->getSingularLabel();
$t_args = ['%language' => $languages[$form_langcode]->getName(), '%title' => $label, '@title' => $title];
* Agree on approach
* Write test
* Update code
none
none
none
none
none
Active
11.1 🔥
content_translation.module
Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to our policies.