Skip to content

Commit

Permalink
Merge branch 'release/160227'
Browse files Browse the repository at this point in the history
  • Loading branch information
raamdev committed Feb 27, 2016
2 parents bac4f22 + fd4ede5 commit 2364d22
Show file tree
Hide file tree
Showing 16 changed files with 162 additions and 88 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
= v160227 =

- **Bug Fix**: Fixed a ZenCache Backwards Compatibility bug that was preventing calls to `$GLOBALS['zencache']` from working properly with Comet Cache. See [Issue #689](https://github.com/websharks/comet-cache/issues/689)
- **Bug Fix**: Fixed a ZenCache Backwards Compatibility bug that was preventing `ZENCACHE_ALLOWED` from working properly with Comet Cache. See [Issue #683](https://github.com/websharks/comet-cache/issues/683).
- **Bug Fix**: Fixed a Quick Cache Backwards Compatibility bug that was preventing calls to `$GLOBALS['quick_cache']` from working properly with Comet Cache. Props to @Kedakai for reporting. See [Issue #691](https://github.com/websharks/comet-cache/issues/691).
- **Bug Fix** (Pro): Fixed an Auto-Cache Engine bug that was preventing the Auto-Cache Engine from generating cached pages. Props @digitalhexcode for reporting. See [Issue #679](https://github.com/websharks/comet-cache/issues/679).
- **Enhancement**: Improved the way Comet Cache handles file locking in an effort to improve compatibility with various environments. There were reports of issues with PHP FPM/FastCGI and this release attempts to address those. See [Issue #671](https://github.com/websharks/comet-cache/issues/671)
- **Enhancement** (Pro): A new HTML Compression option allows you to define whether or not HTML Compression should be enabled for Logged-In users (when Logged-In User caching is enabled). See **Comet Cache → Plugin Options → HTML Compression → Enable HTML Compression for Logged-In Users?**. Props @renzms. See [Issue #650](https://github.com/websharks/comet-cache/issues/650).
- **Accelerated Mobile Pages (AMP) Compatibility**: Added full support for Accelerated Mobile Pages via the [AMP plugin](https://wordpress.org/plugins/amp/). Comet Cache now works great alongside the AMP plugin. AMP-generated pages will be cached and those cache files will be intelligently cleared when necessary to keep things up-to-date. See [Issue #688](https://github.com/websharks/comet-cache/issues/688).

= v160223.1 =

- **Bug Fix**: Fixes PHP Fatal Error when upgrading from Comet Cache v160211.

= v160223 =

- **Announcement: After March 1st, 2016 Comet Cache will require PHP Multibyte String support.** The `mbstring` extension provides Multibyte String support to PHP and is required to properly handle UTF-8 characters, which many sites now use. Without Multibyte String support, caching will be unstable. For that reason we are requiring the `mbstring` extension to improve reliability when caching and to prevent your site from experiencing unforeseen issues in the future..
Expand Down
2 changes: 1 addition & 1 deletion comet-cache-pro.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
Version: 160223.1
Version: 160227
Text Domain: comet-cache
Plugin Name: Comet Cache Pro
Network: true
Expand Down
12 changes: 11 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=== Comet Cache ===

Stable tag: 160223.1
Stable tag: 160227
Requires at least: 4.1
Tested up to: 4.5-alpha
Text Domain: comet-cache
Expand Down Expand Up @@ -336,6 +336,16 @@ Requires PHP v5.4+. The latest version of Comet Cache is a complete rewrite (OOP

== Changelog ==

= v160227 =

- **Bug Fix**: Fixed a ZenCache Backwards Compatibility bug that was preventing calls to `$GLOBALS['zencache']` from working properly with Comet Cache. See [Issue #689](https://github.com/websharks/comet-cache/issues/689)
- **Bug Fix**: Fixed a ZenCache Backwards Compatibility bug that was preventing `ZENCACHE_ALLOWED` from working properly with Comet Cache. See [Issue #683](https://github.com/websharks/comet-cache/issues/683).
- **Bug Fix**: Fixed a Quick Cache Backwards Compatibility bug that was preventing calls to `$GLOBALS['quick_cache']` from working properly with Comet Cache. Props to @Kedakai for reporting. See [Issue #691](https://github.com/websharks/comet-cache/issues/691).
- **Bug Fix** (Pro): Fixed an Auto-Cache Engine bug that was preventing the Auto-Cache Engine from generating cached pages. Props @digitalhexcode for reporting. See [Issue #679](https://github.com/websharks/comet-cache/issues/679).
- **Enhancement**: Improved the way Comet Cache handles file locking in an effort to improve compatibility with various environments. There were reports of issues with PHP FPM/FastCGI and this release attempts to address those. See [Issue #671](https://github.com/websharks/comet-cache/issues/671)
- **Enhancement** (Pro): A new HTML Compression option allows you to define whether or not HTML Compression should be enabled for Logged-In users (when Logged-In User caching is enabled). See **Comet Cache → Plugin Options → HTML Compression → Enable HTML Compression for Logged-In Users?**. Props @renzms. See [Issue #650](https://github.com/websharks/comet-cache/issues/650).
- **Accelerated Mobile Pages (AMP) Compatibility**: Added full support for Accelerated Mobile Pages via the [AMP plugin](https://wordpress.org/plugins/amp/). Comet Cache now works great alongside the AMP plugin. AMP-generated pages will be cached and those cache files will be intelligently cleared when necessary to keep things up-to-date. See [Issue #688](https://github.com/websharks/comet-cache/issues/688).

= v160223.1 =

- **Bug Fix**: Fixes PHP Fatal Error when upgrading from Comet Cache v160211.
Expand Down
16 changes: 9 additions & 7 deletions src/includes/classes/AdvCacheBackCompat.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,26 @@ public static function zcRequestVars()
*/
public static function zenCacheConstants()
{
$_global_ns = strtoupper(GLOBAL_NS);

if (!($constants = get_defined_constants(true)) || empty($constants['user'])) {
return; // Nothing to do; i.e. no user-defined constants.
}
foreach ($constants['user'] as $_constant => $_value) {
if (stripos($_constant, 'ZENCACHE_') !== 0) {
continue; // Nothing to do here.
}
if (!($_constant_sub_name = substr($_constant, 12))) {
if (!($_constant_sub_name = substr($_constant, 9))) {
continue; // Nothing to do here.
}
if (!defined(GLOBAL_NS.'_'.$_constant_sub_name)) {
define(GLOBAL_NS.'_'.$_constant_sub_name, $_value);
if (!defined($_global_ns.'_'.$_constant_sub_name)) {
define($_global_ns.'_'.$_constant_sub_name, $_value);
}
}
unset($_constant, $_value); // Housekeeping.

if (isset($_SERVER['ZENCACHE_ALLOWED']) && !isset($_SERVER[GLOBAL_NS.'_ALLOWED'])) {
$_SERVER[GLOBAL_NS.'_ALLOWED'] = $_SERVER['ZENCACHE_ALLOWED'];
if (isset($_SERVER['ZENCACHE_ALLOWED']) && !isset($_SERVER[$_global_ns.'_ALLOWED'])) {
$_SERVER[$_global_ns.'_ALLOWED'] = $_SERVER['ZENCACHE_ALLOWED'];
}

unset($_constant, $_value, $_global_ns); // Housekeeping.
}
}
2 changes: 1 addition & 1 deletion src/includes/classes/AutoCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected function autoCacheUrl($url)
array(
'blocking' => false,
'user-agent' => $this->plugin->options['auto_cache_user_agent'].
'; '.SLUG_TD.' '.VERSION,
'; '.GLOBAL_NS.' '.VERSION,
)
)
);
Expand Down
9 changes: 8 additions & 1 deletion src/includes/classes/MenuPageOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ public function __construct()
echo ' <hr />'."\n";

echo ' <h3>'.__('Auto-Cache User-Agent String', SLUG_TD).'</h3>'."\n";
echo ' <table style="width:100%;"><tr><td><input type="text" name="'.esc_attr(GLOBAL_NS).'[saveOptions][auto_cache_user_agent]" value="'.esc_attr($this->plugin->options['auto_cache_user_agent']).'" /></td><td style="width:1px; font-weight:bold; white-space:nowrap;">; '.esc_html(SLUG_TD.' '.VERSION).'</td></tr></table>'."\n";
echo ' <table style="width:100%;"><tr><td><input type="text" name="'.esc_attr(GLOBAL_NS).'[saveOptions][auto_cache_user_agent]" value="'.esc_attr($this->plugin->options['auto_cache_user_agent']).'" /></td><td style="width:1px; font-weight:bold; white-space:nowrap;">; '.esc_html(GLOBAL_NS.' '.VERSION).'</td></tr></table>'."\n";
echo ' <p class="info" style="display:block;">'.__('This is how the Auto-Cache Engine identifies itself when connecting to URLs. See <a href="http://en.wikipedia.org/wiki/User_agent" target="_blank">User Agent</a> in the Wikipedia.', SLUG_TD).'</p>'."\n";
echo ' </div>'."\n";
echo ' </div>'."\n";
Expand Down Expand Up @@ -865,6 +865,13 @@ public function __construct()
echo ' <p><input type="text" name="'.esc_attr(GLOBAL_NS).'[saveOptions][htmlc_cache_expiration_time]" value="'.esc_attr($this->plugin->options['htmlc_cache_expiration_time']).'" /></p>'."\n";
echo ' <p class="info" style="display:block;">'.__('<strong>Tip:</strong> the value that you specify here MUST be compatible with PHP\'s <a href="http://php.net/manual/en/function.strtotime.php" target="_blank" style="text-decoration:none;"><code>strtotime()</code></a> function. Examples: <code>2 hours</code>, <code>7 days</code>, <code>6 months</code>, <code>1 year</code>.', SLUG_TD).'</p>'."\n";
echo ' <p>'.sprintf(__('<strong>Note:</strong> This does NOT impact the overall cache expiration time that you configure with %1$s. It only impacts the sub-routines provided by the HTML Compressor. In fact, this expiration time is mostly irrelevant. The HTML Compressor uses an internal checksum, and it also checks <code>filemtime()</code> before using an existing cache file. The HTML Compressor class also handles the automatic cleanup of your cache directories to keep it from growing too large over time. Therefore, unless you have VERY little disk space there is no reason to set this to a lower value (even if your site changes dynamically quite often). If anything, you might like to increase this value which could help to further reduce server load. You can <a href="https://github.com/websharks/HTML-Compressor" target="_blank">learn more here</a>. We recommend setting this value to at least double that of your overall %1$s expiration time.', SLUG_TD), esc_html(NAME)).'</p>'."\n";
echo ' <hr />'."\n";
echo ' <h3>'.__('Enable HTML Compression for Logged-In Users?', SLUG_TD).'</h3>'."\n";
echo ' <p>'.__('Disabled by default. This setting is only applicable when caching for Logged-In Users is enabled. This should remain disabled for logged-in users because the user-specific cache has a much shorter Time To Live (TTL) which means their cache is likely to expire more quickly than a normal visitor. Rebuilding the HTML Compressor cache is time-consuming and doing it too frequently will actually slow things down for them. For example, if you\'re logged into the site as a user and you submit a form, that triggers a clearing of the cache for that user, including the HTML Compressor cache (when Logged-In User caching is enabled). Lots of little actions you take can result in a clearing of the cache. This shorter TTL is not ideal when running the HTML Compressor because it does a deep analysis of the page content and the associated resources in order to intelligently compress things. For logged-in users, it is better to skip that extra work and just cache the HTML source as-is, avoiding that extra overhead. In short, do NOT turn this on unless you know what you\'re doing.', SLUG_TD).'</p>'."\n";
echo ' <p><select name="'.esc_attr(GLOBAL_NS).'[saveOptions][htmlc_when_logged_in]">'."\n";
echo ' <option value="0"'.selected($this->plugin->options['htmlc_when_logged_in'], '0', false).'>'.__('No, disable HTML Compression for logged-in users (recommended).', SLUG_TD).'</option>'."\n";
echo ' <option value="postload"'.selected($this->plugin->options['htmlc_when_logged_in'], 'postload', false).'>'.__('Yes, enable HTML Compression for logged-in users.', SLUG_TD).'</option>'."\n";
echo ' </select></p>'."\n";
echo ' </div>'."\n";
echo ' </div>'."\n";

Expand Down
2 changes: 2 additions & 0 deletions src/includes/classes/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ public function setup()
'htmlc_compress_css_code',
'htmlc_compress_js_code',
'htmlc_compress_html_code',
'htmlc_when_logged_in',

'auto_cache_enable',
'auto_cache_max_time',
Expand Down Expand Up @@ -348,6 +349,7 @@ public function setup()
'htmlc_compress_css_code' => '1', // `0|1`.
'htmlc_compress_js_code' => '1', // `0|1`.
'htmlc_compress_html_code' => '1', // `0|1`.
'htmlc_when_logged_in' => '0', // `0|1`; enable when logged in?
/* Related to auto-cache engine. */

Expand Down
3 changes: 3 additions & 0 deletions src/includes/closures/Ac/HtmlCUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
if (!COMET_CACHE_HTMLC_ENABLE) {
return $cache; // Nothing to do here.
}
if ($self->is_user_logged_in && !COMET_CACHE_HTMLC_WHEN_LOGGED_IN) {
return $cache; // Nothing to do here.
}
// Deals with multisite base & sub-directory installs.
// e.g. `htmlc/cache/public/www-example-com` (standard WP installation).
// e.g. `htmlc/cache/public/[[/base]/child1]/www-example-com` (multisite network).
Expand Down
4 changes: 2 additions & 2 deletions src/includes/closures/Plugin/AutoCacheUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/**
* Check if PHP configuration meets minimum requirements for Auto-Cache Engine and remove old notice if necessary.
*
* @since 15xxxx Improving Auto-Cache Engine minimum PHP requirements reporting.
* @since 160103 Improving Auto-Cache Engine minimum PHP requirements reporting.
*
* @attaches-to `admin_init`
*/
Expand All @@ -52,7 +52,7 @@
/**
* Check if PHP configuration meets minimum requirements for Auto-Cache Engine and display a notice if necessary.
*
* @since 15xxxx Improving Auto-Cache Engine minimum PHP requirements reporting.
* @since 160103 Improving Auto-Cache Engine minimum PHP requirements reporting.
*
* @return bool `TRUE` if all required PHP configuration is present, else `FALSE`. This also creates a dashboard notice in some cases.
*
Expand Down
4 changes: 2 additions & 2 deletions src/includes/closures/Plugin/HtaccessUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/*
* Plugin options that have associated htaccess rules.
*
* @since 15xxxx Improving `.htaccess` tweaks.
* @since 160103 Improving `.htaccess` tweaks.
*
* @return array Plugin options that have associated htaccess rules
*
Expand Down Expand Up @@ -140,7 +140,7 @@
/*
* Determines if there are any plugin options enabled that require htaccess rules to be added.
*
* @since 15xxxx Improving `.htaccess` tweaks.
* @since 160103 Improving `.htaccess` tweaks.
*
* @return bool True when an option is enabled that requires htaccess rules, false otherwise.
*/
Expand Down
5 changes: 4 additions & 1 deletion src/includes/closures/Shared/CacheLockUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@
$inode_key = fileinode($wp_config_file);
$mutex = $tmp_dir.'/'.SLUG_TD.'-'.$inode_key.'.lock';

if (!($resource = fopen($mutex, 'w')) || !flock($resource, LOCK_EX)) {
if (!($resource = fopen($mutex, 'wb')) || !flock($resource, LOCK_EX)) {
throw new \Exception(__('Unable to obtain an exclusive lock.', SLUG_TD));
}

@chmod($mutex, 0666); // See https://git.io/v2WAt

return array('type' => 'flock', 'resource' => $resource);
};

Expand Down
6 changes: 4 additions & 2 deletions src/includes/closures/Shared/CachePathUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@
* @since 151220 Enhancing translation support.
*
* @return string Default cache-path suffix frag (regex).
*
* @TODO Use conditional to detect the AMP plugin (e.g., `isAmpInstalled()`) to avoid edge cases with the `|\/amp` regex here
*/
$self->cachePathRegexDefaultSuffixFrag = function () use ($self) {
if ($self->isPlugin() && !empty($GLOBALS['wp_rewrite'])){
$pagination_base = $GLOBALS['wp_rewrite']->pagination_base;
$comments_pagination_base = $GLOBALS['wp_rewrite']->comments_pagination_base;
return '(?:\/index)?(?:\.|\/(?:'.preg_quote($pagination_base, '/').'\/[0-9]+|'.preg_quote($comments_pagination_base, '/').'\-[0-9]+)[.\/])';
return '(?:\/index|\/amp)?(?:\.|\/(?:'.preg_quote($pagination_base, '/').'\/[0-9]+|'.preg_quote($comments_pagination_base, '/').'\-[0-9]+)[.\/])';
} else {
return '(?:\/index)?(?:\.|\/(?:page\/[0-9]+|comment\-page\-[0-9]+)[.\/])';
return '(?:\/index|\/amp)?(?:\.|\/(?:page\/[0-9]+|comment\-page\-[0-9]+)[.\/])';
}
};

Expand Down
5 changes: 4 additions & 1 deletion src/includes/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
require_once dirname(__FILE__).'/stub.php';

if (!Conflicts::check()) {
$GLOBALS[GLOBAL_NS] = new Plugin();
$GLOBALS[GLOBAL_NS] = new Plugin();
$GLOBALS['zencache'] = $GLOBALS[GLOBAL_NS]; // Back compat.
$GLOBALS['quick_cache'] = $GLOBALS[GLOBAL_NS]; // Back compat.

add_action('plugins_loaded', function() {
require_once dirname(__FILE__).'/api.php';
});
Expand Down
2 changes: 1 addition & 1 deletion src/includes/stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
require_once dirname(dirname(__FILE__)).'/vendor/autoload.php';
require_once dirname(__FILE__).'/functions/i18n-utils.php';

${__FILE__}['version'] = '160223.1'; //version//
${__FILE__}['version'] = '160227'; //version//
${__FILE__}['plugin'] = dirname(dirname(dirname(__FILE__)));
${__FILE__}['plugin'] .= '/'.basename(${__FILE__}['plugin']).'.php';
${__FILE__}['ns_path'] = str_replace('\\', '/', __NAMESPACE__); // To dir/path.
Expand Down
12 changes: 12 additions & 0 deletions src/includes/templates/advanced-cache.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,18 @@ if (!defined('COMET_CACHE_HTMLC_ENABLE')) {
}
/*[/pro]*/
/*[pro strip-from="lite"]*/
if (!defined('COMET_CACHE_HTMLC_WHEN_LOGGED_IN')) {
/**
* Enable HTML compressor when logged in?
*
* @since 140422 First documented version.
*
* @var string|integer|boolean A boolean-ish value; e.g. `1` or `0`.
*/
define('COMET_CACHE_HTMLC_WHEN_LOGGED_IN', '%%COMET_CACHE_HTMLC_WHEN_LOGGED_IN%%');
}
/*[/pro]*/
/*[pro strip-from="lite"]*/
if (!defined('COMET_CACHE_HTMLC_CSS_EXCLUSIONS')) {
/**
* CSS exclusions for the HTML compressor.
Expand Down
Loading

0 comments on commit 2364d22

Please sign in to comment.