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.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | moderated_content_bulk_publish-3380518-7.patch | 14.93 KB | csmdgl |
| #2 | moderated_content_bulk_publish-3380518-3.patch | 3.28 KB | mohd sahzad |
| moderated_content_bulk_publish_utf8_encode.patch | 14.56 KB | misterdidi |
Comments
Comment #2
mohd sahzad commentedi have fixed PHP 8.2 utf8_encode() compatibility issue
Comment #3
noorulshameera commentedI verified that patch #2 applied cleanly and it replaces all the occurrences of the deprecated function utf8_encode() in the code.
Comment #5
joseph.olstadThe first patch was taken and committed (thank you), the patch 3 was incomplete.
3.0.x likely has the same issue
Comment #6
joseph.olstadFixed in 2.0.26
Thank you to the above
https://www.drupal.org/project/moderated_content_bulk_publish/releases/2...
3.0.x needs work
Comment #7
csmdgl commentedPatch for 3.0.x
Comment #9
joseph.olstadComment #10
joseph.olstadhttps://www.drupal.org/project/moderated_content_bulk_publish/releases/3...
Comment #11
joseph.olstadThanks @csmdgl , great work!