Skip to content

Commit

Permalink
Bug fix; qc-* prefixed files should be converted to zc-*. See: wpshar…
Browse files Browse the repository at this point in the history
  • Loading branch information
JasWSInc committed Nov 21, 2014
1 parent 49b0810 commit 1a5cc45
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions zencache-pro/includes/actions.php
Expand Up @@ -170,7 +170,7 @@ public function save_options($args)
if(!($add_advanced_cache = $this->plugin->add_advanced_cache()))
$query_args[__NAMESPACE__.'__advanced_cache_add_failure']
= ($add_advanced_cache === NULL)
? 'qc-advanced-cache' : '1';
? 'zc-advanced-cache' : '1';

$this->plugin->update_blog_paths();
}
Expand Down Expand Up @@ -212,7 +212,7 @@ public function restore_default_options($args)
if(!($add_advanced_cache = $this->plugin->add_advanced_cache()))
$query_args[__NAMESPACE__.'__advanced_cache_add_failure']
= ($add_advanced_cache === NULL)
? 'qc-advanced-cache' : '1';
? 'zc-advanced-cache' : '1';

$this->plugin->update_blog_paths();
}
Expand Down
2 changes: 1 addition & 1 deletion zencache-pro/includes/advanced-cache.tpl.php
Expand Up @@ -552,7 +552,7 @@ class advanced_cache extends share # `/wp-content/advanced-cache.php`
*
* @var string A unique string identifier in the set of `NC_DEBUG_` constants.
*/
const NC_DEBUG_QCAC_GET_VAR = 'nc_debug_qcac_get_var';
const NC_DEBUG_QCAC_GET_VAR = 'nc_debug_zcac_get_var';

