mb_convert_encoding is deprecated in PHP 8.2

Created on 5 February 2024, 11 months ago
Updated 15 February 2024, 10 months ago

Problem/Motivation

After updating our system to PHP 8.2, we are facing this error:

Deprecated function: mb_convert_encoding(): Handling HTML entities via mbstring is deprecated; use htmlspecialchars, htmlentities, or mb_encode_numericentity/mb_decode_numericentity instead in Caxy\HtmlDiff\Table\TableDiff->createDocumentWithHtml() (Zeile 630 in /var/www/html/docport/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableDiff.php)

Is this a bug of the diff module, or in the Caxy library?

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇩🇪Germany dbielke1986

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

Comments & Activities

  • Issue created by @dbielke1986
  • First commit to issue fork.
  • 🇮🇳India himanshu_jhaloya Indore

    Hi @dbielke1986 Is this a bug in the Caxy library related with.

  • Status changed to Needs review 10 months ago
  • 🇮🇳India himanshu_jhaloya Indore

    php-htmldiff/lib/Caxy/HtmlDiff/Table
    /TableDiff.php

    To Fix the issue you can add the following code
    instead
    line 592
    $htmlDiff = HtmlDiff::create(
    mb_convert_encoding($oldContent, 'UTF-8', 'HTML-ENTITIES'),
    mb_convert_encoding($newContent, 'UTF-8', 'HTML-ENTITIES'),
    $this->config
    );
    to
    $htmlDiff = HtmlDiff::create(
    htmlspecialchars_decode($oldContent, ENT_QUOTES | ENT_HTML5),
    htmlspecialchars_decode($newContent, ENT_QUOTES | ENT_HTML5),
    $this->config
    );

    instead
    line 630---
    $dom->loadHTML(mb_convert_encoding(
    $this->purifyHtml(mb_convert_encoding($text, $this->config->getEncoding(), mb_detect_encoding($text))),
    'HTML-ENTITIES',
    $this->config->getEncoding()
    ));

    to

    $dom->loadHTML(mb_convert_encoding(
    $this->purifyHtml(mb_convert_encoding($text, $this->config->getEncoding(), mb_detect_encoding($text))),
    'HTML-ENTITIES',
    $this->config->getEncoding()
    ));

  • Status changed to Needs work 10 months ago
  • 🇩🇪Germany dbielke1986

    I think we need an MR for this issue before it should be "Needs review".
    Can you push your changes to an MR?

  • 🇮🇳India himanshu_jhaloya Indore

    Hi @dbielke1986 i you please review if this work i will create the MR

  • 🇺🇸United States bluegeek9

    The issue is with php-htmldiff. The library needs the patch, and then the dependency revision needs to increase.

  • Assigned to bluegeek9
  • Status changed to Active 8 months ago
  • 🇺🇸United States anilu@ Houston, TX

    As the issue is in a module dependency and not the module itself, we need to wait until library maintainers approve the PR. For now, I apply the patch with composer using the vendor folder as this:

     "vendor/caxy/php-htmldiff": {
                    "TableDiff: Deprecated function mb_convert_encoding() in PHP 8.2 - [#123]" : "https://patch-diff.githubusercontent.com/raw/caxy/php-htmldiff/pull/125.patch"
                }
  • 🇦🇺Australia jannakha Brisbane!

    +1 for #10 comment

  • heddn Nicaragua

    This is postponed on an upstream fix.

Production build 0.71.5 2024