Deprecation warnings with PHP 8.2

Created on 27 May 2024, 7 months ago

Problem/Motivation

Currently the module does not fully support PHP 8.2 because it's using the deprecated utf8_encode() function.

Deprecated function: Function utf8_encode() is deprecated funktiossa Drupal\system_status\Services\SystemStatusEncryption::encryptOpenssl() (rivi 54 tiedostossa /var/www/builds/2024-05-22.08-20-20.commit--b0a8284/web/modules/contrib/system_status/src/Services/SystemStatusEncryption.php)

Source code: https://git.drupalcode.org/project/system_status/-/blob/3.0.x/src/Servic...

Steps to reproduce

Install the module with PHP 8.2 and monitor the dblog.

Proposed resolution

Looking at other modules they seem to have replaced utf8_encode() with mb_convert_encoding(), https://www.php.net/manual/en/function.mb-convert-encoding.php.

Remaining tasks

* Code changes
* Tests

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇫🇮Finland heikkiy Oulu

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

Merge Requests

Comments & Activities

  • Issue created by @heikkiy
  • Pipeline finished with Success
    7 months ago
    Total: 151s
    #183292
  • Status changed to Needs review 7 months ago
  • 🇮🇳India dev16.addweb

    Thanks, @heikkiy. We can add mb_detect_encoding() to detect the source encoding

    $source_encoding = mb_detect_encoding($plaintext, mb_detect_order(), true);
    $plaintext_utf8= mb_convert_encoding($plaintext, 'UTF-8', $source_encoding);
  • 🇫🇮Finland heikkiy Oulu

    Sounds good @silviaddweb. Added it.

  • Pipeline finished with Success
    7 months ago
    Total: 206s
    #184788
  • Pipeline finished with Success
    7 months ago
    Total: 192s
    #185225
  • 🇫🇮Finland heikkiy Oulu

    Running the project through PHP Compatibility tests finds more deprecations. I tested the module with PHP 8.3 but the deprecations are old.

    ---------------------------------------------
    FOUND 11 ERRORS AFFECTING 3 LINES
    ------------------------------------------------------------------------------------------------------------------------------------------------------
     36 | ERROR | Function mcrypt_get_iv_size() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead
     36 | ERROR | Extension 'mcrypt' is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead
     36 | ERROR | The constant "MCRYPT_RIJNDAEL_128" is deprecated since PHP 7.1 and removed since PHP 7.2
     36 | ERROR | The constant "MCRYPT_MODE_CBC" is deprecated since PHP 7.1 and removed since PHP 7.2
     37 | ERROR | Function mcrypt_create_iv() is deprecated since PHP 7.1 and removed since PHP 7.2; Use random_bytes() or OpenSSL instead
     37 | ERROR | Extension 'mcrypt' is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead
     37 | ERROR | The constant "MCRYPT_RAND" is deprecated since PHP 7.1 and removed since PHP 7.2
     41 | ERROR | Function mcrypt_encrypt() is deprecated since PHP 7.1 and removed since PHP 7.2; Use OpenSSL instead
     41 | ERROR | Extension 'mcrypt' is deprecated since PHP 7.1 and removed since PHP 7.2; Use openssl (preferred) or pecl/mcrypt once available instead
     41 | ERROR | The constant "MCRYPT_RIJNDAEL_128" is deprecated since PHP 7.1 and removed since PHP 7.2
     41 | ERROR | The constant "MCRYPT_MODE_CBC" is deprecated since PHP 7.1 and removed since PHP 7.2
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    
  • Status changed to Needs work 7 months ago
  • Status changed to Needs review 7 months ago
  • 🇺🇦Ukraine AstonVictor

    thanks for the report. merged

  • Status changed to Fixed 2 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024