Error when trying to render a group permission revision

Created on 27 January 2023, almost 2 years ago
Updated 6 February 2023, almost 2 years ago

Problem/Motivation

When trying to view a group permission revision under PHP 8.1, errors are thrown due to a bug in the code.

The error is in GroupPermissionsController::revisionPageTitle, where in line 302 the title of the revision is set to `$group_permission->label()`. This returns NULL, as the GroupPermission entity does not have a label field. This breaks under PHP 8.1 because now the inner workings of the t function put NULL into htmlspecialchars:

Deprecated function: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Component\Utility\Html::escape() (line 424 of core/lib/Drupal/Component/Utility/Html.php).
Drupal\Component\Utility\Html::escape(NULL) (Line: 262)
Drupal\Component\Render\FormattableMarkup::placeholderEscape(NULL) (Line: 232)
Drupal\Component\Render\FormattableMarkup::placeholderFormat('%title (Rev. %revision)', Array) (Line: 195)
Drupal\Core\StringTranslation\TranslatableMarkup->render() (Line: 15)
Drupal\Core\StringTranslation\TranslatableMarkup->__toString() (Line: 1)
...

Steps to reproduce

1. View a URL like `/group/1/permissions/revision/2?group_permission=2` under PHP 8.1 or newer

Proposed resolution

Decide for something else to use as title or implement the label function. Something like "Group permissions for group 123" seems like a good fit for the headline of the page.

Remaining tasks

- Write a patch
- Write a test case

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇩🇪Germany ammaletu Bonn, Germany

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

Comments & Activities

Production build 0.71.5 2024