WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: WP Super Cache] Enabled WP-Supercache and my site disappeared #2 (5 posts)

  1. sp_malley
    Member
    Posted 5 years ago #

    Followed all the instructions. Clicked Activate button next to the plugin and then navigated to Settings -> Super Cache TAB.

    ... this caused WordPress to crash. At this point the plugin has already generated the following file and is trying to display it:

    wp-content/wp-cache-config.php

    The screen goes blank because this is a generated PHP and it is malformed in the following way:

    <?php
    /*
    WP-Cache Config Sample File
    
    See wp-cache.php for author details.
    */
    
    define( 'WPCACHEHOME', ABSPATH . /Users/id/Sites/wp-content/plugins/wp-super-cache/" ); //Added by WP-Cache Manager
    
    $cache_compression = 0; // Super cache compression
    $cache_enabled = false;
    .... (rest of file)

    SO - The answer is to add the missing double-quote after ABSPATH . which is killing the PHP. Suggestion: fix this backquoting and / or add to the troubleshooting FAQ section of readme.txt:

    Users should check their wp-content/wp-cache-config.php after it is created for missing quotes after the line

    define( 'WPCACHEHOME', ABSPATH .

  2. sp_malley
    Member
    Posted 5 years ago #

    I believe the reason for encountering the error is because either

    i) a symlink to wordpress folder
    ii) a symlink in wordpress folder --> wp_content

    Indeed -

    ABSPATH . /Users/id/Sites/wp-content/plugins/wp-super-cache/"

    should say only

    ABSPATH . "wp-content/plugins/wp-super-cache"

    ii) A symlink error for wp-content. The reason was symlilnked wp-content is important wordpress folder containing all themes, etc and better kept elsewhere. I move wp-contnet to my home folder, so it can be backed up separately. Its just a regular unix symlink (not a hardlink or anything).

    Perhaps this revelation can be added to the troubleshooting.

  3. Donncha O Caoimh
    Member
    Posted 5 years ago #

    That's strange. The " is in the code that creates the config file, but when there's something unusual about the directory layout it's difficult to spot it. This is the first time I've seen this happen!

    What about putting the wp-content directory in your web root, and then symlinking it from your home directory?

  4. sp_malley
    Member
    Posted 5 years ago #

    Well actually my web-root is inside my home directory, and all the Apache, PHP,etc, is run under my regular user account. Thanks to MAMP.

    So in this context its effectively the same thing if i were linking wp-content from my web-root, into my wordpress site (all directories within). This bug appears to be in the PHP code writing the wp-cache-config.php file.

    Super cache is called off /wp-admin/options-general.php?page= which means that it is already included the ABSPATH constant (which points to the wordpress root of the site). Which allows this to work. In Macintosh the symlink directory passed in to PHP is not mapped. (so it appears as /path/to/real/file). And also affecting

    /Users/id/Sites/wp-content/plugins/one-click-plugin-updater/do_update.php

    Soo i dont really know what i can do about that one.
    But for Supercache its a quoting issue around line 777 of wp-cache.php:

    copy($wp_cache_config_file_sample, $wp_cache_config_file);
    		if( is_file( dirname(__FILE__) . '/wp-cache-config-sample.php' ) ) {
    			wp_cache_replace_line('WPCACHEHOME', "define( 'WPCACHEHOME', ABSPATH . " . str_replace( '\\', '/', str_replace( ABSPATH, ' "', dirname(__FILE__) ) ) . "/\" );", $wp_cache_config_file);
    		} elseif( is_file( dirname(__FILE__) . '/wp-super-cache/wp-cache-config-sample.php' ) ) {
    			wp_cache_replace_line('WPCACHEHOME', "define( 'WPCACHEHOME', ABSPATH . " . str_replace( '\\', '/', str_replace( ABSPATH, ' "', dirname(__FILE__) ) ) . "/wp-super-cache/\" );", $wp_cache_config_file);
    		}

    maybe because the symlink passed by PHP has a leading slash and others dont? (might be throwing off the regex rewriting the opening quote?). I dont know PHP but it might be an escaping issue. This part ' "', dirname(__FILE__) looks hairy because it seems to be a backtick instead of a regular quote. Is that normal for PHP code?

  5. sp_malley
    Member
    Posted 5 years ago #

    Oh - its not a backtick but is a proper single quote, my mistake. However its now clear to me that the original line in the wp-cache-config-sample.php does not need to be re-written. So simply commenting out those 2 lines will fix the issue. I checked it and working fine !

    copy($wp_cache_config_file_sample, $wp_cache_config_file);
    		if( is_file( dirname(__FILE__) . '/wp-cache-config-sample.php' ) ) {
    			# wp_cache_replace_line('WPCACHEHOME', "define( 'WPCACHEHOME', ABSPATH . " . str_replace( '\\', '/', str_replace( ABSPATH, ' "', dirname(__FILE__) ) ) . "/\" );", $wp_cache_config_file);
    		} elseif( is_file( dirname(__FILE__) . '/wp-super-cache/wp-cache-config-sample.php' ) ) {
    			# wp_cache_replace_line('WPCACHEHOME', "define( 'WPCACHEHOME', ABSPATH . " . str_replace( '\\', '/', str_replace( ABSPATH, ' "', dirname(__FILE__) ) ) . "/wp-super-cache/\" );", $wp_cache_config_file);
    		}

    I think this is a safe to change because you are already pre-pending with ABSPATH here. And if the user would like to put their cache files in a non-standard directory they could edit the path in the config file manually.

Topic Closed

This topic has been closed to new replies.

About this Topic