From f3e6712e4fdd2dac47e6b4e187cc269587ff26a7 Mon Sep 17 00:00:00 2001 From: Richard Brown Date: Thu, 16 Feb 2017 14:48:15 +0000 Subject: [PATCH] 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))); }