Everything worked oki on development server but when I ported the site to live webserver => WSOD.
Because this module doesn't do at least an class_exists('DOMDocument', FALSE) the user doesn't have a clue of what happened... Also it is not very easy to debug especially when you also use PHPMailer module and other mail handling modules.

Here is the code responsible for the bug:

  public function compress() {
    error_reporting(0);
    $doc = new DOMDocument('1.0', 'utf8');

So it sets to no error reporting and then tries to instantiate the class... And when that class doesn't exist everything crashes and no warning/error message are thrown to the developer.

What would be the best way to solve this issue ? I'm thinking that doing a class_exists and if the class doesn't exist return the html uncompressed would be a good idea. Also, a warning in 'admin/reports/status' would be very helpful to let the admin that even if the compress module is enabled it won't work until the php-xml library is installed.

Comments

andreiashu’s picture

Assigned: Unassigned » andreiashu
Status: Active » Needs review
StatusFileSize
new2.01 KB

Here is a first patch that should solve this (annoying) issue. It simply skips the compress process if DOMDocument isn't available. It also adds an OKI or ERROR message type at 'admin/reports/status' depending on the availability of the class.

The messages/warnings need improvements.

Setting this as CNR so I can get some feedback.

andreiashu’s picture

Title: WSOD because mimemail_compress module doesn't warn if php-xml (or DOMDocument) isn't available » White screen when using Mimemail Compress without php-xml extension
Status: Needs review » Needs work

Setting this as 'needs work' because we should provide a .install file that doesn't let the user enable this module without having the php-xml extension in the first place.

And a better title.

sgabe’s picture

Title: White screen when using Mimemail Compress without php-xml extension » WSOD when using Mime Mail Compress without DOM extension
Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Needs work » Needs review
StatusFileSize
new4.98 KB

The attached patch is against current HEAD and provides an install file with hook_requirement() which checks for the DOM extension.

sgabe’s picture

Status: Needs review » Fixed

Committed to HEAD.

andreiashu’s picture

cool! Thanks

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

alar’s picture

I'm only 'staging' a migration. My solution today is to disable Mime Mail CSS Compressor 6.x-1.1 entirely.
All is happy in my world again, but I log this in fear it comes back to haunt me! ;)