wp-rocket icon indicating copy to clipboard operation
wp-rocket copied to clipboard

Automatic Lazy Rendering: 500 error in browser console if dom extension is disabled - Class "DOMDocument" not found

Open alfonso100 opened this issue 1 year ago • 4 comments

Before submitting an issue please check that you’ve completed the following steps: Yes - Made sure you’re on the latest version Yes - Used the search feature to ensure that the bug hasn’t been reported before

Describe the bug A 500 error appears in the browser console, the website is still functional but cache and optimizations are not applied.

This is related to Automatic Lazy Rendering and its usage of PHP dom extension When the dom extension (https://www.php.net/en/dom) is disabled in the server, it triggers the error here: https://github.com/wp-media/wp-rocket/blob/73488699424f726bef28dbf2c934340efcab8e47/inc/Engine/Optimization/LazyRenderContent/Frontend/Processor/Dom.php#L81

Error log: 5818 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Class "DOMDocument" not found in /wp-content/plugins/wp-rocket/inc/Engine/Optimization/LazyRenderContent/Frontend/Processor/Dom.php:81 To solve they need to enable the dom extension in PHP

To Reproduce Steps to reproduce the behavior:

  1. Disable DOM extension in PHP
  2. Visit the frontend of the site
  3. See the 500 error console error

Expected behavior We should check if DOM extension is enabled or not, and:

  • show a warning to the users in the backend
  • Avoid the fatal error

Additional context Ticket 1: https://secure.helpscout.net/conversation/2720908346/514956?folderId=2683093 Ticket 2: https://secure.helpscout.net/conversation/2723174345/515454?folderId=2683093 Slack thread: https://wp-media.slack.com/archives/C43T1AYMQ/p1727853713650349

Acceptance Criteria (for WP Media team use only) Clear instructions for developers, to be added before the grooming

alfonso100 avatar Oct 02 '24 07:10 alfonso100

Related: https://secure.helpscout.net/conversation/2729837367/516925?folderId=8127822

Adrianadla avatar Oct 10 '24 18:10 Adrianadla

Related: https://secure.helpscout.net/conversation/2730140171/516991?folderId=273766

webtrainingwheels avatar Oct 11 '24 15:10 webtrainingwheels

Related: https://secure.helpscout.net/conversation/2731385184/517216/

jekayode avatar Oct 14 '24 06:10 jekayode

related: https://secure.helpscout.net/conversation/2734835657/517925/

worldwildweb avatar Oct 17 '24 09:10 worldwildweb

Related issue: https://secure.helpscout.net/conversation/2760375019/522678?viewId=8127831

jekayode avatar Nov 14 '24 14:11 jekayode

https://secure.helpscout.net/conversation/2776010046/526746?viewId=377611

webtrainingwheels avatar Nov 27 '24 22:11 webtrainingwheels

https://secure.helpscout.net/conversation/2791181231/530339?viewId=273766

alfonso100 avatar Dec 13 '24 11:12 alfonso100