From f3e6712e4fdd2dac47e6b4e187cc269587ff26a7 Mon Sep 17 00:00:00 2001 From: Richard Brown Date: Thu, 16 Feb 2017 14:48:15 +0000 Subject: [PATCH 01/20] Apply the option `strip_vcl_whitespace` everywhere In some places the value of strip_vcl_whitespace was not being checked, e.g. The VCL saved to disk on config change was always being stripped. --- .../Turpentine/Model/Observer/Varnish.php | 13 +++++++------ .../controllers/Varnish/ManagementController.php | 9 ++++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/code/community/Nexcessnet/Turpentine/Model/Observer/Varnish.php b/app/code/community/Nexcessnet/Turpentine/Model/Observer/Varnish.php index 1fcadda7c..29d03012a 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Observer/Varnish.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Observer/Varnish.php @@ -83,27 +83,28 @@ public function adminSystemConfigChangedSection($eventObject) { Mage::helper('turpentine/data')->getAutoApplyOnSave()) { $result = Mage::getModel('turpentine/varnish_admin')->applyConfig(); $session = Mage::getSingleton('core/session'); + $helper = Mage::helper('turpentine'); foreach ($result as $name => $value) { if ($value === true) { - $session->addSuccess(Mage::helper('turpentine/data') + $session->addSuccess($helper ->__('VCL successfully applied to: '.$name)); } else { - $session->addError(Mage::helper('turpentine/data') + $session->addError($helper ->__(sprintf('Failed to apply the VCL to %s: %s', $name, $value))); } } $cfgr = Mage::getModel('turpentine/varnish_admin')->getConfigurator(); if (is_null($cfgr)) { - $session->addError(Mage::helper('turpentine/data') + $session->addError($helper ->__('Failed to load configurator')); } else { - $result = $cfgr->save($cfgr->generate()); + $result = $cfgr->save($cfgr->generate($helper->shouldStripVclWhitespace('save'))); if ($result[0]) { - $session->addSuccess(Mage::helper('turpentine/data') + $session->addSuccess($helper ->__('The VCL file has been saved.')); } else { - $session->addError(Mage::helper('turpentine/data') + $session->addError($helper ->__('Failed to save the VCL file: '.$result[1]['message'])); } } diff --git a/app/code/community/Nexcessnet/Turpentine/controllers/Varnish/ManagementController.php b/app/code/community/Nexcessnet/Turpentine/controllers/Varnish/ManagementController.php index 0472d4e62..92909451c 100644 --- a/app/code/community/Nexcessnet/Turpentine/controllers/Varnish/ManagementController.php +++ b/app/code/community/Nexcessnet/Turpentine/controllers/Varnish/ManagementController.php @@ -128,15 +128,18 @@ public function flushContentTypeAction() { */ public function applyConfigAction() { Mage::dispatchEvent('turpentine_varnish_apply_config'); - $result = Mage::getModel('turpentine/varnish_admin')->applyConfig(); + $helper = Mage::helper('turpentine'); + $result = Mage::getModel('turpentine/varnish_admin')->applyConfig($helper + ->shouldStripVclWhitespace('apply') + ); foreach ($result as $name => $value) { if ($value === true) { $this->_getSession() - ->addSuccess(Mage::helper('turpentine') + ->addSuccess($helper ->__('VCL successfully applied to '.$name)); } else { $this->_getSession() - ->addError(Mage::helper('turpentine') + ->addError($helper ->__(sprintf('Failed to apply the VCL to %s: %s', $name, $value))); } From 667149d0d3d6e2f96a5132e61465755ffe09a59d Mon Sep 17 00:00:00 2001 From: Richard Brown Date: Mon, 20 Feb 2017 14:44:33 +0000 Subject: [PATCH 02/20] Don't set X-Forwarded-For in vlc_recv for v4 According to https://varnish-cache.org/docs/5.0/whats-new/upgrading-4.0.html#x-forwarded-for-is-now-set-before-vcl-recv > In many cases, people unintentionally removed X-Forwarded-For when > implementing their own vcl_recv. Therefore it has been moved to before > vcl_recv, so if you don't want an IP added to it, you should remove it > in vcl_recv. Leaving the fragment in vcl_recv results in the proxy ip being inserted twice. --- .../community/Nexcessnet/Turpentine/misc/version-4.vcl | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl b/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl index 470183f62..81259865d 100644 --- a/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl +++ b/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl @@ -111,16 +111,6 @@ sub vcl_recv { {{https_redirect}} - # this always needs to be done so it's up at the top - if (req.restarts == 0) { - if (req.http.X-Forwarded-For) { - set req.http.X-Forwarded-For = - req.http.X-Forwarded-For + ", " + client.ip; - } else { - set req.http.X-Forwarded-For = client.ip; - } - } - # We only deal with GET and HEAD by default # we test this here instead of inside the url base regex section # so we can disable caching for the entire site if needed From 0d9577a2c99f046ffeb94590ee3dba8ccb2ac64e Mon Sep 17 00:00:00 2001 From: Luke Evers Date: Fri, 17 Mar 2017 11:23:16 -0400 Subject: [PATCH 03/20] Add more options for Varnish probing --- .../Model/Varnish/Configurator/Abstract.php | 22 ++++++-- .../Nexcessnet/Turpentine/etc/config.xml | 4 ++ .../Nexcessnet/Turpentine/etc/system.xml | 52 ++++++++++++++++++- 3 files changed, 72 insertions(+), 6 deletions(-) diff --git a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php index d40efe3ea..b03d90cc6 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php @@ -734,6 +734,7 @@ protected function _vcl_director_backend($host, $port, $probeUrl = '', $options * Format a VCL probe declaration to put in backend which is in director * * @param string $probeUrl URL to check if backend is up + * * @return string */ protected function _vcl_get_probe($probeUrl) { @@ -744,17 +745,30 @@ protected function _vcl_get_probe($probeUrl) { } else { $tpl = <<_formatTemplate($tpl, [ 'probe_host' => $urlParts['host'], - 'probe_path' => $urlParts['path'] - ); - return $this->_formatTemplate($tpl, $vars); + 'probe_path' => $urlParts['path'], + 'timeout' => $timeout, + 'interval' => $interval, + 'window' => $window, + 'threshold' => $threshold, + ]); } } diff --git a/app/code/community/Nexcessnet/Turpentine/etc/config.xml b/app/code/community/Nexcessnet/Turpentine/etc/config.xml index 894453a34..155fe3c0a 100644 --- a/app/code/community/Nexcessnet/Turpentine/etc/config.xml +++ b/app/code/community/Nexcessnet/Turpentine/etc/config.xml @@ -58,6 +58,10 @@ 8080 127.0.0.1:8080 + 3s + 8s + 5 + 3 127.0.0.1:8080 300 diff --git a/app/code/community/Nexcessnet/Turpentine/etc/system.xml b/app/code/community/Nexcessnet/Turpentine/etc/system.xml index 575a425fd..6477684f4 100644 --- a/app/code/community/Nexcessnet/Turpentine/etc/system.xml +++ b/app/code/community/Nexcessnet/Turpentine/etc/system.xml @@ -359,10 +359,58 @@ yes|yes_admin + + + Maximum timeout for requests. If the request takes longer than the maximum timeout, it will be marked as a failed response. + text + 24 + 1 + 0 + 0 + + yes|yes_admin + + + + + How often to check a backend. + text + 25 + 1 + 0 + 0 + + yes|yes_admin + + + + + Total number of responses in a window of health. + text + 26 + 1 + 0 + 0 + + yes|yes_admin + + + + + Number of needed successful responses in the backend probe window. + text + 27 + 1 + 0 + 0 + + yes|yes_admin + + textarea - 25 + 28 1 0 0 @@ -373,7 +421,7 @@ text - 27 + 29 1 0 0 From de3657c21c2b465415f2f74fddd54c4d00d9f0fa Mon Sep 17 00:00:00 2001 From: Luke Evers Date: Fri, 17 Mar 2017 11:40:22 -0400 Subject: [PATCH 04/20] Use array definition to support PHP 5.3 --- .../Turpentine/Model/Varnish/Configurator/Abstract.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php index b03d90cc6..2dd09ab25 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php @@ -761,14 +761,14 @@ protected function _vcl_get_probe($probeUrl) { $window = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_window'); $threshold = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_threshold'); - return $this->_formatTemplate($tpl, [ + return $this->_formatTemplate($tpl, array( 'probe_host' => $urlParts['host'], 'probe_path' => $urlParts['path'], 'timeout' => $timeout, 'interval' => $interval, 'window' => $window, 'threshold' => $threshold, - ]); + )); } } From 1c9c9a54673cc41f2662d930cd2a3082c9ab03f8 Mon Sep 17 00:00:00 2001 From: Jeroen Vermeulen Date: Fri, 24 Mar 2017 12:12:38 +0000 Subject: [PATCH 05/20] Varnish v4: Moved configuration of directors to top of `sub vcl_recv` Reason: Also load-balance traffic which hits `return (pipe)` like POST requests, or traffic which is not part of Magento. --- .../Nexcessnet/Turpentine/misc/version-4.vcl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl b/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl index 470183f62..1d597bdbe 100644 --- a/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl +++ b/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl @@ -107,7 +107,13 @@ sub vcl_init { } sub vcl_recv { - {{maintenance_allowed_ips}} + if (req.url ~ "{{url_base_regex}}{{admin_frontname}}") { + set req.backend_hint = {{admin_backend_hint}}; + } else { + {{set_backend_hint}} + } + + {{maintenance_allowed_ips}} {{https_redirect}} @@ -148,10 +154,7 @@ sub vcl_recv { set req.http.X-Turpentine-Secret-Handshake = "{{secret_handshake}}"; # use the special admin backend and pipe if it's for the admin section if (req.url ~ "{{url_base_regex}}{{admin_frontname}}") { - set req.backend_hint = {{admin_backend_hint}}; return (pipe); - } else { - {{set_backend_hint}} } if (req.http.Cookie ~ "\bcurrency=") { set req.http.X-Varnish-Currency = regsub( From ac32e07b4cb50484ffb621d1d707636d6bbd0553 Mon Sep 17 00:00:00 2001 From: Jeroen Vermeulen Date: Fri, 24 Mar 2017 12:20:32 +0000 Subject: [PATCH 06/20] Some whitespace changes to improve layout of generated Varnish4 VCL --- .../Turpentine/Model/Varnish/Configurator/Version4.php | 3 +++ app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version4.php b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version4.php index 78c44c642..770fabcb6 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version4.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version4.php @@ -80,6 +80,7 @@ protected function _vcl_directors() $tpl = << Date: Tue, 13 Jun 2017 11:37:15 +0200 Subject: [PATCH 07/20] Fixed small typo --- app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl b/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl index 470183f62..8264d721d 100644 --- a/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl +++ b/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl @@ -300,7 +300,7 @@ sub vcl_hash { if (req.http.X-Varnish-Esi-Access == "private" && req.http.Cookie ~ "frontend=") { - std.log("hash_data - frontned cookie: " + regsub(req.http.Cookie, "^.*?frontend=([^;]*);*.*$", "\1")); + std.log("hash_data - frontend cookie: " + regsub(req.http.Cookie, "^.*?frontend=([^;]*);*.*$", "\1")); hash_data(regsub(req.http.Cookie, "^.*?frontend=([^;]*);*.*$", "\1")); {{advanced_session_validation}} From d4f1eff917f61880ac1c9249297ecff3a35c297c Mon Sep 17 00:00:00 2001 From: Gianluca Strafella Date: Fri, 14 Jul 2017 14:02:22 +0200 Subject: [PATCH 08/20] default ttl based on session.gc_maxlifetime --- app/code/community/Nexcessnet/Turpentine/Helper/Esi.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php b/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php index d9054c6fe..387abd4db 100644 --- a/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php +++ b/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php @@ -231,7 +231,11 @@ public function getCacheClearEvents() { * @return string */ public function getDefaultEsiTtl() { - return trim(Mage::getStoreConfig('web/cookie/cookie_lifetime')); + $defaultLifeTime = trim(Mage::getStoreConfig('web/cookie/cookie_lifetime')); + if ($defaultLifeTime < 60) { + $defaultLifeTime = ini_get('session.gc_maxlifetime'); + } + return $defaultLifeTime; } /** From bf10b5872ddfe54e9ce7d958cdf280c67a0e3c0b Mon Sep 17 00:00:00 2001 From: Andrew Kett Date: Wed, 26 Jul 2017 12:06:41 +1200 Subject: [PATCH 09/20] Dispatch event in _getTemplateVars to allow other extensions to add custom vcl template variables --- .../Turpentine/Model/Varnish/Configurator/Version2.php | 9 +++++++++ .../Turpentine/Model/Varnish/Configurator/Version3.php | 9 +++++++++ .../Turpentine/Model/Varnish/Configurator/Version4.php | 8 ++++++++ 3 files changed, 26 insertions(+) diff --git a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version2.php b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version2.php index 170153981..650d921bd 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version2.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version2.php @@ -23,6 +23,8 @@ class Nexcessnet_Turpentine_Model_Varnish_Configurator_Version2 extends Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract { const VCL_TEMPLATE_FILE = 'version-2.vcl'; + const VCL_VERSION = '2'; + /** * Generate the Varnish 2.1-compatible VCL @@ -55,6 +57,13 @@ protected function _getTemplateVars() { $vars['esi_public_ttl'] = $this->_getDefaultTtl(); $vars['advanced_session_validation'] = $this->_getAdvancedSessionValidation(); + + //dispatch event to allow other extensions to add custom vcl template variables + Mage::dispatchEvent('turpentine_get_templatevars_after', array( + 'vars' => &$vars, + 'vcl_version'=> self::VCL_VERSION + )); + return $vars; } } diff --git a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version3.php b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version3.php index d025b737c..25d20948a 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version3.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version3.php @@ -23,6 +23,8 @@ class Nexcessnet_Turpentine_Model_Varnish_Configurator_Version3 extends Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract { const VCL_TEMPLATE_FILE = 'version-3.vcl'; + const VCL_VERSION = '3'; + /** * Generate the Varnish 3.0-compatible VCL @@ -60,6 +62,13 @@ protected function _getTemplateVars() { $vars = parent::_getTemplateVars(); $vars['advanced_session_validation'] = $this->_getAdvancedSessionValidation(); + + //dispatch event to allow other extensions to add custom vcl template variables + Mage::dispatchEvent('turpentine_get_templatevars_after', array( + 'vars' => &$vars, + 'vcl_version'=> self::VCL_VERSION + )); + return $vars; } } diff --git a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version4.php b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version4.php index 78c44c642..2ff5d248b 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version4.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version4.php @@ -23,6 +23,8 @@ class Nexcessnet_Turpentine_Model_Varnish_Configurator_Version4 extends Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract { const VCL_TEMPLATE_FILE = 'version-4.vcl'; + const VCL_VERSION = '4'; + /** * Generate the Varnish 4.0-compatible VCL @@ -72,6 +74,12 @@ protected function _getTemplateVars() { $vars['set_backend_hint'] = ''; } + //dispatch event to allow other extensions to add custom vcl template variables + Mage::dispatchEvent('turpentine_get_templatevars_after', array( + 'vars' => &$vars, + 'vcl_version'=> self::VCL_VERSION + )); + return $vars; } From 3ab718657b468aa2cff13363aad7f40f124050d5 Mon Sep 17 00:00:00 2001 From: Andrew Kett Date: Thu, 27 Jul 2017 20:32:28 +1200 Subject: [PATCH 10/20] check for all hosts from all store views in http -> https redirect --- .../Model/Varnish/Configurator/Abstract.php | 43 ++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php index 2b1abb0d0..af6c29d40 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php @@ -930,22 +930,25 @@ protected function _vcl_sub_https_proto_fix() { * @return string */ protected function _vcl_sub_https_redirect_fix() { - $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); - $baseUrl = str_replace(array('http://', 'https://'), '', $baseUrl); - $baseUrl = rtrim($baseUrl, '/'); - + + $hostRegex = array(); + foreach ($this->_getHostNames() as $host) { + $hostRegex[] = 'req.http.host ~ "^(?i)'.$host.'"'; + } + $hostRegex = implode(' || ', $hostRegex); + switch (Mage::getStoreConfig('turpentine_varnish/servers/version')) { case 4.0: case 4.1: $tpl = <<_stripHost(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)); + $hosts = array( + $baseUrl => $baseUrl + ); + + foreach (Mage::app()->getWebsites() as $website) { + foreach ($website->getGroups() as $group) { + $stores = $group->getStores(); + foreach ($stores as $store) { + $baseUrl = $this->_stripHost(Mage::getStoreConfig('web/unsecure/base_url', $store->getId())); + $secureBaseUrl = $this->_stripHost(Mage::getStoreConfig('web/secure/base_url', $store->getId())); + + $hosts[$baseUrl] = $baseUrl; + $hosts[$secureBaseUrl] = $secureBaseUrl; + } + } + } + + return $hosts; + } + + protected function _stripHost ($baseUrl){ + return rtrim(str_replace(array('http://', 'https://'), '', $baseUrl), '/'); + } + /** * Get the allowed IPs when in maintenance mode * From 37b06391aee6f9f59b1e27bc013935f1420685ea Mon Sep 17 00:00:00 2001 From: Simon Sprankel Date: Wed, 10 Jan 2018 18:10:57 +0100 Subject: [PATCH 11/20] fixed MageWorx_XSitemap compatibility MageWorx_XSitemap used to use `xsitemap` for their models, but they now use `mageworx_xsitemap`. --- app/code/community/Nexcessnet/Turpentine/Helper/Cron.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/community/Nexcessnet/Turpentine/Helper/Cron.php b/app/code/community/Nexcessnet/Turpentine/Helper/Cron.php index 2b0449161..991b6a6a7 100644 --- a/app/code/community/Nexcessnet/Turpentine/Helper/Cron.php +++ b/app/code/community/Nexcessnet/Turpentine/Helper/Cron.php @@ -192,7 +192,7 @@ public function getAllUrls() { } } $sitemap = (Mage::getConfig()->getNode('modules/MageWorx_XSitemap') !== FALSE) ? - 'xsitemap/cms_page' : 'sitemap/cms_page'; + 'mageworx_xsitemap/cms_page' : 'sitemap/cms_page'; foreach (Mage::getResourceModel($sitemap) ->getCollection($storeId) as $item) { $urls[] = $baseUrl.$item->getUrl(); From a0d79e323b3dfe48cd09fca5cf12a42b215c46a6 Mon Sep 17 00:00:00 2001 From: "Damian A. Pastorini" Date: Mon, 19 Feb 2018 13:12:21 -0300 Subject: [PATCH 12/20] Update Grid.php - Updated contribution, included options validation to avoid hide the options if full page cache and varnish cache were enabled at the same time. --- .../Turpentine/Block/Adminhtml/Cache/Grid.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/app/code/community/Nexcessnet/Turpentine/Block/Adminhtml/Cache/Grid.php b/app/code/community/Nexcessnet/Turpentine/Block/Adminhtml/Cache/Grid.php index d25bb7b78..087509d68 100644 --- a/app/code/community/Nexcessnet/Turpentine/Block/Adminhtml/Cache/Grid.php +++ b/app/code/community/Nexcessnet/Turpentine/Block/Adminhtml/Cache/Grid.php @@ -1,8 +1,8 @@ getCollection(); $turpentineEnabled = false; $fullPageEnabled = false; - foreach ($collection as $key=>$item) - { - if ($item->getStatus() == 1 && ($item->getId() == 'turpentine_pages' || $item->getId() == 'turpentine_esi_blocks')) - { + foreach ($collection as $key=>$item) { + if ($item->getStatus() == 1 && ($item->getId() == 'turpentine_pages' || $item->getId() == 'turpentine_esi_blocks')) { $turpentineEnabled = true; } - if ($item->getStatus() == 1 && $item->getId() == 'full_page') - { + if ($item->getStatus() == 1 && $item->getId() == 'full_page') { $fullPageEnabled = true; } } - if ($turpentineEnabled) - { + if ($turpentineEnabled && !$fullPageEnabled) { $collection->removeItemByKey('full_page'); } - if ($fullPageEnabled) - { + if ($fullPageEnabled && !$turpentineEnabled) { $collection->removeItemByKey('turpentine_pages'); $collection->removeItemByKey('turpentine_esi_blocks'); } From 2542571064f9cfbe3527e1d605301298f5dd8b9e Mon Sep 17 00:00:00 2001 From: Fernando Kindermann Date: Wed, 9 May 2018 16:57:57 +0200 Subject: [PATCH 13/20] Updated constant REGEXP_VARNISH_VERSION to identify Varnish versions with muliple mayor,minor,sub digits --- .../Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php index ed4b92718..e7feedee4 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php @@ -88,7 +88,7 @@ class Nexcessnet_Turpentine_Model_Varnish_Admin_Socket { * Regexp to detect the varnish version number * @var string */ - const REGEXP_VARNISH_VERSION = '/^varnish\-(?P\d)\.(?P\d)\.(?P\d) revision (?P[0-9a-f]+)$/'; + const REGEXP_VARNISH_VERSION = '/^varnish\-(?P\d+)\.(?P\d+)\.(?P\d+) revision (?P[0-9a-f]+)$/'; /** * VCL config versions, should match config select values From 744784679d10b9278a92f991f0aef83b4d60b736 Mon Sep 17 00:00:00 2001 From: pieterjanliekens Date: Wed, 15 Aug 2018 01:50:33 +0200 Subject: [PATCH 14/20] Fixed comments --- util/warm-cache.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/warm-cache.sh b/util/warm-cache.sh index 300559803..2c87ef08b 100755 --- a/util/warm-cache.sh +++ b/util/warm-cache.sh @@ -80,7 +80,7 @@ fi UA="" if [[ $AGENT =~ .. ]]; then UA="-A '$AGENT'" - echo "Warning with User-Agent '$AGENT'" + echo "Warming with User-Agent '$AGENT'" fi echo "Warming $(cat $TMP_URL_FILE | wc -l) URLs using $CONC concurrent users..." From 470d8c7b3a4e4a1fece2977ffa3d5d5a3a28c8b5 Mon Sep 17 00:00:00 2001 From: Simon Sprankel Date: Thu, 30 Aug 2018 14:32:39 +0200 Subject: [PATCH 15/20] added Bing and Baidu bots to crawler user agents --- app/code/community/Nexcessnet/Turpentine/etc/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/community/Nexcessnet/Turpentine/etc/config.xml b/app/code/community/Nexcessnet/Turpentine/etc/config.xml index 55082bd31..5fc4a10f2 100644 --- a/app/code/community/Nexcessnet/Turpentine/etc/config.xml +++ b/app/code/community/Nexcessnet/Turpentine/etc/config.xml @@ -63,7 +63,7 @@ 300 21600 127.0.0.1 - + 1 From a9ec7b5248e5294b18a30f1b7c1d028825155cbe Mon Sep 17 00:00:00 2001 From: Simon Sprankel Date: Tue, 11 Sep 2018 10:43:34 +0200 Subject: [PATCH 16/20] fixed admin_messages in frontend, fixes #940 --- .../Nexcessnet/Turpentine/Block/Core/Messages.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php b/app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php index d330623e4..f33d0d784 100644 --- a/app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php +++ b/app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php @@ -316,15 +316,7 @@ protected function _clearMessages() { */ protected function _real_toHtml() { if ( ! $this->_directCall) { - switch ($this->getNameInLayout()) { - case 'global_messages': - $this->_directCall = 'getHtml'; - break; - case 'messages': - default: - $this->_directCall = 'getGroupedHtml'; - break; - } + $this->_directCall = 'getGroupedHtml'; } switch ($this->_directCall) { case 'getHtml': From f81e23594f1f718cc97821cad311cd7483515973 Mon Sep 17 00:00:00 2001 From: "varnishm1 on hill.magehost.pro" Date: Thu, 13 Sep 2018 10:43:16 +0200 Subject: [PATCH 17/20] Fix for notice 'Only variables should be passed by reference' in PHP 7. --- .../community/Nexcessnet/Turpentine/Helper/Esi.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php b/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php index 6f59d65de..8435c57ec 100644 --- a/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php +++ b/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php @@ -379,15 +379,17 @@ public function getFormKeyEsiUrl() { */ public function getEsiLayoutBlockNode($layout, $blockName) { // first try very specific by checking for action setEsiOptions inside block - $blockNode = end($layout->getNode()->xpath( + $blockNodes = $layout->getNode()->xpath( sprintf('//block[@name=\'%s\'][action[@method=\'setEsiOptions\']]', $blockName) - )); + ); + $blockNode = end($blockNodes); // fallback: only match name if ( ! ($blockNode instanceof Mage_Core_Model_Layout_Element)) { - $blockNode = end($layout->getNode()->xpath( + $blockNodes = $layout->getNode()->xpath( sprintf('//block[@name=\'%s\']', $blockName) - )); + ); + $blockNode = end($blockNodes); } return $blockNode; } From e8fedec259778448bf81152282397d1aa9a7ce8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=BCnig?= Date: Mon, 24 Sep 2018 15:53:01 +0200 Subject: [PATCH 18/20] Fix Typo in VCL Fixed a Typo in Varnish4.vcl --- app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl b/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl index 15ff7ca06..05d8e41b8 100644 --- a/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl +++ b/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl @@ -301,7 +301,7 @@ sub vcl_hash { if (req.http.X-Varnish-Esi-Access == "private" && req.http.Cookie ~ "frontend=") { - std.log("hash_data - frontned cookie: " + regsub(req.http.Cookie, "^.*?frontend=([^;]*);*.*$", "\1")); + std.log("hash_data - frontend cookie: " + regsub(req.http.Cookie, "^.*?frontend=([^;]*);*.*$", "\1")); hash_data(regsub(req.http.Cookie, "^.*?frontend=([^;]*);*.*$", "\1")); {{advanced_session_validation}} From cb80121e978e1ebbfe6af520c814564ccfe8c509 Mon Sep 17 00:00:00 2001 From: Simon Sprankel Date: Wed, 26 Sep 2018 09:25:53 +0200 Subject: [PATCH 19/20] added more Google bot user agents See https://support.google.com/webmasters/answer/1061943 --- app/code/community/Nexcessnet/Turpentine/etc/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/community/Nexcessnet/Turpentine/etc/config.xml b/app/code/community/Nexcessnet/Turpentine/etc/config.xml index 8e10c31fa..3e53e68af 100644 --- a/app/code/community/Nexcessnet/Turpentine/etc/config.xml +++ b/app/code/community/Nexcessnet/Turpentine/etc/config.xml @@ -67,7 +67,7 @@ 300 21600 127.0.0.1 - + 1 From 96bbddaa4878238a00034a41ecac40d3aba2c31a Mon Sep 17 00:00:00 2001 From: Miguel Balparda Date: Tue, 30 Oct 2018 14:34:44 -0300 Subject: [PATCH 20/20] Bump version for new release. --- app/code/community/Nexcessnet/Turpentine/etc/config.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/community/Nexcessnet/Turpentine/etc/config.xml b/app/code/community/Nexcessnet/Turpentine/etc/config.xml index 3e53e68af..1de6007f7 100644 --- a/app/code/community/Nexcessnet/Turpentine/etc/config.xml +++ b/app/code/community/Nexcessnet/Turpentine/etc/config.xml @@ -20,7 +20,7 @@ - 0.7.4 + 0.7.5