WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
Not working Minify on some configurations (6 posts)

  1. Daniel Kukiela
    Member
    Posted 2 years ago #

    Hi.
    I moved my blog to home.pl hosting. After that Minify stopped working.

    On that configuration $_SERVER['SCRIPT_FILENAME'] and $_SERVER['PHP_SELF'] are equal, so in w3_get_document_root() in define.php:

    if (!empty($_SERVER['SCRIPT_FILENAME'])) {
                $document_root = substr(w3_path($_SERVER['SCRIPT_FILENAME']), 0, -strlen(w3_path($_SERVER['PHP_SELF'])));

    that evaluates to an empty string.

    Few lines below:
    $document_root = realpath($document_root);
    If path ($document_root) delivered to realpath is blank, realpath() returns current directory. In my case it is "/wp-content/w3tc/min/" instead of "/".

    That causes en error:
    W3TC Minify Error</h1><p>Path "/wp-content/w3tc/min/wp-content/themes/twentyten/style.css" failed realpath().

    I fixed it like this:

    if(strlen($document_root))
    	$document_root = realpath($document_root);

    But there is more realpath() with an empty string delivered.

    After that fix, paths in minified css (url() in css) was wrong (something like: "/wp-content/w3tc/min/wentyten/wenyten/images/logo_small.png" - yes, tehre is "wentyten", not "twentyten").

    To make it work for me, i patched also:
    ImportProcessor.php -> _urlCB($m):

    if(strlen($_SERVER['DOCUMENT_ROOT']))
    	$path = substr($path, strlen(realpath($_SERVER['DOCUMENT_ROOT'])));

    UriRewriter.php -> _realpath($path):

    $realPath = strlen($path) ? realpath($path) : "";

    but it can be more places to fix.

    http://wordpress.org/extend/plugins/w3-total-cache/

  2. Frederick Townes
    Member
    Plugin Author

    Posted 1 year ago #

    Thank you for letting us know. We are looking into the issue.

    If you can enable WP_DEBUG that would help uncover what the issue is.

  3. medeis
    Member
    Posted 1 year ago #

    I'm also having same problem as described above. I believe the issue is connected with Idea Web Server which some providers are using.

    Instead of the minified file the following error message is shown instead of file that should be minified (<script type="text/javascript" src="http://***/wp-content/w3tc/min/3fb8a440.9d92a2.js">):

    <h1>W3TC Minify Error</h1><p>Path "/wp-content/w3tc/min/wp-includes/js/comment-reply.min.js" failed realpath().</p>

    It's about the same error for css (W3TC is looking for css file in wrong path - /wp-content/w3tc/min/themes/***/style.css).

    In DEBUG I can see only the following entries related:

    [05-Jan-2013 20:09:04 UTC] PHP Notice:  Array to string conversion in /wp-content/plugins/w3-total-cache/lib/W3/Minify.php on line 810
    [05-Jan-2013 20:09:04 UTC] PHP Notice:  Array to string conversion in /wp-content/plugins/w3-total-cache/lib/W3/Minify.php on line 810
    
    [05-Jan-2013 20:09:05 UTC] PHP Notice:  Undefined variable: location in /wp-content/plugins/w3-total-cache/lib/W3/Minify.php on line 146
    [05-Jan-2013 20:09:05 UTC] PHP Notice:  Undefined variable: location in /wp-content/plugins/w3-total-cache/lib/W3/Minify.php on line 146
    [05-Jan-2013 20:09:05 UTC] PHP Notice:  Undefined variable: location in /wp-content/plugins/w3-total-cache/lib/W3/Minify.php on line 147
    [05-Jan-2013 20:09:05 UTC] PHP Notice:  Undefined variable: location in /wp-content/plugins/w3-total-cache/lib/W3/Minify.php on line 14

    Let me know if any other debug would be useful.

  4. Daniel Kukiela
    Member
    Posted 1 year ago #

    Frederick - I didn't know, that you replied.
    I don't know, how debug would help. I made some patches, so plugin works for me, and so debug will be not appropriate.
    If you wold like, i will setup new wordpress instance with unpatched plugin.
    But i wrote where the problem is.
    As medeis wrote, problem propably exists only on Idea Web Server, where SCRIPT_FILENAME's and PHP_SELF's paths are equal.
    Just make sure, that $document_root variable is not empty. If it is, do not use realpatch() function, which will produce unexpected path for empty $document_root variable.
    On Idea Web Serwer root folder of any path exposed in $_SERVER array is user root folder, not system root folder.

  5. medeis
    Member
    Posted 1 year ago #

    is there any update regarding progress of this?
    The required fixes are quite simple and well-descibed above, but unfortunately this bug still exists, even after latest update to 0.9.2.7.

    Thanks!

  6. Frederick Townes
    Member
    Plugin Author

    Posted 1 year ago #

    @medeis, since this case is covered by the latest version and version .7 your issue is probably something else. If you send a support request we can investigate your case as well.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic