PHP 8.2 utf8_encode() compatibility issue

Created on 10 August 2023, 11 months ago
Updated 12 October 2023, 9 months ago

Problem/Motivation

utf8_encode() function has been deprecated as of php8.2.0. This function is used in many places to encode log messages or interface messages when performing bulk actions, resulting in the display of Drupal warning messages such as "Deprecated function: Function utf8_encode() is deprecated in Drupal\moderated_content_bulk_publish\AdminModeration->unpublish() (line 44 of modules/contrib/moderated_content_bulk_publish/src/AdminModeration.php)." when performing bulk actions.

Steps to reproduce

  • Drupal 9/10 + php8.2
  • Out of the box editorial workflow
  • Perform any bulk action on moderated content (Publish/Unpublish latest revision, Pin/Unpin content, Archive current revision)

The action performs well, but Drupal warning messages are displayed.

Proposed resolution

Follow recommendation of official php documentation and replace use of utf8_encode() with mb_convert_encoding() function.

Attached is a patch that follows the above recommendation.

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
  • PHP 8.2

    The issue particularly affects sites running on PHP version 8.2.0 or later.

Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024