/**
* No-cache because of a missing `$_SERVER['HTTP_HOST']`.
Expand Down
4 changes: 2 additions & 2 deletions zencache-pro/includes/auto-cache.php
Expand Up @@ -149,7 +149,7 @@ protected function log_auto_cache_url($url, $wp_remote_get_response)
{
$cache_dir = $this->plugin->cache_dir();
$cache_lock = $this->plugin->cache_lock();
$auto_cache_log_file = $cache_dir.'/qc-auto-cache.log';
$auto_cache_log_file = $cache_dir.'/zc-auto-cache.log';

if(is_file($auto_cache_log_file) && !is_writable($auto_cache_log_file))
throw new \exception(sprintf(__('Auto-cache log file is NOT writable: `%1$s`. Please set permissions to `644` (or higher). `666` might be needed in some cases.', $this->plugin->text_domain), $auto_cache_log_file));
Expand Down Expand Up @@ -177,7 +177,7 @@ protected function log_auto_cache_run($total_urls, $total_time)
{
$cache_dir = $this->plugin->cache_dir();
$cache_lock = $this->plugin->cache_lock();
$auto_cache_log_file = $cache_dir.'/qc-auto-cache.log';
$auto_cache_log_file = $cache_dir.'/zc-auto-cache.log';

if(is_file($auto_cache_log_file) && !is_writable($auto_cache_log_file))
throw new \exception(sprintf(__('Auto-cache log file is NOT writable: `%1$s`. Please set permissions to `644` (or higher). `666` might be needed in some cases.', $this->plugin->text_domain), $auto_cache_log_file));
Expand Down
4 changes: 2 additions & 2 deletions zencache-pro/includes/menu-pages.php
Expand Up @@ -98,8 +98,8 @@ public function options()
if(!empty($_REQUEST[__NAMESPACE__.'__advanced_cache_add_failure']))
{
echo '<div class="plugin-menu-page-notice error">'."\n";
if($_REQUEST[__NAMESPACE__.'__advanced_cache_add_failure'] === 'qc-advanced-cache')
echo ' <i class="fa fa-thumbs-down"></i> '.sprintf(__('Failed to update your <code>/wp-content/advanced-cache.php</code> file. Cannot write stat file: <code>%1$s/qc-advanced-cache</code>. Please be sure this directory exists (and that it\'s writable): <code>%1$s</code>. Please use directory permissions <code>755</code> or higher (perhaps <code>777</code>). Once you\'ve done this, please try again.', $this->plugin->text_domain), esc_html($this->plugin->cache_dir()))."\n";
if($_REQUEST[__NAMESPACE__.'__advanced_cache_add_failure'] === 'zc-advanced-cache')
echo ' <i class="fa fa-thumbs-down"></i> '.sprintf(__('Failed to update your <code>/wp-content/advanced-cache.php</code> file. Cannot write stat file: <code>%1$s/zc-advanced-cache</code>. Please be sure this directory exists (and that it\'s writable): <code>%1$s</code>. Please use directory permissions <code>755</code> or higher (perhaps <code>777</code>). Once you\'ve done this, please try again.', $this->plugin->text_domain), esc_html($this->plugin->cache_dir()))."\n";
else echo ' <i class="fa fa-thumbs-down"></i> '.__('Failed to update your <code>/wp-content/advanced-cache.php</code> file. Most likely a permissions error. Please create an empty file here: <code>/wp-content/advanced-cache.php</code> (just an empty PHP file, with nothing in it); give it permissions <code>644</code> or higher (perhaps <code>666</code>). Once you\'ve done this, please try again.', $this->plugin->text_domain)."\n";
echo '</div>'."\n";
}
Expand Down
14 changes: 7 additions & 7 deletions zencache-pro/includes/share.php
Expand Up @@ -592,8 +592,8 @@ public function host_dir_token($dashify = FALSE)
$host_dir_token = isset($host_dir_token[0]) ? '/'.$host_dir_token.'/' : '/';

if($host_dir_token !== '/' // Perhaps NOT the main site?
&& (!is_file(($cache_dir = $this->cache_dir()).'/qc-blog-paths') // NOT a read/valid blog path?
|| !in_array($host_dir_token, unserialize(file_get_contents($cache_dir.'/qc-blog-paths')), TRUE))
&& (!is_file(($cache_dir = $this->cache_dir()).'/zc-blog-paths') // NOT a read/valid blog path?
|| !in_array($host_dir_token, unserialize(file_get_contents($cache_dir.'/zc-blog-paths')), TRUE))
) $host_dir_token = '/'; // Main site; e.g. this is NOT a real/valid child blog path.
}
$token_value = $dashify ? trim(preg_replace('/[^a-z0-9\/]/i', '-', $host_dir_token), '-') : $host_dir_token;
Expand Down Expand Up @@ -1503,7 +1503,7 @@ public function delete_files_from_cache_dir($regex, $check_max_age = FALSE)
$cache_dir_tmp_regex = '/^'.preg_quote($cache_dir_tmp, '/').$cache_dir_tmp_regex;
else $cache_dir_tmp_regex = '/^'.preg_quote($cache_dir_tmp.'/', '/').$cache_dir_tmp_regex;

# if(WP_DEBUG) file_put_contents(WP_CONTENT_DIR.'/qc-debug.log', print_r($regex, TRUE)."\n".print_r($cache_dir_tmp_regex, TRUE)."\n\n", FILE_APPEND);
# if(WP_DEBUG) file_put_contents(WP_CONTENT_DIR.'/zc-debug.log', print_r($regex, TRUE)."\n".print_r($cache_dir_tmp_regex, TRUE)."\n\n", FILE_APPEND);
// Uncomment the above line to debug regex pattern matching used by this routine; and others that call upon it.

if(!rename($cache_dir, $cache_dir_tmp)) // Work from tmp directory so deletions are atomic.
Expand All @@ -1514,7 +1514,7 @@ public function delete_files_from_cache_dir($regex, $check_max_age = FALSE)
{
if(($_file_dir->isFile() || $_file_dir->isLink()) // Files and/or symlinks only.

// Don't delete files in the immediate directory; e.g. `qc-advanced-cache` or `.htaccess`, etc.
// Don't delete files in the immediate directory; e.g. `zc-advanced-cache` or `.htaccess`, etc.
// Actual `http|https/...` cache files are nested. Files in the immediate directory are for other purposes.
&& (strpos($_file_dir->getSubpathname(), '/') !== FALSE)

Expand Down Expand Up @@ -1631,7 +1631,7 @@ public function delete_files_from_host_cache_dir($regex, $check_max_age = FALSE)
$_host_cache_dir_tmp_regex = '/^'.preg_quote($_host_cache_dir_tmp, '/').$_host_cache_dir_tmp_regex;
else $_host_cache_dir_tmp_regex = '/^'.preg_quote($_host_cache_dir_tmp.'/', '/').$_host_cache_dir_tmp_regex;

# if(WP_DEBUG) file_put_contents(WP_CONTENT_DIR.'/qc-debug.log', print_r($regex, TRUE)."\n".print_r($_host_cache_dir_tmp_regex, TRUE)."\n\n", FILE_APPEND);
# if(WP_DEBUG) file_put_contents(WP_CONTENT_DIR.'/zc-debug.log', print_r($regex, TRUE)."\n".print_r($_host_cache_dir_tmp_regex, TRUE)."\n\n", FILE_APPEND);
// Uncomment the above line to debug regex pattern matching used by this routine; and others that call upon it.

if(!rename($_host_cache_dir, $_host_cache_dir_tmp)) // Work from tmp directory so deletions are atomic.
Expand All @@ -1642,7 +1642,7 @@ public function delete_files_from_host_cache_dir($regex, $check_max_age = FALSE)
{
if(($_file_dir->isFile() || $_file_dir->isLink()) // Files and/or symlinks only.

// Don't delete files in the immediate directory; e.g. `qc-advanced-cache` or `.htaccess`, etc.
// Don't delete files in the immediate directory; e.g. `zc-advanced-cache` or `.htaccess`, etc.
// Actual `http|https/...` cache files are nested. Files in the immediate directory are for other purposes.
&& ($_host_cache_dir !== $cache_dir || strpos($_file_dir->getSubpathname(), '/') !== FALSE)

Expand Down Expand Up @@ -1679,7 +1679,7 @@ public function delete_files_from_host_cache_dir($regex, $check_max_age = FALSE)

/**
* Delete all files/dirs from a directory (for all schemes/hosts);
* including `qc-` prefixed files; or anything else for that matter.
* including `zc-` prefixed files; or anything else for that matter.
*
* @since 141110 Refactoring cache clear/purge routines.
*
Expand Down
2 changes: 1 addition & 1 deletion zencache-pro/includes/translations/zencache-pro.pot
Expand Up @@ -296,7 +296,7 @@ msgid "Failed to update your <code>/wp-config.php</code> file automatically. Ple
msgstr ""

#: includes/menu-pages.php:92
msgid "Failed to update your <code>/wp-content/advanced-cache.php</code> file. Cannot write stat file: <code>%1$s/qc-advanced-cache</code>. Please be sure this directory exists (and that it's writable): <code>%1$s</code>. Please use directory permissions <code>755</code> or higher (perhaps <code>777</code>). Once you've done this, please try again."
msgid "Failed to update your <code>/wp-content/advanced-cache.php</code> file. Cannot write stat file: <code>%1$s/zc-advanced-cache</code>. Please be sure this directory exists (and that it's writable): <code>%1$s</code>. Please use directory permissions <code>755</code> or higher (perhaps <code>777</code>). Once you've done this, please try again."
msgstr ""

#: includes/menu-pages.php:93
Expand Down
22 changes: 11 additions & 11 deletions zencache-pro/zencache-pro.inc.php
Expand Up @@ -2719,7 +2719,7 @@ public function remove_wp_cache_from_wp_config()
}

/**
* Checks to make sure the `qc-advanced-cache` file still exists;
* Checks to make sure the `zc-advanced-cache` file still exists;
* and if it doesn't, the `advanced-cache.php` is regenerated automatically.
*
* @since 140422 First documented version.
Expand All @@ -2745,7 +2745,7 @@ public function check_advanced_cache()

$cache_dir = $this->cache_dir(); // Current cache directory.

if(!is_file($cache_dir.'/qc-advanced-cache'))
if(!is_file($cache_dir.'/zc-advanced-cache'))
$this->add_advanced_cache();
}

Expand All @@ -2767,7 +2767,7 @@ public function check_advanced_cache()
*
* @return boolean|null `TRUE` on success. `FALSE` or `NULL` on failure.
* A special `NULL` return value indicates success with a single failure
* that is specifically related to the `qc-advanced-cache` file.
* that is specifically related to the `zc-advanced-cache` file.
*/
public function add_advanced_cache()
{
Expand Down Expand Up @@ -2868,7 +2868,7 @@ public function add_advanced_cache()
if(is_writable($cache_dir) && !is_file($cache_dir.'/.htaccess'))
file_put_contents($cache_dir.'/.htaccess', $this->htaccess_deny);

if(!is_dir($cache_dir) || !is_writable($cache_dir) || !is_file($cache_dir.'/.htaccess') || !file_put_contents($cache_dir.'/qc-advanced-cache', time()))
if(!is_dir($cache_dir) || !is_writable($cache_dir) || !is_file($cache_dir.'/.htaccess') || !file_put_contents($cache_dir.'/zc-advanced-cache', time()))
{
$this->cache_unlock($cache_lock); // Unlock cache.
return NULL; // Special return value (NULL) in this case.
Expand Down Expand Up @@ -2948,19 +2948,19 @@ public function delete_advanced_cache()
}

/**
* Checks to make sure the `qc-blog-paths` file still exists;
* and if it doesn't, the `qc-blog-paths` file is regenerated automatically.
* Checks to make sure the `zc-blog-paths` file still exists;
* and if it doesn't, the `zc-blog-paths` file is regenerated automatically.
*
* @since 140422 First documented version.
*
* @attaches-to `init` hook.
*
* @note This runs so that remote deployments which completely wipe out an
* existing set of website files (like the AWS Elastic Beanstalk does) will NOT cause ZenCache
* to stop functioning due to the lack of a `qc-blog-paths` file, which is generated by ZenCache.
* to stop functioning due to the lack of a `zc-blog-paths` file, which is generated by ZenCache.
*
* For instance, if you have a Git repo with all of your site files; when you push those files
* to your website to deploy them, you most likely do NOT have the `qc-blog-paths` file.
* to your website to deploy them, you most likely do NOT have the `zc-blog-paths` file.
* ZenCache creates this file on its own. Thus, if it's missing (and QC is active)
* we simply regenerate the file automatically to keep ZenCache running.
*/
Expand All @@ -2976,12 +2976,12 @@ public function check_blog_paths()

$cache_dir = $this->cache_dir(); // Current cache directory.

if(!is_file($cache_dir.'/qc-blog-paths'))
if(!is_file($cache_dir.'/zc-blog-paths'))
$this->update_blog_paths();
}

/**
* Creates and/or updates the `qc-blog-paths` file.
* Creates and/or updates the `zc-blog-paths` file.
*
* @since 140422 First documented version.
*
Expand Down Expand Up @@ -3020,7 +3020,7 @@ public function update_blog_paths($enable_live_network_counts = NULL)
$_path = '/'.ltrim(preg_replace('/^'.preg_quote($this->host_base_token(), '/').'/', '', $_path), '/');
unset($_path); // Housekeeping.

file_put_contents($cache_dir.'/qc-blog-paths', serialize($paths));
file_put_contents($cache_dir.'/zc-blog-paths', serialize($paths));
}
$this->cache_unlock($cache_lock); // Unlock cache directory.

Expand Down

0 comments on commit 1a5cc45

Please sign in to comment.