Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] utf8_encode() has been deprecated. #988

Closed
rosiel opened this issue Oct 25, 2023 · 2 comments
Closed

[BUG] utf8_encode() has been deprecated. #988

rosiel opened this issue Oct 25, 2023 · 2 comments

Comments

@rosiel
Copy link
Member

rosiel commented Oct 25, 2023

PHP Note: https://php.watch/versions/8.2/utf8_encode-utf8_decode-deprecated

What steps does it take to reproduce the issue?

Resolution

mbstring, iconv and intl are suggested as replacements, but I don't know enough to suggest which one (or combination) to use, or whether we have access to these extensions in the default deployment.

@adam-vessey
Copy link

adam-vessey commented Oct 25, 2023

Given the utf8_encode() call is predicated on a call to mb_detect_encoding(), which seems to be from mbstring, would seem to point towards mbstring as the shortest path, already expected to be present?

Instead of the current

    if (mb_detect_encoding($contents) != 'UTF-8') {
      $contents = utf8_encode($contents);
    }

Something like:

    $detected_encoding = mb_detect_encoding($contents);
    if ($detected_encoding != 'UTF-8') {
      $contents = mb_convert_encoding($contents, 'UTF-8', $detected_encoding);
    }

?


Also, revisiting Drupal's requirements proper, it requires mbstring already: https://www.drupal.org/docs/getting-started/system-requirements/php-requirements#s-mbstring-

@rosiel
Copy link
Member Author

rosiel commented Nov 1, 2023

fixed as part of #987

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants