mb_convert_encoding is deprecated in PHP 8.2

Created on 5 February 2024, 5 months ago
Updated 22 April 2024, 2 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?

📌 Task
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 Mandsaur

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

  • Status changed to Needs review 4 months ago
  • 🇮🇳India himanshu_jhaloya Mandsaur

    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 4 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 Mandsaur

    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 2 months ago
  • 🇺🇸United States bluegeek9
Production build 0.69.0 2024