render() of renderer service can only accept array now, passing null lead to final error

Created on 24 June 2025, 9 days ago

Problem/Motivation

render() of renderer service can only accept array now in Drupal 11.2.0, passing null lead to final error

Steps to reproduce

1. Create a message
2. Send the message use the message_notify module
3. Or render the message in other ways to trigger the template_preprocess_message(array &$variables) hook

Proposed resolution

Don't pass null to the render() method.

  if (isset($variables['elements']['created']) && is_array($variables['elements']['created'])) {
    $variables['date'] = \Drupal::service('renderer')->render($variables['elements']['created']);
    unset($variables['elements']['created']);
  }
  if (isset($variables['elements']['uid']) && is_array($variables['elements']['uid'])) {
    $variables['author_name'] = \Drupal::service('renderer')->render($variables['elements']['uid']);
    unset($variables['elements']['uid']);
  }

Remaining tasks

none.

User interface changes

none.

API changes

none.

Data model changes

none.

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡³China 司南

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024