With libxml2 < 2.9.12-r2 (not tested with 2.9.12), the result of php -r 'var_dump((new DOMDocument)->saveHTML());' Command line code:1: string(1) " " has always been an empty HTML string. Now, with 2.9.12(-r2), it returns false and breaks API. Minimal script: <?php declare(strict_types=1); function asHTML(DOMDocument $dom): string { return $dom->saveHTML(); } echo asHTML(new DOMDocument); ?> This will generate: Return value of asHTML() must be of the type string, bool returned
You can see that the behaviour as always be identical across versions of PHP: https://3v4l.org/W83pq
1. Thanks for the report. 2. Can you please report this upstream too to libxml2?
(In reply to Sam James from comment #2) > 1. Thanks for the report. > > 2. Can you please report this upstream too to libxml2? I am not quite sure the problem is at libxml2 level or at PHP's one. But I'll follow your advice and create one upstream and linking it here.
libxml2 upstream issue: https://gitlab.gnome.org/GNOME/libxml2/-/issues/266
Fixed upstream. A patch inspired by https://gitlab.gnome.org/GNOME/libxml2/-/commit/92d9ab4c28842a09ca2b76d3ff2f933e01b6cd6f can probably be used until it is part of a release.
(In reply to Patrick ALLAERT from comment #5) > Fixed upstream. > > A patch inspired by > https://gitlab.gnome.org/GNOME/libxml2/-/commit/ > 92d9ab4c28842a09ca2b76d3ff2f933e01b6cd6f can probably be used until it is > part of a release. Huge thanks for reporting upstream and to us. (The reason I asked you to go to libxml2 first is because even if this weren't necessarily caused by them, they may have insight as to what change made it appear, etc.) I assume you've verified the patch works for you in /etc/portage/patches/?
(In reply to Sam James from comment #6) > (In reply to Patrick ALLAERT from comment #5) > > Fixed upstream. > > > > A patch inspired by > > https://gitlab.gnome.org/GNOME/libxml2/-/commit/ > > 92d9ab4c28842a09ca2b76d3ff2f933e01b6cd6f can probably be used until it is > > part of a release. > > Huge thanks for reporting upstream and to us. (The reason I asked you to go > to libxml2 first is because even if this weren't necessarily caused by them, > they may have insight as to what change made it appear, etc.) > > I assume you've verified the patch works for you in /etc/portage/patches/? No, I haven't. Not familiar (yet) with local custom patches. I will try now, hints welcome.
(In reply to Patrick ALLAERT from comment #7) > No, I haven't. > > Not familiar (yet) with local custom patches. > > I will try now, hints welcome. No worries at all. See https://wiki.gentoo.org/wiki//etc/portage/patches#Adding_user_patches but here's the rundown: 1) mkdir -p /etc/portage/patches/dev-libs/libxml2/ 2) wget https://gitlab.gnome.org/GNOME/libxml2/-/commit/92d9ab4c28842a09ca2b76d3ff2f933e01b6cd6f.patch -O /etc/portage/patches/dev-libs/libxml2/bug794733.patch 3) emerge -v1 libxml2 (you should see 'user patches applied' towards the beginning') 4) try your PHP test case again
Local patch worked great! $ eix ^libxml2$ [I] dev-libs/libxml2 Available versions: (2) 2.9.10-r5^t 2.9.12^t 2.9.12-r2^t {debug examples icu ipv6 lzma +python readline static-libs test verify-sig ABI_MIPS="n32 n64 o32" ABI_S390="32 64" ABI_X86="32 64 x32" PYTHON_TARGETS="python3_8 python3_9"} Installed versions: 2.9.12-r2(2)^t(16:51:31 07/06/21)(icu ipv6 python readline -debug -examples -lzma -static-libs -test -verify-sig ABI_MIPS="-n32 -n64 -o32" ABI_S390="-32 -64" ABI_X86="64 -32 -x32" PYTHON_TARGETS="python3_9 -python3_8") Homepage: http://www.xmlsoft.org/ https://gitlab.gnome.org/GNOME/libxml2 Description: XML C parser and toolkit $ php8.0 -r 'var_dump((new DOMDocument)->saveHTML());' string(1) " "
Created attachment 714294 [details, diff] Patch from upstream commit 92d9ab4c28842a09ca2b76d3ff2f933e01b6cd6f Patch from https://gitlab.gnome.org/GNOME/libxml2/-/commit/92d9ab4c28842a09ca2b76d3ff2f933e01b6cd6f.patch
(In reply to Patrick ALLAERT from comment #9) > Local patch worked great! > Huge thanks. Testing...
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=44c350da1481eb2666003486ea295bc836401d01 commit 44c350da1481eb2666003486ea295bc836401d01 Author: Sam James <sam@gentoo.org> AuthorDate: 2021-06-07 23:54:11 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2021-06-08 00:17:56 +0000 dev-libs/libxml2: add upstream patch for PHP/HTML serialisation regression Bug: https://bugs.gentoo.org/794733 Signed-off-by: Sam James <sam@gentoo.org> dev-libs/libxml2/Manifest | 1 + dev-libs/libxml2/libxml2-2.9.12-r3.ebuild | 251 ++++++++++++++++++++++++++++++ 2 files changed, 252 insertions(+)
x86 done
amd64 done
sparc stable
arm64 done
arm done
ppc stable
ppc64 stable
hppa done, bug done