Roundcube Community Forum

Release Support => Pending Issues => Topic started by: chris_scott on December 16, 2022, 10:53:55 AM

Title: DOMDocument error on PHP 8.1
Post by: chris_scott on December 16, 2022, 10:53:55 AM
Hi there,

I'm getting this error when trying to view HTML emails on Roundcube 1.6 / PHP 8.1.13. On PHP 7.4 it works fine. Is this a bug or do I need to install or configure something?

Thanks,
Chris

PHP Fatal error:  Uncaught Error: Typed property DOMDocument::$documentElement must not be accessed before initialization in /home/chris/projects/roundcube/vendor/masterminds/html5/src/HTML5/Parser/DOMTreeBuilder.php:275
Stack trace:
#0 /home/chris/projects/roundcube/vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php(399): Masterminds\HTML5\Parser\DOMTreeBuilder->startTag()
#1 /home/chris/projects/roundcube/vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php(141): Masterminds\HTML5\Parser\Tokenizer->tagName()
#2 /home/chris/projects/roundcube/vendor/masterminds/html5/src/HTML5/Parser/Tokenizer.php(82): Masterminds\HTML5\Parser\Tokenizer->consumeData()
#3 /home/chris/projects/roundcube/vendor/masterminds/html5/src/HTML5.php(161): Masterminds\HTML5\Parser\Tokenizer->parse()
#4 /home/chris/projects/roundcube/vendor/masterminds/html5/src/HTML5.php(89): Masterminds\HTML5->parse()
#5 /home/chris/projects/roundcube/program/lib/Roundcube/rcube_washtml.php(698): Masterminds\HTML5->loadHTML()
#6 /home/chris/projects/roundcube/program/actions/mail/index.php(977): rcube_washtml->wash()
#7 /home/chris/projects/roundcube/program/actions/mail/index.php(1021): rcmail_action_mail_index::wash_html()
#8 /home/chris/projects/roundcube/program/actions/mail/show.php(748): rcmail_action_mail_index::print_body()
#9 /home/chris/projects/roundcube/program/include/rcmail_output_html.php(1484): rcmail_action_mail_show::message_body()
#10 [internal function]: rcmail_output_html->xml_command()
#11 /home/chris/projects/roundcube/program/include/rcmail_output_html.php(1322): preg_replace_callback()
#12 /home/chris/projects/roundcube/program/include/rcmail_output_html.php(825): rcmail_output_html->parse_xml()
#13 /home/chris/projects/roundcube/program/include/rcmail_output_html.php(654): rcmail_output_html->parse()
#14 /home/chris/projects/roundcube/program/actions/mail/show.php(164): rcmail_output_html->send()
#15 /home/chris/projects/roundcube/program/include/rcmail.php(275): rcmail_action_mail_show->run()
#16 /home/chris/projects/roundcube/index.php(278): rcmail->action_handler()
#17 {main}
  thrown in /home/chris/projects/roundcube/vendor/masterminds/html5/src/HTML5/Parser/DOMTreeBuilder.php on line 275
Title: Re: DOMDocument error on PHP 8.1
Post by: alec on December 17, 2022, 03:11:32 AM
It looks like a bug in https://github.com/Masterminds/html5-php, but I'm unable to reproduce on the same php version. Make sure you have most recent version of this package.
Title: Re: DOMDocument error on PHP 8.1
Post by: chris_scott on December 19, 2022, 09:54:15 AM
So I did some more testing: I installed a new complete version of RC (1.6.0) directly from roundcube.net, ran it on PHP 8.1.13 (Linux Mint/Apache 2.4.41/MySQL 8.0.31) and confirmed the problem when viewing html emails. The bundled version of masterminds/html5 was 2.7.5 so I ran composer upgrade and it got upgraded to the latest available version: 2.7.6. This didn't fix the problem.

I then downloaded the dependent version and installed all the dependencies. Got the same result. Then I checked on Roundcube 1.5 -- same error when running PHP 8.1.13.

Is there anything else I should check?

Title: Re: DOMDocument error on PHP 8.1
Post by: chris_scott on December 20, 2022, 02:06:11 AM
To test it further, I installed PHP 8.2.0 and on that version it works properly, no errors. Maybe it was something with that particular PHP version 8.1.13? The installed extensions on both PHP versions are exactly the same. I guess if nobody else has experienced this problem we can close the subject.
Title: Re: DOMDocument error on PHP 8.1
Post by: shin on December 21, 2022, 06:42:06 AM
Just logged in to say that I'm currently facing the same issue, running php 8.1.13 and Roundcube 1.5.3 on Docker (mailu/roundcube:master-arm).
Sadly I don't have the knowledge to even try upgrading both PHP and Roundcube to its latest versions until another docker image comes out.
Would be great if there's a "quick-fix" solution for it.

Edit: going into "Config->Prefs->Message View" and Disabling "Show HTML" actually lets me see the content of incoming emails, although obviously: HTML doesn't work anymore.