From 0b14a30968fb89b8343df3c2a3a8f10fc249604b Mon Sep 17 00:00:00 2001 From: Jeroen Vermeulen Date: Wed, 26 Oct 2016 12:08:05 +0200 Subject: [PATCH 1/7] Fix for picking the wrong block from the layout when multiple blocks found Some themes like Ultimo use `unsetChild` to remove default Magento blocks, and create the block again with the same name but other properties in another place. The `unsetChild` action does not remove a block from the XML, only from the object structure. When an ESI block is requested, the controller was only looking for the name of the block in the layout XML, so in some cases it picked the removed block. I added a check for setEsiOptions inside the block XML, with a fallback to the old behaviour. --- .../Nexcessnet/Turpentine/Helper/Esi.php | 26 +++++++++++++++++++ .../Turpentine/Model/Observer/Esi.php | 5 ++-- .../Turpentine/controllers/EsiController.php | 6 ++--- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php b/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php index 00250a122..f7b263059 100644 --- a/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php +++ b/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php @@ -362,6 +362,32 @@ public function getFormKeyEsiUrl() { return $esiUrl; } + /** + * Grab a block node by name from the layout XML. + * + * Multiple blocks with the same name may exist in the layout, because some themes + * use 'unsetChild' to remove a block and create it with the same name somewhere + * else. For example Ultimo does this. + * + * @param Mage_Core_Model_Layout $layout + * @param string $blockName value of name= attribute in layout XML + * @return Mage_Core_Model_Layout_Element + */ + public function getEsiLayoutBlockNode($layout,$blockName) { + // first try very specific by checking for action setEsiOptions inside block + $blockNode = current($layout->getNode()->xpath( + sprintf('//block[@name=\'%s\'][action[@method=\'setEsiOptions\']]', + $blockName) + )); + // fallback: only match name + if ( ! ($blockNode instanceof Mage_Core_Model_Layout_Element)) { + $blockNode = current($layout->getNode()->xpath( + sprintf('//block[@name=\'%s\']', $blockName) + )); + } + return $blockNode; + } + /** * Load the ESI cache clear events from the layout * diff --git a/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php b/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php index 09d4a4c10..a79b7727d 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php @@ -415,9 +415,8 @@ protected function _getBlockLayoutHandles($block) { $activeHandles = array(); // get the xml node representing the block we're working on (from the // default handle probably) - $blockNode = current($layout->getNode()->xpath(sprintf( - '//block[@name=\'%s\']', - $block->getNameInLayout() ))); + $blockNode = Mage::helper('turpentine/esi')->getEsiLayoutBlockNode( + $layout, $block->getNameInLayout()); $childBlocks = Mage::helper('turpentine/data') ->getChildBlockNames($blockNode); foreach ($childBlocks as $blockName) { diff --git a/app/code/community/Nexcessnet/Turpentine/controllers/EsiController.php b/app/code/community/Nexcessnet/Turpentine/controllers/EsiController.php index c7c136cdf..061f913f6 100644 --- a/app/code/community/Nexcessnet/Turpentine/controllers/EsiController.php +++ b/app/code/community/Nexcessnet/Turpentine/controllers/EsiController.php @@ -212,10 +212,8 @@ protected function _getEsiBlock($esiData) { $turpentineHelper = Mage::helper('turpentine/data') ->setLayout($layout); - $blockNode = current($layout->getNode()->xpath( - sprintf('//block[@name=\'%s\']', $esiData->getNameInLayout()) - )); - + $blockNode = Mage::helper('turpentine/esi')->getEsiLayoutBlockNode( + $layout, $esiData->getNameInLayout()); if ( ! ($blockNode instanceof Mage_Core_Model_Layout_Element)) { Mage::helper('turpentine/debug')->logWarn( 'No block node found with @name="%s"', From 981952971914971aac37ea466bc9833fbe4b5d4e Mon Sep 17 00:00:00 2001 From: Phu Hoang Date: Thu, 17 Nov 2016 13:47:59 +0700 Subject: [PATCH 2/7] Keep params from original url --- .../community/Nexcessnet/Turpentine/Model/Observer/Esi.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php b/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php index 09d4a4c10..2b1040c5a 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php @@ -297,6 +297,11 @@ public function injectEsi($eventObject) { ); } + /** + * Keep params from original url + */ + $urlOptions['_query'] = Mage::app()->getRequest()->getParams(); + $esiUrl = Mage::getUrl('turpentine/esi/getBlock', $urlOptions); if ($esiOptions[$methodParam] == 'esi') { // setting [web/unsecure/base_url] can be https://... but ESI can never be HTTPS From e519dc81d071ddb100edaa84e538651c7a8bf732 Mon Sep 17 00:00:00 2001 From: bordeo Date: Wed, 14 Dec 2016 12:37:08 +0100 Subject: [PATCH 3/7] varnish 4.1 compatibility --- .../Nexcessnet/Turpentine/Model/Config/Select/Version.php | 1 + .../Nexcessnet/Turpentine/Model/Varnish/Admin.php | 2 +- .../Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php | 7 ++++--- .../Turpentine/Model/Varnish/Configurator/Abstract.php | 6 +++++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/code/community/Nexcessnet/Turpentine/Model/Config/Select/Version.php b/app/code/community/Nexcessnet/Turpentine/Model/Config/Select/Version.php index e88251213..0ce6b3f7b 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Config/Select/Version.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Config/Select/Version.php @@ -26,6 +26,7 @@ public function toOptionArray() { array('value' => '2.1', 'label' => $helper->__('2.1.x')), array('value' => '3.0', 'label' => $helper->__('3.0.x')), array('value' => '4.0', 'label' => $helper->__('4.0.x')), + array('value' => '4.1', 'label' => $helper->__('4.1.x')), array('value' => 'auto', 'label' => $helper->__('Auto')), ); } diff --git a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin.php b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin.php index 6dbb2115d..096448da0 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin.php @@ -138,7 +138,7 @@ protected function _testEsiSyntaxParam($socket) { $result = false; if ($helper->csrfFixupNeeded()) { - if ($socket->getVersion() === '4.0') { + if ($socket->getVersion() === '4.0' || $socket->getVersion() === '4.1' ) { $paramName = 'feature'; $value = $socket->param_show($paramName); $value = explode("\n", $value['text']); 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 7ae3ad6fa..fadcb2c38 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php @@ -82,7 +82,7 @@ class Nexcessnet_Turpentine_Model_Varnish_Admin_Socket { // varnish default, can only be changed at Varnish startup time // if data to write is over this limit the actual run-time limit is checked // and used - const CLI_CMD_LENGTH_LIMIT = 8192; + const CLI_CMD_LENGTH_LIMIT = 16384; /** * Regexp to detect the varnish version number @@ -93,7 +93,7 @@ class Nexcessnet_Turpentine_Model_Varnish_Admin_Socket { /** * VCL config versions, should match config select values */ - static protected $_VERSIONS = array('2.1', '3.0', '4.0'); + static protected $_VERSIONS = array('2.1', '3.0', '4.0', '4.1'); /** * Varnish socket connection @@ -405,7 +405,7 @@ protected function _write($data) { if ($dataLength >= self::CLI_CMD_LENGTH_LIMIT) { $cliBufferResponse = $this->param_show('cli_buffer'); $regexp = '~^cli_buffer\s+(\d+)\s+\[bytes\]~'; - if ($this->getVersion() === '4.0') { + if ($this->getVersion() === '4.0' || $this->getVersion() === '4.1') { // Varnish4 supports "16k" style notation $regexp = '~^cli_buffer\s+Value is:\s+(\d+)([k|m|g|b]{1})?\s+\[bytes\]~'; } @@ -518,6 +518,7 @@ protected function _translateCommandMethod($verb) { case '2.1': $command = str_replace('ban', 'purge', $command); break; + case '4.1': case '4.0': case '3.0': $command = str_replace('purge', 'ban', $command); 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 f539e2b41..a8c6149a7 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php @@ -40,6 +40,7 @@ static public function getFromSocket($socket) { } switch ($version) { case '4.0': + case '4.1': return Mage::getModel( 'turpentine/varnish_configurator_version4', array('socket' => $socket) ); @@ -868,6 +869,7 @@ protected function _vcl_sub_maintenance_allowed_ips() { switch (Mage::getStoreConfig('turpentine_varnish/servers/version')) { case 4.0: + case 4.1: $tpl = <<_vcl_sub_https_redirect_fix(); - if(Mage::getStoreConfig('turpentine_varnish/servers/version') == '4.0'){ + if(Mage::getStoreConfig('turpentine_varnish/servers/version') == '4.0' || Mage::getStoreConfig('turpentine_varnish/servers/version') == '4.1'){ $vars['vcl_synth'] = $this->_vcl_sub_synth_https_fix(); } } From 71573b16446c125cbb237b7a226d9bf98896cbec Mon Sep 17 00:00:00 2001 From: Jeroen Vermeulen Date: Thu, 15 Dec 2016 12:24:14 +0100 Subject: [PATCH 4/7] Small fix for notice when CM_REDISSESSION_LOCKING_ENABLED is already defined Example: 2016-12-15T11:01:56+00:00 ERR (3): Notice: Constant CM_REDISSESSION_LOCKING_ENABLED already defined in /path/to/httpdocs/app/code/community/Nexcessnet/Turpentine/Model/Observer/Varnish.php on line 69 --- .../community/Nexcessnet/Turpentine/Model/Observer/Varnish.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/community/Nexcessnet/Turpentine/Model/Observer/Varnish.php b/app/code/community/Nexcessnet/Turpentine/Model/Observer/Varnish.php index 7eb51c4e3..bfab14f7d 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Observer/Varnish.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Observer/Varnish.php @@ -65,7 +65,8 @@ public function addProductListToolbarRewrite($eventObject) { */ public function fixCmRedisSessionLocks($eventObject) { if (Mage::helper('core')->isModuleEnabled('Cm_RedisSession')) { - if ( ! empty($_COOKIE['frontend']) && 'crawler-session' == $_COOKIE['frontend']) { + if ( ! empty($_COOKIE['frontend']) && 'crawler-session' == $_COOKIE['frontend'] && + !defined('CM_REDISSESSION_LOCKING_ENABLED') ) { define('CM_REDISSESSION_LOCKING_ENABLED', false); } } From 3df3ec0b21cfa2247a811f882e02409be4195b8d Mon Sep 17 00:00:00 2001 From: Miguel Balparda Date: Tue, 27 Dec 2016 10:46:16 -0300 Subject: [PATCH 5/7] Revert "use pass instead of pipe on non GET requests to improve performance" --- 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 5b5758b8d..470183f62 100644 --- a/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl +++ b/app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl @@ -127,7 +127,7 @@ sub vcl_recv { if (!{{enable_caching}} || req.http.Authorization || req.method !~ "^(GET|HEAD|OPTIONS)$" || req.http.Cookie ~ "varnish_bypass={{secret_handshake}}") { - return (pass); + return (pipe); } if({{send_unmodified_url}}) { From bcd58538bed76c35ec00e950847eb2ea3928ff68 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Tue, 27 Dec 2016 13:57:21 +0000 Subject: [PATCH 6/7] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- .../Turpentine/Block/Poll/ActivePoll.php | 30 +++++++++---------- .../Nexcessnet/Turpentine/Helper/Esi.php | 2 +- .../Turpentine/Model/Core/Session.php | 2 +- .../Turpentine/Model/Observer/Esi.php | 10 +++---- .../Turpentine/Model/Observer/Varnish.php | 2 +- .../Turpentine/Model/Varnish/Admin.php | 2 +- .../Turpentine/Model/Varnish/Admin/Socket.php | 2 +- .../Model/Varnish/Configurator/Abstract.php | 25 ++++++++-------- .../Model/Varnish/Configurator/Version3.php | 3 +- .../Model/Varnish/Configurator/Version4.php | 11 ++++--- .../Turpentine/controllers/EsiController.php | 6 ++-- contrib/tools/esi-decoder.php | 22 +++++++------- 12 files changed, 57 insertions(+), 60 deletions(-) diff --git a/app/code/community/Nexcessnet/Turpentine/Block/Poll/ActivePoll.php b/app/code/community/Nexcessnet/Turpentine/Block/Poll/ActivePoll.php index 56343127f..665af029b 100644 --- a/app/code/community/Nexcessnet/Turpentine/Block/Poll/ActivePoll.php +++ b/app/code/community/Nexcessnet/Turpentine/Block/Poll/ActivePoll.php @@ -21,19 +21,19 @@ class Nexcessnet_Turpentine_Block_Poll_ActivePoll extends Mage_Poll_Block_ActivePoll { - public function setTemplate($template) - { - if ((Mage::getConfig()->getModuleConfig('Mage_Poll')->is('active', 'true')) && - (!Mage::getStoreConfig('advanced/modules_disable_output/Mage_Poll'))) - { - $this->_template = $template; - $this->setPollTemplate('turpentine/ajax.phtml', 'poll'); - $this->setPollTemplate('turpentine/ajax.phtml', 'results'); - } - else - { - // Mage_Poll is disabled, so do nothing - } - return $this; - } + public function setTemplate($template) + { + if ((Mage::getConfig()->getModuleConfig('Mage_Poll')->is('active', 'true')) && + (!Mage::getStoreConfig('advanced/modules_disable_output/Mage_Poll'))) + { + $this->_template = $template; + $this->setPollTemplate('turpentine/ajax.phtml', 'poll'); + $this->setPollTemplate('turpentine/ajax.phtml', 'results'); + } + else + { + // Mage_Poll is disabled, so do nothing + } + return $this; + } } diff --git a/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php b/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php index f7b263059..d9054c6fe 100644 --- a/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php +++ b/app/code/community/Nexcessnet/Turpentine/Helper/Esi.php @@ -373,7 +373,7 @@ public function getFormKeyEsiUrl() { * @param string $blockName value of name= attribute in layout XML * @return Mage_Core_Model_Layout_Element */ - public function getEsiLayoutBlockNode($layout,$blockName) { + public function getEsiLayoutBlockNode($layout, $blockName) { // first try very specific by checking for action setEsiOptions inside block $blockNode = current($layout->getNode()->xpath( sprintf('//block[@name=\'%s\'][action[@method=\'setEsiOptions\']]', diff --git a/app/code/community/Nexcessnet/Turpentine/Model/Core/Session.php b/app/code/community/Nexcessnet/Turpentine/Model/Core/Session.php index 4078fffb1..141c667b2 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Core/Session.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Core/Session.php @@ -56,7 +56,7 @@ public function real_getFormKey() */ public function renewFormKey() { - $this->setData('_form_key', Mage::helper('core')->getRandomString(16)); + $this->setData('_form_key', Mage::helper('core')->getRandomString(16)); } /** diff --git a/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php b/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php index a79b7727d..bf06417a0 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php @@ -227,9 +227,9 @@ public function injectEsi($eventObject) { 'Checking ESI block candidate: %s', $blockObject->getNameInLayout() ? $blockObject->getNameInLayout() : $blockObject->getModuleName() ); - $debugHelper->logInfo( "-- block testing: shouldResponseUseEsi = " . $esiHelper->shouldResponseUseEsi()); - $debugHelper->logInfo( "-- block testing: instanceof Mage_Core_Block_Template = " . $blockObject instanceof Mage_Core_Block_Template ); - $debugHelper->logInfo( "-- block testing: Esi Options = " . print_r($blockObject->getEsiOptions(), true) ); + $debugHelper->logInfo("-- block testing: shouldResponseUseEsi = ".$esiHelper->shouldResponseUseEsi()); + $debugHelper->logInfo("-- block testing: instanceof Mage_Core_Block_Template = ".$blockObject instanceof Mage_Core_Block_Template); + $debugHelper->logInfo("-- block testing: Esi Options = ".print_r($blockObject->getEsiOptions(), true)); } if ($esiHelper->shouldResponseUseEsi() && $blockObject instanceof Mage_Core_Block_Template && @@ -332,8 +332,8 @@ protected function _getEsiData($blockObject, $esiOptions) { $methodParam = $esiHelper->getEsiMethodParam(); $esiData = new Varien_Object(); $esiData->setStoreId(Mage::app()->getStore()->getId()); - $esiData->setDesignPackage( Mage::getDesign()->getPackageName() ); - $esiData->setDesignTheme( Mage::getDesign()->getTheme( 'layout' ) ); + $esiData->setDesignPackage(Mage::getDesign()->getPackageName()); + $esiData->setDesignTheme(Mage::getDesign()->getTheme('layout')); $esiData->setNameInLayout($blockObject->getNameInLayout()); $esiData->setBlockType(get_class($blockObject)); $esiData->setLayoutHandles($this->_getBlockLayoutHandles($blockObject)); diff --git a/app/code/community/Nexcessnet/Turpentine/Model/Observer/Varnish.php b/app/code/community/Nexcessnet/Turpentine/Model/Observer/Varnish.php index bfab14f7d..1fcadda7c 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Observer/Varnish.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Observer/Varnish.php @@ -66,7 +66,7 @@ public function addProductListToolbarRewrite($eventObject) { public function fixCmRedisSessionLocks($eventObject) { if (Mage::helper('core')->isModuleEnabled('Cm_RedisSession')) { if ( ! empty($_COOKIE['frontend']) && 'crawler-session' == $_COOKIE['frontend'] && - !defined('CM_REDISSESSION_LOCKING_ENABLED') ) { + ! defined('CM_REDISSESSION_LOCKING_ENABLED')) { define('CM_REDISSESSION_LOCKING_ENABLED', false); } } diff --git a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin.php b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin.php index 096448da0..764f5dac5 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin.php @@ -138,7 +138,7 @@ protected function _testEsiSyntaxParam($socket) { $result = false; if ($helper->csrfFixupNeeded()) { - if ($socket->getVersion() === '4.0' || $socket->getVersion() === '4.1' ) { + if ($socket->getVersion() === '4.0' || $socket->getVersion() === '4.1') { $paramName = 'feature'; $value = $socket->param_show($paramName); $value = explode("\n", $value['text']); 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 fadcb2c38..ed4b92718 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php @@ -500,7 +500,7 @@ protected function _command($verb, $okCode = 200) { $response['code'], $response['text'] )); } else { if (Mage::getStoreConfig('turpentine_varnish/general/varnish_log_commands')) { - Mage::helper('turpentine/debug')->logDebug('VARNISH command sent: ' . $data); + Mage::helper('turpentine/debug')->logDebug('VARNISH command sent: '.$data); } return $response; } 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 a8c6149a7..d40efe3ea 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php @@ -111,8 +111,8 @@ public function save($generatedConfig) { * @return string */ protected function _getVclTemplateFilename($baseFilename) { - $extensionDir = Mage::getModuleDir('', 'Nexcessnet_Turpentine'); - return sprintf('%s/misc/%s', $extensionDir, $baseFilename); + $extensionDir = Mage::getModuleDir('', 'Nexcessnet_Turpentine'); + return sprintf('%s/misc/%s', $extensionDir, $baseFilename); } /** @@ -131,7 +131,7 @@ protected function _getVclFilename() { * * @return string */ - protected function _getCustomIncludeFilename($position='') { + protected function _getCustomIncludeFilename($position = '') { $key = 'custom_include_file'; $key .= ($position) ? '_'.$position : ''; return $this->_formatTemplate( @@ -151,8 +151,7 @@ protected function _getCustomTemplateFilename() { Mage::getStoreConfig('turpentine_varnish/servers/custom_vcl_template'), array('root_dir' => Mage::getBaseDir()) ); - if (is_file($filePath)) { return $filePath; } - else { return null; } + if (is_file($filePath)) { return $filePath; } else { return null; } } @@ -193,8 +192,8 @@ protected function _vcl_call($subroutine) { */ protected function _getAdminFrontname() { if (Mage::getStoreConfig('admin/url/use_custom_path')) { - if(Mage::getStoreConfig('web/url/use_store')) { - return Mage::getModel('core/store')->load(0)->getCode() . "/" . Mage::getStoreConfig('admin/url/custom_path'); + if (Mage::getStoreConfig('web/url/use_store')) { + return Mage::getModel('core/store')->load(0)->getCode()."/".Mage::getStoreConfig('admin/url/custom_path'); } else { return Mage::getStoreConfig('admin/url/custom_path'); } @@ -909,8 +908,8 @@ protected function _vcl_sub_maintenance_allowed_ips() { */ 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,'/'); + $baseUrl = str_replace(array('http://', 'https://'), '', $baseUrl); + $baseUrl = rtrim($baseUrl, '/'); switch (Mage::getStoreConfig('turpentine_varnish/servers/version')) { case 4.0: @@ -982,7 +981,7 @@ protected function _vcl_sub_synth_https_fix() { $tpl = $this->_vcl_sub_synth(); - if(!$tpl){ + if ( ! $tpl) { $tpl = <<_vcl_sub_https_redirect_fix(); - if(Mage::getStoreConfig('turpentine_varnish/servers/version') == '4.0' || Mage::getStoreConfig('turpentine_varnish/servers/version') == '4.1'){ + if (Mage::getStoreConfig('turpentine_varnish/servers/version') == '4.0' || Mage::getStoreConfig('turpentine_varnish/servers/version') == '4.1') { $vars['vcl_synth'] = $this->_vcl_sub_synth_https_fix(); } } - foreach (array('','top') as $position) { + foreach (array('', 'top') as $position) { $customIncludeFile = $this->_getCustomIncludeFilename($position); if (is_readable($customIncludeFile)) { $key = 'custom_vcl_include'; 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 2247404b0..d025b737c 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version3.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version3.php @@ -35,8 +35,7 @@ public function generate($doClean = true) { $customTemplate = $this->_getCustomTemplateFilename(); if ($customTemplate) { $tplFile = $customTemplate; - } - else { + } else { $tplFile = $this->_getVclTemplateFilename(self::VCL_TEMPLATE_FILE); } $vcl = $this->_formatTemplate(file_get_contents($tplFile), 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 72512cbcf..78c44c642 100644 --- a/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version4.php +++ b/app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version4.php @@ -35,8 +35,7 @@ public function generate($doClean = true) { $customTemplate = $this->_getCustomTemplateFilename(); if ($customTemplate) { $tplFile = $customTemplate; - } - else { + } else { $tplFile = $this->_getVclTemplateFilename(self::VCL_TEMPLATE_FILE); } $vcl = $this->_formatTemplate(file_get_contents($tplFile), @@ -94,13 +93,13 @@ protected function _vcl_directors() $backendNodes = Mage::helper('turpentine/data')->cleanExplode(PHP_EOL, Mage::getStoreConfig('turpentine_vcl/backend/backend_nodes')); - for($i = 0, $iMax = count($backendNodes); $i < $iMax; $i++) { + for ($i = 0, $iMax = count($backendNodes); $i < $iMax; $i++) { $tpl .= <<_vcl_director_backend($host, $port, $prefix . $number, $probeUrl, $backendOptions); + $backends .= $this->_vcl_director_backend($host, $port, $prefix.$number, $probeUrl, $backendOptions); $number++; } diff --git a/app/code/community/Nexcessnet/Turpentine/controllers/EsiController.php b/app/code/community/Nexcessnet/Turpentine/controllers/EsiController.php index 061f913f6..576e77c34 100644 --- a/app/code/community/Nexcessnet/Turpentine/controllers/EsiController.php +++ b/app/code/community/Nexcessnet/Turpentine/controllers/EsiController.php @@ -183,9 +183,9 @@ protected function _getEsiBlock($esiData) { } } $layout = Mage::getSingleton('core/layout'); - Mage::getSingleton( 'core/design_package' ) - ->setPackageName( $esiData->getDesignPackage() ) - ->setTheme( $esiData->getDesignTheme() ); + Mage::getSingleton('core/design_package') + ->setPackageName($esiData->getDesignPackage()) + ->setTheme($esiData->getDesignTheme()); // dispatch event for adding handles to layout update Mage::dispatchEvent( diff --git a/contrib/tools/esi-decoder.php b/contrib/tools/esi-decoder.php index cf2bb6685..553e3f2fa 100644 --- a/contrib/tools/esi-decoder.php +++ b/contrib/tools/esi-decoder.php @@ -1,16 +1,16 @@ Date: Tue, 21 Feb 2017 08:18:33 -0600 Subject: [PATCH 7/7] Bump version --- 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 7934d4e8e..894453a34 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.1 + 0.7.2