New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflict with W3 Total Cache - JS Minify loading to WSOD #199

Closed
bobbingwide opened this Issue Oct 7, 2018 · 4 comments

Comments

2 participants
@bobbingwide

bobbingwide commented Oct 7, 2018

Both autoptimize and W3 Total Cache use a version of JSMinify. I’ve experienced situations where autoloading attempts to load the JS Minify source file leading to the PHP parser issuing messages saying JSException classes could not be redefined. This then caused a further PHP error from output buffering which then led to a WSOD.
Wrapping the definitions of the exception classes, in both Autoptimize and W3 Total Cache resolved the issue.
I haven’t investigated further the real cause of the problem. I can reproduce the problem in Live and locally but not on a test site.
I’m writing this from memory so the file and class names are not complete.

@futtta

This comment has been minimized.

Show comment
Hide comment
@futtta

futtta Oct 7, 2018

Owner

hey @bobbingwide; thanks for the input!

is this something you've (only) experienced recently or (also) before the 2.4-release? and does this go away when the mnification features of W3TC are disabled (as I advise in the FAQ)?

Owner

futtta commented Oct 7, 2018

hey @bobbingwide; thanks for the input!

is this something you've (only) experienced recently or (also) before the 2.4-release? and does this go away when the mnification features of W3TC are disabled (as I advise in the FAQ)?

@bobbingwide

This comment has been minimized.

Show comment
Hide comment
@bobbingwide

bobbingwide Oct 7, 2018

Hi @futtta I believe it's the latter, but I'll need to check the settings. It appears that the versions of autoptimize that I'm running are different.

This is the change I made to the W3 Total Cache code in lib/Minify/JSMin.php

if ( !class_exists( "JSMin_UnterminatedStringException", false ) ) {
class JSMin_UnterminatedStringException extends Exception {}
class JSMin_UnterminatedCommentException extends Exception {}
class JSMin_UnterminatedRegExpException extends Exception {}
} 

and I made a corresponding change to classes/external/php/minify-2.3.1-jsmin.php, which I understand is the 2.3.4 code.

Here are the messages.

[02-Oct-2018 08:29:17 UTC] PHP Fatal error:  Cannot declare class JSMin_UnterminatedStringException, 
because the name is already in use in 
\wp-content\plugins\w3-total-cache\lib\Minify\JSMin.php on line 453
[02-Oct-2018 08:29:17 UTC] PHP Fatal error:  Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0

Not sure which part of the FAQ you're referring to but I'll try disabling W3TC's minify.

bobbingwide commented Oct 7, 2018

Hi @futtta I believe it's the latter, but I'll need to check the settings. It appears that the versions of autoptimize that I'm running are different.

This is the change I made to the W3 Total Cache code in lib/Minify/JSMin.php

if ( !class_exists( "JSMin_UnterminatedStringException", false ) ) {
class JSMin_UnterminatedStringException extends Exception {}
class JSMin_UnterminatedCommentException extends Exception {}
class JSMin_UnterminatedRegExpException extends Exception {}
} 

and I made a corresponding change to classes/external/php/minify-2.3.1-jsmin.php, which I understand is the 2.3.4 code.

Here are the messages.

[02-Oct-2018 08:29:17 UTC] PHP Fatal error:  Cannot declare class JSMin_UnterminatedStringException, 
because the name is already in use in 
\wp-content\plugins\w3-total-cache\lib\Minify\JSMin.php on line 453
[02-Oct-2018 08:29:17 UTC] PHP Fatal error:  Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0

Not sure which part of the FAQ you're referring to but I'll try disabling W3TC's minify.

@bobbingwide

This comment has been minimized.

Show comment
Hide comment
@bobbingwide

bobbingwide Oct 7, 2018

Both the Live and Test sites are now running with Autoptimize 2.4 and W3TC 0.9.7
In the Test site :

  • Minify is selected for BOTH plugins,
  • Optimize HTML Code? is also checked.
  • Opcode Cache is Opcode: Zend Opcache
  • Seems to work fine

In the Live site:

  • Minify is only selected for Autoptimize
  • Optimize HTML Code? is NOT checked
  • Opcode Cache is Not available

plus, on Live only,

  • with Autoptimize deactivated, selecting W3TC's Minify breaks some JS

Didn't manage to reproduce problem with 2.4.

It could have been a problem triggered by Autoptimize upgrade without clearing W3TC's cache.

bobbingwide commented Oct 7, 2018

Both the Live and Test sites are now running with Autoptimize 2.4 and W3TC 0.9.7
In the Test site :

  • Minify is selected for BOTH plugins,
  • Optimize HTML Code? is also checked.
  • Opcode Cache is Opcode: Zend Opcache
  • Seems to work fine

In the Live site:

  • Minify is only selected for Autoptimize
  • Optimize HTML Code? is NOT checked
  • Opcode Cache is Not available

plus, on Live only,

  • with Autoptimize deactivated, selecting W3TC's Minify breaks some JS

Didn't manage to reproduce problem with 2.4.

It could have been a problem triggered by Autoptimize upgrade without clearing W3TC's cache.

@futtta

This comment has been minimized.

Show comment
Hide comment
@futtta

futtta Oct 7, 2018

Owner

OK, 2.4 indeed is smarter in loading the minifiers, glad all is well! :)

Owner

futtta commented Oct 7, 2018

OK, 2.4 indeed is smarter in loading the minifiers, glad all is well! :)

@futtta futtta closed this Oct 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment