[D10] Drupal\Core\Language\Language passed as plain_text in render array

Created on 10 August 2023, over 1 year ago
Updated 3 October 2023, about 1 year ago

Problem/Motivation

Normal usage of module causes TypeError: htmlspecialchars(): Argument #1 ($string) must be of type string, Drupal\Core\Language\Language given in htmlspecialchars()

Steps to reproduce

Proposed resolution

Original code:

protected function viewValue(FieldItemInterface $item) {
    return [
      '#plain_text' => $item->language ?? $item->language->getId(),
    ];
}

Invalid use of ?? operator, which should be replaced with:

protected function viewValue(FieldItemInterface $item) {
    return [
      '#plain_text' => $item->language ? $item->language->getId() : null,
    ];
}

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇵🇱Poland prauat Wroclaw

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

Comments & Activities

Production build 0.71.5 2024