Title: Issues with hardcoded location to zencache.php
Last modified: August 30, 2016

---

# Issues with hardcoded location to zencache.php

 *  Resolved [pyramusnl](https://wordpress.org/support/users/pyramusnl/)
 * (@pyramusnl)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/issues-with-hardcoded-location-to-zencachephp/)
 * 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](https://www.dropbox.com/s/wgos6knceu7uo3e/Screenshot_2015-10-22_17_59_51.png?dl=0)(
   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](https://www.dropbox.com/s/j1h1z9caj863hjm/Screenshot_2015-10-23_14_10_39.png?dl=0)
 * 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://wordpress.org/plugins/zencache/](https://wordpress.org/plugins/zencache/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Raam Dev](https://wordpress.org/support/users/raamdev/)
 * (@raamdev)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/issues-with-hardcoded-location-to-zencachephp/#post-6678329)
 * [@pyramusnl](https://wordpress.org/support/users/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](https://wordpress.org/support/users/pyramusnl/)
 * (@pyramusnl)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/issues-with-hardcoded-location-to-zencachephp/#post-6678330)
 * 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](https://wordpress.org/support/users/raamdev/)
 * (@raamdev)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/issues-with-hardcoded-location-to-zencachephp/#post-6678331)
 * [@pyramusnl](https://wordpress.org/support/users/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](https://wordpress.org/support/users/raamdev/)
 * (@raamdev)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/issues-with-hardcoded-location-to-zencachephp/#post-6678332)
 * [@pyramusnl](https://wordpress.org/support/users/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](https://wordpress.org/support/users/pyramusnl/)
 * (@pyramusnl)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/issues-with-hardcoded-location-to-zencachephp/#post-6678336)
 * 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](https://wordpress.org/support/users/raamdev/)
 * (@raamdev)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/issues-with-hardcoded-location-to-zencachephp/#post-6678337)
 * > 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.

 * ![](https://s.w.org/plugins/geopattern-icon/zencache_3c4c6b.svg)
 * [ZenCache](https://wordpress.org/plugins/zencache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/zencache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/zencache/)
 * [Active Topics](https://wordpress.org/support/plugin/zencache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/zencache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/zencache/reviews/)

## Tags

 * [wp-config](https://wordpress.org/support/topic-tag/wp-config/)

 * 6 replies
 * 2 participants
 * Last reply from: [Raam Dev](https://wordpress.org/support/users/raamdev/)
 * Last activity: [10 years, 7 months ago](https://wordpress.org/support/topic/issues-with-hardcoded-location-to-zencachephp/#post-6678337)
 * Status: resolved