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


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


II. Restart PHP/Nginx
sudo systemctl restart php8.1-fpm
sudo systemctl restart nginx
sudo update-alternatives --set php /usr/bin/php8.1
  • What version of the module is installed?
    – mona lisa
    Commented Jun 5, 2023 at 15:58
  • Version 2.11 with drupal 9
    – lobafox
    Commented Jun 6, 2023 at 6:27
  • 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: github.com/Masterminds/html5-php/issues/… - maybe a conflict of the extensions is happening?
    – itsandev
    Commented Jun 9, 2023 at 6:53
  • I removed the extension and it solved it
    – lobafox
    Commented Jun 9, 2023 at 8:46

1 Answer 1


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

  • Works fine on php8.1 on my docker container...
    – lobafox
    Commented Jun 7, 2023 at 6:32
  • Indeed, works with PHP8.2, but Drupal 9 doesn't fully support PHP8.2...
    – lobafox
    Commented Jun 7, 2023 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.