Score:0

Entity print broken when updating to PHP8.1

kn flag

I've updated my drupal environment php 7.4 to php 8.1.18. i've enable some extensions, but I have this error when i try to download a PDF

Error : Typed property DOMDocument::$documentElement must not be accessed before initialization in Masterminds\HTML5\Parser\DOMTreeBuilder->startTag() (/var/www/myproject/vendor/masterminds/html5/src/HTML5/Parser/DOMTreeBuilder.php line 275)

#0 /var/www/myproject/vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php(399): Masterminds\HTML5\Parser\DOMTreeBuilder->startTag()
#1 /var/www/myproject/vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php(141): Masterminds\HTML5\Parser\Tokenizer->tagName()
#2 /var/www/myproject/vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php(82): Masterminds\HTML5\Parser\Tokenizer->consumeData()
#3 /var/www/myproject/vendor/masterminds/html5/src/HTML5.php(161): Masterminds\HTML5\Parser\Tokenizer->parse()
#4 /var/www/myproject/vendor/masterminds/html5/src/HTML5.php(89): Masterminds\HTML5->parse()
#5 /var/www/myproject/vendor/dompdf/dompdf/src/Dompdf.php(478): Masterminds\HTML5->loadHTML()
#6 /var/www/myproject/web/modules/contrib/entity_print/src/Plugin/EntityPrint/PrintEngine/DomPdf.php(207): Dompdf\Dompdf->loadHtml()

the extensions are the same than PHP7.4

enter image description here

EDIT :

By digging, I've found that this on enter image description here

is producing this on php7

enter image description here

but this in php8 (going through the same functions)...

enter image description here

The nodeName is just name in php 8 (and so on). Do I have to change another thing in my server to update the \DOMImplementation() ?

EDIT 2 :

i've remade the delivry of my package to another server (so php7.4 to php8.1.13), same result. It only works into my docker container, not my client server. Here's my procedure :

apt install php8.1-fpm php8.1-xml php8.1-mysql php8.1-gd php8.1-cli php8.1-common php8.1-mbstring php8.1-opcache php8.1-readline php8.1-curl php8.1-bcmath php8.1-zip

    I. edit ini file : /etc/php/8.1/fpm/php.ini

extension=gd
extension=zip
extension=dom
extension=pdo_mysql
extension=mbstring

II. Restart PHP/Nginx
sudo systemctl restart php8.1-fpm
sudo systemctl restart nginx
sudo update-alternatives --set php /usr/bin/php8.1
id flag
What version of the module is installed?
kn flag
Version 2.11 with drupal 9
Ivaylo Tsandev avatar
us flag
If you can't upgrade to PHP 8.2 for whatever reason, you may also try the latest version of PHP 8.1.*, i.e. 8.1.19 and it upgrading to it should be enough for fixing this issue. Also, as pointed in this comment: https://github.com/Masterminds/html5-php/issues/220#issuecomment-1580998305 - maybe a conflict of the extensions is happening?
kn flag
I removed the extension and it solved it
Score:0
vg flag

This is not entity_print related, but to it's dependencies, you should use PHP 8.2.x, see https://github.com/Masterminds/html5-php/issues/220

kn flag
Works fine on php8.1 on my docker container...
kn flag
Indeed, works with PHP8.2, but Drupal 9 doesn't fully support PHP8.2...
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.