• Resolved pyramusnl

    (@pyramusnl)


    The hardcoded, absolute path to zencache.php in the variable ZENCACHE_PLUGIN_FILE will cause issues when working with different servers (local dev vs remote staging, production etc) and migrating your site between those.

    Line 164 (in my case) in the file advanced-cache.php:
    define('ZENCACHE_PLUGIN_FILE', '/Volumes/HD/local/path/follows/here/plugins/zencache/zencache.php');

    Screenshot of debug output (FYI: the issue will actually also break functionality on some pages)

    I solved this by replacing the first part of this static path by the constant WP_CONTENT_DIR which is already defined in wp-config.php. I think this is best practice for every plugin, isn’t it? Screenshot of change in code

    However, I don’t know if, and how, this can make it back in your original code in some way so I won’t run into trouble again after future updates.

    Please let me know if you need more info.

    https://www.ads-software.com/plugins/zencache/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Raam Dev

    (@raamdev)

    @pyramusnl The advanced-cache.php file is dynamically generated whenever ZenCache is enabled. At the time of generation, ZenCache will determine the correct ZENCACHE_PLUGIN_FILE value and use that in advanced-cache.php.

    If you’re moving between development environments, the best thing to do is either delete advanced-cache.php and allowing it to be regenerated, or clicking the “Restore” button inside the ZenCache options to reset the ZenCache options and have ZenCache regenerate the advanced-cache.php file for you.

    Thread Starter pyramusnl

    (@pyramusnl)

    As you can imagine, this is very unhandy: you should not have to manually change settings or delete files when pushing from say staging to production. I have an automated workflow where any manual intervention is a lot of (unwanted) hassle.

    And as I explained, I don’t think there’s a good reason for that: using my fix easily resolves this issue. So why would you still write a hardcoded path in the file? Do I miss something?

    Plugin Author Raam Dev

    (@raamdev)

    @pyramusnl The advanced-cache.php file is dynamically generated because once it’s in place the advanced-cache.php file loads before most of WordPress (which is how caching plugins can load a cached version of a page if one exists, which saves the overhead of loading the rest of WordPress). For that reason, it’s not possible to run a lot of common WordPress functions inside advanced-cache.php (hence the reason it needs to be dynamically generated when the caching plugin is enabled).

    However, you’re right that WP_CONTENT_DIR is already defined in wp-config.php, which comes before advanced-cache.php, so I can’t think of any immediate reason why that’s not already used there. I will review the code again and update this in the next release if I’m not missing anything. I appreciate the feedback!

    Plugin Author Raam Dev

    (@raamdev)

    @pyramusnl Which version of ZenCache are you running? I just confirmed that the latest version of ZenCache Lite (v150930) is already using WP_CONTENT_DIR in advanced-cache.php. Here’s the relevant line from my own advanced-cache.php file on my test site:

    define('ZENCACHE_PLUGIN_FILE', WP_CONTENT_DIR.'/plugins/zencache/zencache.php');
    Thread Starter pyramusnl

    (@pyramusnl)

    hey there, i’m using 150930. i looked back in my commits and have been using zencache since version 150409. maybe you introduced this fix after that version and it didn’t work retroactively?

    Plugin Author Raam Dev

    (@raamdev)

    maybe you introduced this fix after that version and it didn’t work retroactively?

    Yes, that fix was introduced earlier this year, sometime back in March – April I believe, so that’s most likely the reason you saw this issue.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Issues with hardcoded location to zencache.php’ is closed to new replies.