Skip to content

refactor: DOMParser::withString() for PHP 8.2#6672

Merged
kenjis merged 5 commits into
codeigniter4:developfrom
kenjis:fix-DOMParser-withString-php82
Oct 25, 2022
Merged

refactor: DOMParser::withString() for PHP 8.2#6672
kenjis merged 5 commits into
codeigniter4:developfrom
kenjis:fix-DOMParser-withString-php82

Conversation

@kenjis

@kenjis kenjis commented Oct 12, 2022

Copy link
Copy Markdown
Member

Description
See #6170
See https://php.watch/versions/8.2/mbstring-qprint-base64-uuencode-html-entities-deprecated

  • mb_convert_encoding($str, 'HTML-Entities') is deprecated in PHP 8.2.

Checklist:

  • Securely signed commits
  • [] Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • [] User guide updated
  • Conforms to style guide

@kenjis kenjis added PHP 8.2 refactor Pull requests that refactor code labels Oct 12, 2022
@kenjis kenjis mentioned this pull request Oct 12, 2022
7 tasks
@kenjis kenjis changed the title refactor: DOMParser::withString() refactor: DOMParser::withString() for PHP 8.2 Oct 12, 2022

@MGatner MGatner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having a hard time finding a clear answer: are you sure these are the same?

@MGatner

MGatner commented Oct 12, 2022

Copy link
Copy Markdown
Member

Compare: Kristories/symfony@eea3b10

@kenjis

kenjis commented Oct 13, 2022

Copy link
Copy Markdown
Member Author

The latest code in Symfony is different.

$this->line = htmlspecialchars_decode(utf8_decode(htmlentities($this->line, ENT_COMPAT, 'UTF-8', false)));

https://github.com/Kristories/symfony/blob/eea3b10327c1a9b1298a069ea8f844c70e73b6a7/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php#L981

$this->line = mb_encode_numericentity($this->line, [0x80, 0x10FFFF, 0, 0x1FFFFF], 'UTF-8');

https://github.com/symfony/symfony/blob/b527899f4fb4355fd356eef6f910ea67c5f86192/src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php#L939

Comment thread system/Test/DOMParser.php
@kenjis

kenjis commented Oct 13, 2022

Copy link
Copy Markdown
Member Author

I'm having a hard time finding a clear answer: are you sure these are the same?

No. The following tests fail with this PR.

--- a/tests/system/Test/DOMParserTest.php
+++ b/tests/system/Test/DOMParserTest.php
@@ -80,8 +80,9 @@ final class DOMParserTest extends CIUnitTestCase
     public function provideText()
     {
         return [
-            ['Hello World'],
-            ['Hellö Wörld'],
+            'en' => ['Hello World'],
+            'sv' => ['Hej, världen'],
+            'ja' => ['こんにちは、世界'],
         ];
     }
 

@kenjis

kenjis commented Oct 13, 2022

Copy link
Copy Markdown
Member Author

I changed the code, and test case.
But I don't understand the need for the conversion. 😓

@MGatner

MGatner commented Oct 13, 2022

Copy link
Copy Markdown
Member

Have you blamed it for any clues? I can look into it later on desktop, but it is a rather baffling feature.

@kenjis kenjis added the help wanted More help is needed for the proper resolution of an issue or pull request label Oct 17, 2022
@kenjis kenjis mentioned this pull request Oct 22, 2022
5 tasks
@kenjis kenjis force-pushed the fix-DOMParser-withString-php82 branch from b12e15e to d88f555 Compare October 24, 2022 08:41
@kenjis kenjis force-pushed the fix-DOMParser-withString-php82 branch from d88f555 to a83d410 Compare October 24, 2022 23:02
@kenjis

kenjis commented Oct 24, 2022

Copy link
Copy Markdown
Member Author

I think this PR is ready to merge.

@kenjis kenjis merged commit a88ceea into codeigniter4:develop Oct 25, 2022
@kenjis kenjis deleted the fix-DOMParser-withString-php82 branch October 25, 2022 21:08
@kenjis

kenjis commented Oct 25, 2022

Copy link
Copy Markdown
Member Author

Thanks for the reviews!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted More help is needed for the proper resolution of an issue or pull request refactor Pull requests that refactor code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants