From b59bf78e16e6672a84460a94ba5e6249a4c22ca4 Mon Sep 17 00:00:00 2001 From: Raam Dev Date: Mon, 27 Jun 2016 21:03:54 -0400 Subject: [PATCH] Fix upgrade bug w/ COMET_CACHE_ALLOW_CLIENT_SIDE_CACHE undefined warning See websharks/comet-cache#789 --- src/includes/classes/VsUpgrades.php | 7 ++++++- src/includes/traits/Ac/ClientSideUtils.php | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/includes/classes/VsUpgrades.php b/src/includes/classes/VsUpgrades.php index 91b8a0f4..70b8fc06 100644 --- a/src/includes/classes/VsUpgrades.php +++ b/src/includes/classes/VsUpgrades.php @@ -42,6 +42,7 @@ protected function runHandlers() $this->fromLte151114(); $this->fromZenCache(); $this->fromLte160227(); + $this->fromLte160521(); } /** @@ -227,14 +228,18 @@ protected function fromLte160227() /** * Before we renamed the Auto-Cache Engine requirements check notice to `auto_cache_engine_minimum_requirements`, * and before we renamed the `allow_browser_cache` option to `allow_client_side_cache`, - * and before we added the `htaccess_access_control_allow_origin` option. + * and before we added the `htaccess_access_control_allow_origin` option, + * and before we renamed COMET_CACHE_ALLOW_BROWSER_CACHE to COMET_CACHE_ALLOW_CLIENT_SIDE_CACHE. * * @since 16xxxx */ protected function fromLte160521() { if (version_compare($this->prev_version, '160521', '<=')) { + global $is_apache; // WP global for web server checks below. + $this->plugin->dismissMainNotice('allow_url_fopen_disabled'); + $this->plugin->removeAdvancedCache(); if (is_array($existing_options = get_site_option(GLOBAL_NS.'_options'))) { if (isset($existing_options['allow_browser_cache'])) { diff --git a/src/includes/traits/Ac/ClientSideUtils.php b/src/includes/traits/Ac/ClientSideUtils.php index 83d55625..09242694 100644 --- a/src/includes/traits/Ac/ClientSideUtils.php +++ b/src/includes/traits/Ac/ClientSideUtils.php @@ -12,6 +12,10 @@ trait ClientSideUtils */ public function maybeStopBrowserCaching() { + if (!defined('COMET_CACHE_ALLOW_CLIENT_SIDE_CACHE')) { + return $this->sendNoCacheHeaders(); // Upgrading from <= v160521, before we renamed this constant. Return default. + } + switch ((bool) COMET_CACHE_ALLOW_CLIENT_SIDE_CACHE) { case true: // If global config allows, check exclusions.