Version Notes
Supports Magento v1.6 and later
Download this release
Release Info
| Developer | Chris Wells |
| Extension | Nexcessnet_Turpentine |
| Version | 0.6.1 |
| Comparing to | |
| See all releases | |
Code changes from version 0.6.0 to 0.6.1
- app/code/community/Nexcessnet/Turpentine/Block/Catalog/Product/List/Toolbar.php +5 -0
- app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php +1 -1
- app/code/community/Nexcessnet/Turpentine/Helper/Cron.php +3 -1
- app/code/community/Nexcessnet/Turpentine/Helper/Data.php +26 -0
- app/code/community/Nexcessnet/Turpentine/Model/Config/Select/StripWhitespace.php +31 -0
- app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin.php +2 -1
- app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php +4 -3
- app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version2.php +3 -2
- app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version3.php +3 -2
- app/code/community/Nexcessnet/Turpentine/controllers/EsiController.php +84 -19
- app/code/community/Nexcessnet/Turpentine/controllers/Varnish/ManagementController.php +4 -2
- app/code/community/Nexcessnet/Turpentine/etc/config.xml +2 -1
- app/code/community/Nexcessnet/Turpentine/etc/system.xml +11 -1
- app/code/community/Nexcessnet/Turpentine/misc/version-2.vcl +1 -1
- app/code/community/Nexcessnet/Turpentine/misc/version-3.vcl +1 -1
- app/design/frontend/base/default/layout/turpentine_esi.xml +2 -9
- package.xml +1 -1
app/code/community/Nexcessnet/Turpentine/Block/Catalog/Product/List/Toolbar.php
CHANGED
|
@@ -25,5 +25,10 @@ class Nexcessnet_Turpentine_Block_Catalog_Product_List_Toolbar extends
|
|
| 25 |
public function _construct() {
|
| 26 |
parent::_construct();
|
| 27 |
$this->disableParamsMemorizing();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
}
|
| 29 |
}
|
| 25 |
public function _construct() {
|
| 26 |
parent::_construct();
|
| 27 |
$this->disableParamsMemorizing();
|
| 28 |
+
// Remove params that may have been memorized before this fix was active.
|
| 29 |
+
Mage::getSingleton('catalog/session')->unsSortOrder();
|
| 30 |
+
Mage::getSingleton('catalog/session')->unsSortDirection();
|
| 31 |
+
Mage::getSingleton('catalog/session')->unsDisplayMode();
|
| 32 |
+
Mage::getSingleton('catalog/session')->unsLimitPage();
|
| 33 |
}
|
| 34 |
}
|
app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php
CHANGED
|
@@ -114,7 +114,7 @@ class Nexcessnet_Turpentine_Block_Core_Messages extends Mage_Core_Block_Messages
|
|
| 114 |
*/
|
| 115 |
public function addMessage( Mage_Core_Model_Message_Abstract $message ) {
|
| 116 |
if( $this->_fixMessages() ) {
|
| 117 |
-
$this->_saveMessages( $message
|
| 118 |
} else {
|
| 119 |
parent::addMessage( $message );
|
| 120 |
}
|
| 114 |
*/
|
| 115 |
public function addMessage( Mage_Core_Model_Message_Abstract $message ) {
|
| 116 |
if( $this->_fixMessages() ) {
|
| 117 |
+
$this->_saveMessages( array( $message ) );
|
| 118 |
} else {
|
| 119 |
parent::addMessage( $message );
|
| 120 |
}
|
app/code/community/Nexcessnet/Turpentine/Helper/Cron.php
CHANGED
|
@@ -173,7 +173,9 @@ class Nexcessnet_Turpentine_Helper_Cron extends Mage_Core_Helper_Abstract {
|
|
| 173 |
$urls[] = $prod->getProductUrl();
|
| 174 |
}
|
| 175 |
}
|
| 176 |
-
|
|
|
|
|
|
|
| 177 |
->getCollection( $storeId ) as $item ) {
|
| 178 |
$urls[] = $baseUrl . $item->getUrl();
|
| 179 |
}
|
| 173 |
$urls[] = $prod->getProductUrl();
|
| 174 |
}
|
| 175 |
}
|
| 176 |
+
$sitemap = (Mage::getConfig()->getNode('modules/MageWorx_XSitemap') !== FALSE) ?
|
| 177 |
+
'xsitemap/cms_page' : 'sitemap/cms_page';
|
| 178 |
+
foreach( Mage::getResourceModel( $sitemap )
|
| 179 |
->getCollection( $storeId ) as $item ) {
|
| 180 |
$urls[] = $baseUrl . $item->getUrl();
|
| 181 |
}
|
app/code/community/Nexcessnet/Turpentine/Helper/Data.php
CHANGED
|
@@ -270,6 +270,32 @@ class Nexcessnet_Turpentine_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
| 270 |
'turpentine_varnish/general/auto_apply_on_save' );
|
| 271 |
}
|
| 272 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 273 |
/**
|
| 274 |
* Get the cookie name for the Varnish bypass
|
| 275 |
*
|
| 270 |
'turpentine_varnish/general/auto_apply_on_save' );
|
| 271 |
}
|
| 272 |
|
| 273 |
+
/**
|
| 274 |
+
* Get config value specifying when to strip VCL whitespaces
|
| 275 |
+
*
|
| 276 |
+
* @return string
|
| 277 |
+
*/
|
| 278 |
+
public function getStripVclWhitespace() {
|
| 279 |
+
return Mage::getStoreConfig(
|
| 280 |
+
'turpentine_varnish/general/strip_vcl_whitespace' );
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
/**
|
| 284 |
+
* Check if VCL whitespaces should be stripped for the given action
|
| 285 |
+
*
|
| 286 |
+
* @param string $action can be either "apply", "save" or "download"
|
| 287 |
+
* @return bool
|
| 288 |
+
*/
|
| 289 |
+
public function shouldStripVclWhitespace($action) {
|
| 290 |
+
$configValue = $this->getStripVclWhitespace();
|
| 291 |
+
if ( $configValue==='always' ) {
|
| 292 |
+
return true;
|
| 293 |
+
} elseif ( $configValue==='apply' && $action==='apply' ) {
|
| 294 |
+
return true;
|
| 295 |
+
}
|
| 296 |
+
return false;
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
/**
|
| 300 |
* Get the cookie name for the Varnish bypass
|
| 301 |
*
|
app/code/community/Nexcessnet/Turpentine/Model/Config/Select/StripWhitespace.php
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* Nexcess.net Turpentine Extension for Magento
|
| 5 |
+
* Copyright (C) 2012 Nexcess.net L.L.C.
|
| 6 |
+
*
|
| 7 |
+
* This program is free software; you can redistribute it and/or modify
|
| 8 |
+
* it under the terms of the GNU General Public License as published by
|
| 9 |
+
* the Free Software Foundation; either version 2 of the License, or
|
| 10 |
+
* (at your option) any later version.
|
| 11 |
+
*
|
| 12 |
+
* This program is distributed in the hope that it will be useful,
|
| 13 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 14 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 15 |
+
* GNU General Public License for more details.
|
| 16 |
+
*
|
| 17 |
+
* You should have received a copy of the GNU General Public License along
|
| 18 |
+
* with this program; if not, write to the Free Software Foundation, Inc.,
|
| 19 |
+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
| 20 |
+
*/
|
| 21 |
+
|
| 22 |
+
class Nexcessnet_Turpentine_Model_Config_Select_stripWhitespace {
|
| 23 |
+
public function toOptionArray() {
|
| 24 |
+
$helper = Mage::helper('turpentine');
|
| 25 |
+
return array(
|
| 26 |
+
array( 'value' => 'always', 'label' => $helper->__( 'Always' ) ),
|
| 27 |
+
array( 'value' => 'apply', 'label' => $helper->__( 'Only when applying directly to Varnish' ) ),
|
| 28 |
+
array( 'value' => 'never', 'label' => $helper->__( 'Never' ) ),
|
| 29 |
+
);
|
| 30 |
+
}
|
| 31 |
+
}
|
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin.php
CHANGED
|
@@ -99,13 +99,14 @@ class Nexcessnet_Turpentine_Model_Varnish_Admin {
|
|
| 99 |
*/
|
| 100 |
public function applyConfig() {
|
| 101 |
$result = array();
|
|
|
|
| 102 |
foreach( Mage::helper( 'turpentine/varnish' )->getSockets() as $socket ) {
|
| 103 |
$cfgr = Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract::getFromSocket( $socket );
|
| 104 |
$socketName = $socket->getConnectionString();
|
| 105 |
if( is_null( $cfgr ) ) {
|
| 106 |
$result[$socketName] = 'Failed to load configurator';
|
| 107 |
} else {
|
| 108 |
-
$vcl = $cfgr->generate();
|
| 109 |
$vclName = Mage::helper( 'turpentine/data' )
|
| 110 |
->secureHash( microtime() );
|
| 111 |
try {
|
| 99 |
*/
|
| 100 |
public function applyConfig() {
|
| 101 |
$result = array();
|
| 102 |
+
$helper = Mage::helper( 'turpentine' );
|
| 103 |
foreach( Mage::helper( 'turpentine/varnish' )->getSockets() as $socket ) {
|
| 104 |
$cfgr = Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract::getFromSocket( $socket );
|
| 105 |
$socketName = $socket->getConnectionString();
|
| 106 |
if( is_null( $cfgr ) ) {
|
| 107 |
$result[$socketName] = 'Failed to load configurator';
|
| 108 |
} else {
|
| 109 |
+
$vcl = $cfgr->generate( $helper->shouldStripVclWhitespace('apply') );
|
| 110 |
$vclName = Mage::helper( 'turpentine/data' )
|
| 111 |
->secureHash( microtime() );
|
| 112 |
try {
|
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php
CHANGED
|
@@ -71,7 +71,7 @@ abstract class Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract {
|
|
| 71 |
$this->_options = array_merge( $this->_options, $options );
|
| 72 |
}
|
| 73 |
|
| 74 |
-
abstract public function generate();
|
| 75 |
// abstract protected function _getTemplateVars();
|
| 76 |
|
| 77 |
/**
|
|
@@ -170,7 +170,7 @@ abstract class Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract {
|
|
| 170 |
if( Mage::getStoreConfig( 'admin/url/use_custom_path' ) ) {
|
| 171 |
return Mage::getStoreConfig( 'admin/url/custom_path' );
|
| 172 |
} else {
|
| 173 |
-
return Mage::getConfig()->getNode(
|
| 174 |
'admin/routers/adminhtml/args/frontName' );
|
| 175 |
}
|
| 176 |
}
|
|
@@ -483,7 +483,8 @@ abstract class Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract {
|
|
| 483 |
*/
|
| 484 |
protected function _cleanVclHelper( $line ) {
|
| 485 |
return $line &&
|
| 486 |
-
( substr( $line, 0, 1 ) != '#'
|
|
|
|
| 487 |
substr( $line, 0, 8 ) == '#include' );
|
| 488 |
}
|
| 489 |
|
| 71 |
$this->_options = array_merge( $this->_options, $options );
|
| 72 |
}
|
| 73 |
|
| 74 |
+
abstract public function generate($doClean=true);
|
| 75 |
// abstract protected function _getTemplateVars();
|
| 76 |
|
| 77 |
/**
|
| 170 |
if( Mage::getStoreConfig( 'admin/url/use_custom_path' ) ) {
|
| 171 |
return Mage::getStoreConfig( 'admin/url/custom_path' );
|
| 172 |
} else {
|
| 173 |
+
return (string)Mage::getConfig()->getNode(
|
| 174 |
'admin/routers/adminhtml/args/frontName' );
|
| 175 |
}
|
| 176 |
}
|
| 483 |
*/
|
| 484 |
protected function _cleanVclHelper( $line ) {
|
| 485 |
return $line &&
|
| 486 |
+
( ( substr( $line, 0, 1 ) != '#' &&
|
| 487 |
+
substr( $line, 0, 2 ) != '//' ) ||
|
| 488 |
substr( $line, 0, 8 ) == '#include' );
|
| 489 |
}
|
| 490 |
|
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version2.php
CHANGED
|
@@ -27,13 +27,14 @@ class Nexcessnet_Turpentine_Model_Varnish_Configurator_Version2
|
|
| 27 |
/**
|
| 28 |
* Generate the Varnish 2.1-compatible VCL
|
| 29 |
*
|
|
|
|
| 30 |
* @return string
|
| 31 |
*/
|
| 32 |
-
public function generate() {
|
| 33 |
$tplFile = $this->_getVclTemplateFilename( self::VCL_TEMPLATE_FILE );
|
| 34 |
$vcl = $this->_formatTemplate( file_get_contents( $tplFile ),
|
| 35 |
$this->_getTemplateVars() );
|
| 36 |
-
|
| 37 |
}
|
| 38 |
|
| 39 |
protected function _getAdvancedSessionValidation() {
|
| 27 |
/**
|
| 28 |
* Generate the Varnish 2.1-compatible VCL
|
| 29 |
*
|
| 30 |
+
* @param bool $doClean if true, VCL will be cleaned (whitespaces stripped, etc.)
|
| 31 |
* @return string
|
| 32 |
*/
|
| 33 |
+
public function generate($doClean=true) {
|
| 34 |
$tplFile = $this->_getVclTemplateFilename( self::VCL_TEMPLATE_FILE );
|
| 35 |
$vcl = $this->_formatTemplate( file_get_contents( $tplFile ),
|
| 36 |
$this->_getTemplateVars() );
|
| 37 |
+
return $doClean ? $this->_cleanVcl( $vcl ) : $vcl;
|
| 38 |
}
|
| 39 |
|
| 40 |
protected function _getAdvancedSessionValidation() {
|
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version3.php
CHANGED
|
@@ -27,13 +27,14 @@ class Nexcessnet_Turpentine_Model_Varnish_Configurator_Version3
|
|
| 27 |
/**
|
| 28 |
* Generate the Varnish 3.0-compatible VCL
|
| 29 |
*
|
|
|
|
| 30 |
* @return string
|
| 31 |
*/
|
| 32 |
-
public function generate() {
|
| 33 |
$tplFile = $this->_getVclTemplateFilename( self::VCL_TEMPLATE_FILE );
|
| 34 |
$vcl = $this->_formatTemplate( file_get_contents( $tplFile ),
|
| 35 |
$this->_getTemplateVars() );
|
| 36 |
-
return $this->_cleanVcl( $vcl );
|
| 37 |
}
|
| 38 |
|
| 39 |
protected function _getAdvancedSessionValidation() {
|
| 27 |
/**
|
| 28 |
* Generate the Varnish 3.0-compatible VCL
|
| 29 |
*
|
| 30 |
+
* @param bool $doClean if true, VCL will be cleaned (whitespaces stripped, etc.)
|
| 31 |
* @return string
|
| 32 |
*/
|
| 33 |
+
public function generate($doClean=true) {
|
| 34 |
$tplFile = $this->_getVclTemplateFilename( self::VCL_TEMPLATE_FILE );
|
| 35 |
$vcl = $this->_formatTemplate( file_get_contents( $tplFile ),
|
| 36 |
$this->_getTemplateVars() );
|
| 37 |
+
return $doClean ? $this->_cleanVcl( $vcl ) : $vcl;
|
| 38 |
}
|
| 39 |
|
| 40 |
protected function _getAdvancedSessionValidation() {
|
app/code/community/Nexcessnet/Turpentine/controllers/EsiController.php
CHANGED
|
@@ -100,10 +100,23 @@ class Nexcessnet_Turpentine_EsiController extends Mage_Core_Controller_Front_Act
|
|
| 100 |
$appShim->shim_setRequest( $dummyRequest );
|
| 101 |
$block = $this->_getEsiBlock( $esiData );
|
| 102 |
if( $block ) {
|
|
|
|
| 103 |
$block->setEsiOptions( false );
|
| 104 |
$resp->setBody( $block->toHtml() );
|
| 105 |
if( (int)$req->getParam( $esiHelper->getEsiTtlParam() ) > 0 ) {
|
| 106 |
$cacheFlag = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
}
|
| 108 |
if( $esiData->getEsiMethod() == 'ajax' ) {
|
| 109 |
$resp->setHeader( 'Access-Control-Allow-Origin',
|
|
@@ -149,7 +162,7 @@ class Nexcessnet_Turpentine_EsiController extends Mage_Core_Controller_Front_Act
|
|
| 149 |
* Generate the ESI block
|
| 150 |
*
|
| 151 |
* @param Varien_Object $esiData
|
| 152 |
-
* @return Mage_Core_Block_Template
|
| 153 |
*/
|
| 154 |
protected function _getEsiBlock( $esiData ) {
|
| 155 |
$block = null;
|
|
@@ -173,34 +186,86 @@ class Nexcessnet_Turpentine_EsiController extends Mage_Core_Controller_Front_Act
|
|
| 173 |
Mage::getSingleton( 'core/design_package' )
|
| 174 |
->setPackageName( $esiData->getDesignPackage() )
|
| 175 |
->setTheme( $esiData->getDesignTheme() );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
$layoutUpdate = $layout->getUpdate();
|
| 177 |
$layoutUpdate->load( $this->_swapCustomerHandles(
|
| 178 |
$esiData->getLayoutHandles() ) );
|
| 179 |
foreach( $esiData->getDummyBlocks() as $blockName ) {
|
| 180 |
$layout->createBlock( 'Mage_Core_Block_Template', $blockName );
|
| 181 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
$layout->generateXml();
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
->
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
}
|
| 197 |
}
|
| 198 |
-
$block = $layout->getBlock( $esiData->getNameInLayout() );
|
| 199 |
-
} else {
|
| 200 |
-
Mage::helper( 'turpentine/debug' )->logWarn(
|
| 201 |
-
'No block node found with @name="%s"',
|
| 202 |
-
$esiData->getNameInLayout() );
|
| 203 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
Varien_Profiler::stop( 'turpentine::controller::esi::_getEsiBlock' );
|
| 205 |
return $block;
|
| 206 |
}
|
| 100 |
$appShim->shim_setRequest( $dummyRequest );
|
| 101 |
$block = $this->_getEsiBlock( $esiData );
|
| 102 |
if( $block ) {
|
| 103 |
+
$blockEsiOptions = $block->getEsiOptions();
|
| 104 |
$block->setEsiOptions( false );
|
| 105 |
$resp->setBody( $block->toHtml() );
|
| 106 |
if( (int)$req->getParam( $esiHelper->getEsiTtlParam() ) > 0 ) {
|
| 107 |
$cacheFlag = true;
|
| 108 |
+
if ( isset( $blockEsiOptions['only_cache_if'] ) ) {
|
| 109 |
+
switch ( $blockEsiOptions['only_cache_if'] ) {
|
| 110 |
+
case 'empty':
|
| 111 |
+
$cacheFlag = ( '' === $resp->getBody() );
|
| 112 |
+
break;
|
| 113 |
+
case 'no_text':
|
| 114 |
+
$cacheFlag = ( '' === trim( strip_tags( $resp->getBody() ) ) );
|
| 115 |
+
break;
|
| 116 |
+
default:
|
| 117 |
+
$cacheFlag = false;
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
}
|
| 121 |
if( $esiData->getEsiMethod() == 'ajax' ) {
|
| 122 |
$resp->setHeader( 'Access-Control-Allow-Origin',
|
| 162 |
* Generate the ESI block
|
| 163 |
*
|
| 164 |
* @param Varien_Object $esiData
|
| 165 |
+
* @return Mage_Core_Block_Template|null
|
| 166 |
*/
|
| 167 |
protected function _getEsiBlock( $esiData ) {
|
| 168 |
$block = null;
|
| 186 |
Mage::getSingleton( 'core/design_package' )
|
| 187 |
->setPackageName( $esiData->getDesignPackage() )
|
| 188 |
->setTheme( $esiData->getDesignTheme() );
|
| 189 |
+
|
| 190 |
+
// dispatch event for adding handles to layout update
|
| 191 |
+
Mage::dispatchEvent(
|
| 192 |
+
'controller_action_layout_load_before',
|
| 193 |
+
array('action'=>$this, 'layout'=>$layout)
|
| 194 |
+
);
|
| 195 |
+
|
| 196 |
$layoutUpdate = $layout->getUpdate();
|
| 197 |
$layoutUpdate->load( $this->_swapCustomerHandles(
|
| 198 |
$esiData->getLayoutHandles() ) );
|
| 199 |
foreach( $esiData->getDummyBlocks() as $blockName ) {
|
| 200 |
$layout->createBlock( 'Mage_Core_Block_Template', $blockName );
|
| 201 |
}
|
| 202 |
+
|
| 203 |
+
if(!$this->getFlag('', self::FLAG_NO_DISPATCH_BLOCK_EVENT)) {
|
| 204 |
+
Mage::dispatchEvent(
|
| 205 |
+
'controller_action_layout_generate_xml_before',
|
| 206 |
+
array('action'=>$this, 'layout'=>$layout)
|
| 207 |
+
);
|
| 208 |
+
}
|
| 209 |
$layout->generateXml();
|
| 210 |
+
|
| 211 |
+
/** @var Nexcessnet_Turpentine_Helper_Data $turpentineHelper */
|
| 212 |
+
$turpentineHelper = Mage::helper( 'turpentine/data' )
|
| 213 |
+
->setLayout( $layout );
|
| 214 |
+
|
| 215 |
+
$blockNode = current( $layout->getNode()->xpath(
|
| 216 |
+
sprintf('//block[@name=\'%s\']',$esiData->getNameInLayout())
|
| 217 |
+
) );
|
| 218 |
+
|
| 219 |
+
if( ! ($blockNode instanceof Mage_Core_Model_Layout_Element) ) {
|
| 220 |
+
Mage::helper( 'turpentine/debug' )->logWarn(
|
| 221 |
+
'No block node found with @name="%s"',
|
| 222 |
+
$esiData->getNameInLayout() );
|
| 223 |
+
return null;
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
$nodesToGenerate = $turpentineHelper->getChildBlockNames( $blockNode );
|
| 227 |
+
Mage::getModel( 'turpentine/shim_mage_core_layout' )
|
| 228 |
+
->shim_generateFullBlock( $blockNode );
|
| 229 |
+
|
| 230 |
+
//find addional blocks that aren't defined in the <block/> but via <reference name="%s">
|
| 231 |
+
$referenceNodes = $layout->getNode()->xpath( sprintf(
|
| 232 |
+
'//reference[@name=\'%s\']',
|
| 233 |
+
$esiData->getNameInLayout() ) );
|
| 234 |
+
if ($referenceNodes) {
|
| 235 |
+
foreach ($referenceNodes as $referenceNode) {
|
| 236 |
+
if ($referenceNode instanceof Mage_Core_Model_Layout_Element) {
|
| 237 |
+
$referencesToGenerate = $turpentineHelper
|
| 238 |
+
->getChildBlockNames( $referenceNode );
|
| 239 |
+
$nodesToGenerate =
|
| 240 |
+
array_merge($nodesToGenerate, $referencesToGenerate);
|
| 241 |
}
|
| 242 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
}
|
| 244 |
+
|
| 245 |
+
// dispatch event for adding xml layout elements
|
| 246 |
+
if(!$this->getFlag('', self::FLAG_NO_DISPATCH_BLOCK_EVENT)) {
|
| 247 |
+
Mage::dispatchEvent(
|
| 248 |
+
'controller_action_layout_generate_blocks_before',
|
| 249 |
+
array('action'=>$this, 'layout'=>$layout)
|
| 250 |
+
);
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
foreach( array_unique($nodesToGenerate) as $nodeName ) {
|
| 254 |
+
foreach( $layout->getNode()->xpath( sprintf(
|
| 255 |
+
'//reference[@name=\'%s\']', $nodeName ) ) as $node ) {
|
| 256 |
+
$layout->generateBlocks( $node );
|
| 257 |
+
}
|
| 258 |
+
}
|
| 259 |
+
$block = $layout->getBlock( $esiData->getNameInLayout() );
|
| 260 |
+
|
| 261 |
+
if(!$this->getFlag('', self::FLAG_NO_DISPATCH_BLOCK_EVENT)) {
|
| 262 |
+
Mage::dispatchEvent(
|
| 263 |
+
'controller_action_layout_generate_blocks_after',
|
| 264 |
+
array('action'=>$this, 'layout'=>$layout)
|
| 265 |
+
);
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
$this->_isLayoutLoaded = true;
|
| 269 |
Varien_Profiler::stop( 'turpentine::controller::esi::_getEsiBlock' );
|
| 270 |
return $block;
|
| 271 |
}
|
app/code/community/Nexcessnet/Turpentine/controllers/Varnish/ManagementController.php
CHANGED
|
@@ -157,7 +157,8 @@ class Nexcessnet_Turpentine_Varnish_ManagementController
|
|
| 157 |
} else {
|
| 158 |
Mage::dispatchEvent( 'turpentine_varnish_save_config',
|
| 159 |
array( 'cfgr' => $cfgr ) );
|
| 160 |
-
$result = $cfgr->save( $cfgr->generate(
|
|
|
|
| 161 |
if( $result[0] ) {
|
| 162 |
$this->_getSession()
|
| 163 |
->addSuccess( Mage::helper('turpentine')
|
|
@@ -183,7 +184,8 @@ class Nexcessnet_Turpentine_Varnish_ManagementController
|
|
| 183 |
$this->_getSession()->addError( $this->__( 'Failed to load configurator' ) );
|
| 184 |
$this->_redirect( '*/cache' );
|
| 185 |
} else {
|
| 186 |
-
$vcl = $cfgr->generate(
|
|
|
|
| 187 |
$this->getResponse()
|
| 188 |
->setHttpResponseCode( 200 )
|
| 189 |
->setHeader( 'Content-Type', 'text/plain', true )
|
| 157 |
} else {
|
| 158 |
Mage::dispatchEvent( 'turpentine_varnish_save_config',
|
| 159 |
array( 'cfgr' => $cfgr ) );
|
| 160 |
+
$result = $cfgr->save( $cfgr->generate(
|
| 161 |
+
Mage::helper('turpentine')->shouldStripVclWhitespace('save') ) );
|
| 162 |
if( $result[0] ) {
|
| 163 |
$this->_getSession()
|
| 164 |
->addSuccess( Mage::helper('turpentine')
|
| 184 |
$this->_getSession()->addError( $this->__( 'Failed to load configurator' ) );
|
| 185 |
$this->_redirect( '*/cache' );
|
| 186 |
} else {
|
| 187 |
+
$vcl = $cfgr->generate(
|
| 188 |
+
Mage::helper( 'turpentine' )->shouldStripVclWhitespace('download') );
|
| 189 |
$this->getResponse()
|
| 190 |
->setHttpResponseCode( 200 )
|
| 191 |
->setHeader( 'Content-Type', 'text/plain', true )
|
app/code/community/Nexcessnet/Turpentine/etc/config.xml
CHANGED
|
@@ -20,13 +20,14 @@
|
|
| 20 |
<config>
|
| 21 |
<modules>
|
| 22 |
<Nexcessnet_Turpentine>
|
| 23 |
-
<version>0.6.
|
| 24 |
</Nexcessnet_Turpentine>
|
| 25 |
</modules>
|
| 26 |
<default>
|
| 27 |
<turpentine_varnish>
|
| 28 |
<general>
|
| 29 |
<auto_apply_on_save>1</auto_apply_on_save>
|
|
|
|
| 30 |
<varnish_debug>0</varnish_debug>
|
| 31 |
<block_debug>0</block_debug>
|
| 32 |
<ajax_messages>1</ajax_messages>
|
| 20 |
<config>
|
| 21 |
<modules>
|
| 22 |
<Nexcessnet_Turpentine>
|
| 23 |
+
<version>0.6.1</version>
|
| 24 |
</Nexcessnet_Turpentine>
|
| 25 |
</modules>
|
| 26 |
<default>
|
| 27 |
<turpentine_varnish>
|
| 28 |
<general>
|
| 29 |
<auto_apply_on_save>1</auto_apply_on_save>
|
| 30 |
+
<strip_vcl_whitespace>always</strip_vcl_whitespace>
|
| 31 |
<varnish_debug>0</varnish_debug>
|
| 32 |
<block_debug>0</block_debug>
|
| 33 |
<ajax_messages>1</ajax_messages>
|
app/code/community/Nexcessnet/Turpentine/etc/system.xml
CHANGED
|
@@ -52,6 +52,16 @@
|
|
| 52 |
<show_in_website>0</show_in_website>
|
| 53 |
<show_in_store>0</show_in_store>
|
| 54 |
</auto_apply_on_save>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
<varnish_debug translate="label" module="turpentine">
|
| 56 |
<label>Enable Debug Info</label>
|
| 57 |
<comment>It is a major security vulnerability, to leave this enabled on production sites</comment>
|
|
@@ -84,7 +94,7 @@
|
|
| 84 |
</ajax_messages>
|
| 85 |
<fix_product_toolbar translate="label" module="turpentine">
|
| 86 |
<label>Fix Product List Toolbar</label>
|
| 87 |
-
<comment>Enable this to prevent caching the
|
| 88 |
<frontend_type>select</frontend_type>
|
| 89 |
<source_model>turpentine/config_select_toggle</source_model>
|
| 90 |
<sort_order>65</sort_order>
|
| 52 |
<show_in_website>0</show_in_website>
|
| 53 |
<show_in_store>0</show_in_store>
|
| 54 |
</auto_apply_on_save>
|
| 55 |
+
<strip_vcl_whitespace translate="label,comment" module="turpentine">
|
| 56 |
+
<label>Strip whitespace from VCL files</label>
|
| 57 |
+
<comment>If whitespace stripping is disabled, generated VCL files will get larger and may exceed the cli_buffer varnish config.</comment>
|
| 58 |
+
<frontend_type>select</frontend_type>
|
| 59 |
+
<source_model>turpentine/config_select_stripWhitespace</source_model>
|
| 60 |
+
<sort_order>25</sort_order>
|
| 61 |
+
<show_in_default>1</show_in_default>
|
| 62 |
+
<show_in_website>0</show_in_website>
|
| 63 |
+
<show_in_store>0</show_in_store>
|
| 64 |
+
</strip_vcl_whitespace>
|
| 65 |
<varnish_debug translate="label" module="turpentine">
|
| 66 |
<label>Enable Debug Info</label>
|
| 67 |
<comment>It is a major security vulnerability, to leave this enabled on production sites</comment>
|
| 94 |
</ajax_messages>
|
| 95 |
<fix_product_toolbar translate="label" module="turpentine">
|
| 96 |
<label>Fix Product List Toolbar</label>
|
| 97 |
+
<comment>Enable this to prevent caching the visitor's view preferences of the product list</comment>
|
| 98 |
<frontend_type>select</frontend_type>
|
| 99 |
<source_model>turpentine/config_select_toggle</source_model>
|
| 100 |
<sort_order>65</sort_order>
|
app/code/community/Nexcessnet/Turpentine/misc/version-2.vcl
CHANGED
|
@@ -20,7 +20,7 @@
|
|
| 20 |
## Custom C Code
|
| 21 |
|
| 22 |
C{
|
| 23 |
-
|
| 24 |
{{custom_c_code}}
|
| 25 |
}C
|
| 26 |
|
| 20 |
## Custom C Code
|
| 21 |
|
| 22 |
C{
|
| 23 |
+
// @source app/code/community/Nexcessnet/Turpentine/misc/uuid.c
|
| 24 |
{{custom_c_code}}
|
| 25 |
}C
|
| 26 |
|
app/code/community/Nexcessnet/Turpentine/misc/version-3.vcl
CHANGED
|
@@ -20,7 +20,7 @@
|
|
| 20 |
## Custom C Code
|
| 21 |
|
| 22 |
C{
|
| 23 |
-
|
| 24 |
{{custom_c_code}}
|
| 25 |
}C
|
| 26 |
|
| 20 |
## Custom C Code
|
| 21 |
|
| 22 |
C{
|
| 23 |
+
// @source app/code/community/Nexcessnet/Turpentine/misc/uuid.c
|
| 24 |
{{custom_c_code}}
|
| 25 |
}C
|
| 26 |
|
app/design/frontend/base/default/layout/turpentine_esi.xml
CHANGED
|
@@ -102,19 +102,14 @@
|
|
| 102 |
</params>
|
| 103 |
</action>
|
| 104 |
</reference>
|
| 105 |
-
|
| 106 |
-
<!-- Messages are not cached because the "messages cleared" event is
|
| 107 |
-
not reliable -->
|
| 108 |
<reference name="global_messages">
|
| 109 |
<action method="setEsiOptions">
|
| 110 |
<params>
|
| 111 |
<access>private</access>
|
| 112 |
-
<method>ajax</method>
|
| 113 |
-
<!-- if this is ever cached we should flush on this event
|
| 114 |
<flush_events>
|
| 115 |
<core_session_abstract_add_message/>
|
| 116 |
</flush_events>
|
| 117 |
-
|
| 118 |
</params>
|
| 119 |
</action>
|
| 120 |
</reference>
|
|
@@ -122,12 +117,10 @@
|
|
| 122 |
<action method="setEsiOptions">
|
| 123 |
<params>
|
| 124 |
<access>private</access>
|
| 125 |
-
<method>ajax</method>
|
| 126 |
-
<!-- if this is ever cached we should flush on this event
|
| 127 |
<flush_events>
|
| 128 |
<core_session_abstract_add_message/>
|
| 129 |
</flush_events>
|
| 130 |
-
|
| 131 |
</params>
|
| 132 |
</action>
|
| 133 |
</reference>
|
| 102 |
</params>
|
| 103 |
</action>
|
| 104 |
</reference>
|
|
|
|
|
|
|
|
|
|
| 105 |
<reference name="global_messages">
|
| 106 |
<action method="setEsiOptions">
|
| 107 |
<params>
|
| 108 |
<access>private</access>
|
|
|
|
|
|
|
| 109 |
<flush_events>
|
| 110 |
<core_session_abstract_add_message/>
|
| 111 |
</flush_events>
|
| 112 |
+
<only_cache_if>no_text</only_cache_if>
|
| 113 |
</params>
|
| 114 |
</action>
|
| 115 |
</reference>
|
| 117 |
<action method="setEsiOptions">
|
| 118 |
<params>
|
| 119 |
<access>private</access>
|
|
|
|
|
|
|
| 120 |
<flush_events>
|
| 121 |
<core_session_abstract_add_message/>
|
| 122 |
</flush_events>
|
| 123 |
+
<only_cache_if>no_text</only_cache_if>
|
| 124 |
</params>
|
| 125 |
</action>
|
| 126 |
</reference>
|
package.xml
CHANGED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
<?xml version='1.0' encoding='utf-8'?>
|
| 2 |
-
<package><name>Nexcessnet_Turpentine</name><license uri="http://opensource.org/licenses/GPL-2.0">GPLv2</license><notes>Supports Magento v1.6 and later</notes><time>
|
| 1 |
<?xml version='1.0' encoding='utf-8'?>
|
| 2 |
+
<package><name>Nexcessnet_Turpentine</name><license uri="http://opensource.org/licenses/GPL-2.0">GPLv2</license><notes>Supports Magento v1.6 and later</notes><time>12:52:16</time><__packager>build_package.py v0.0.3</__packager><summary>Improves Magento support for Varnish caching and generates 2.1 and 3.0 compatible VCLs.</summary><stability>stable</stability><__commit_hash>0a4d2675add584670af235ed2f30418a243cadde</__commit_hash><version>0.6.1</version><extends /><contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file hash="a0bd4a5632b369b058c0ec5262e0cc49" name="turpentine.xml" /></dir><dir name="template"><dir name="turpentine"><file hash="8bd4e7e4540ed816721907cb0ac03a02" name="varnish_management.phtml" /></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file hash="a587e1860ad07546bc7b1459240d3223" name="turpentine_esi.xml" /></dir><dir name="template"><dir name="turpentine"><file hash="b268c48251ccfccf5c775d3e85513584" name="esi.phtml" /><file hash="50798888953fd1550e4347c39e395d0a" name="notices.phtml" /><file hash="252356c9ea115fca63e52d54f67d755f" name="ajax.phtml" /></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file hash="58848d4d90973bfd63b466ea181352a5" name="Nexcessnet_Turpentine.xml" /></dir></target><target name="magecommunity"><dir name="Nexcessnet"><dir name="Turpentine"><dir name="controllers"><file hash="d68418bab75e0b308aeb0fda34bca2cd" name="EsiController.php" /><dir name="Varnish"><file hash="625118bfe342139b7fd9464c05d1b0a6" name="ManagementController.php" /></dir></dir><dir name="Helper"><file hash="2d7286c589b7a3e2f8fe873bd12afe3c" name="Debug.php" /><file hash="802e269b0c80131efbb070309fdc610f" name="Varnish.php" /><file hash="a31045d661a62dac444f82e44ed4f139" name="Esi.php" /><file hash="6a51baf37c84a11f877d432ac47a6f5f" name="Data.php" /><file hash="913d0762f9df7696f1217f82791f1b78" name="Cron.php" /><file hash="6b637be4eac4c924fc1f02b2d49699c3" name="Ban.php" /></dir><dir name="Model"><file hash="c2cb79001524617febbfddf099d09f37" name="Session.php" /><dir name="Observer"><file hash="9d57fad69ff42b71c66ca26bc3372317" name="Debug.php" /><file hash="7244a8ce600e980d612409595b9b6b9b" name="Varnish.php" /><file hash="f2fd1a9d421b5152dd88b8736ba9c58d" name="Esi.php" /><file hash="a34e79218e8ca1fefad303b9399bda9d" name="Cron.php" /><file hash="704cf901bd456b51c263becd0f260d64" name="Ban.php" /></dir><dir name="Dummy"><file hash="2fc1189ace2d0e7383041d16a31df16b" name="Request.php" /></dir><dir name="Config"><dir name="Select"><file hash="9348c5e58037fd97d89b84ccab4ef2d0" name="Toggle.php" /><file hash="dc472f34c25b1688cfa9fa206958c536" name="Version.php" /><file hash="2e01b14592189b3f6a8a05be5ef4c69c" name="StripWhitespace.php" /></dir></dir><dir name="PageCache"><dir name="Container"><file hash="139e8a9bfa209316036e798fff654a8a" name="Notices.php" /></dir></dir><dir name="Varnish"><file hash="f2dcb48cb4f60b8112a82b308ec7ec8b" name="Admin.php" /><dir name="Configurator"><file hash="82d0abe0123272e59e6c319dfdd4e9dc" name="Version3.php" /><file hash="b831b872fcb05d9c723149159db0eed1" name="Version2.php" /><file hash="e4a7a543cf31934f339d2ca139a42ccc" name="Abstract.php" /></dir><dir name="Admin"><file hash="c3d44d59ece358553d2cfa8f92964d39" name="Socket.php" /></dir></dir><dir name="Shim"><dir name="Mage"><dir name="Core"><file hash="821bff6c2fb372e3ffb39abf6453b3f8" name="Layout.php" /><file hash="4a1aa246373520936f0e4b5b3a3baf25" name="App.php" /><file hash="9e5d87f0aa84c9fb1541db83aba69abd" name="Config.php" /></dir></dir></dir></dir><dir name="etc"><file hash="747adeecb56525d9cc9e530ee37b85fb" name="config.xml" /><file hash="610f28a7533a5ea999ea8795874f9086" name="system.xml" /><file hash="3b608fbcca3d307833d10604dff23966" name="cache.xml" /></dir><dir name="misc"><file hash="ba5d5c7263cd90eea3785953e3549041" name="uuid.c" /><file hash="6aea8f5efa5f82dffb864c5df0cb252c" name="version-2.vcl" /><file hash="17048d1cf4967eec32e8a4a768288151" name="version-3.vcl" /></dir><dir name="Block"><file hash="e9b03d651a8da9b1d32c4fd2f4781792" name="Management.php" /><file hash="390cf75d04b1b098cad562229b649c2d" name="Notices.php" /><dir name="Core"><file hash="e7e7b84449ae8d16f0952f5258a9615e" name="Messages.php" /></dir><dir name="Catalog"><dir name="Product"><dir name="List"><file hash="ce9fca4c273987759f284fe31c1597f5" name="Toolbar.php" /></dir></dir></dir></dir><dir name="sql" /></dir></dir></target><target name="magelocal"><dir name="Mage"><dir name="Core"><dir name="Model"><file hash="4d51274ab710e722706ce78b32944fd4" name="Session.php" /></dir></dir></dir></target></contents><dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies><authors><author><name>Chris Wells</name><user>nexcess_net</user><email>clwells@nexcess.net</email></author><author><name>Alex Headley</name><user>aheadley_nex</user><email>aheadley@nexcess.net</email></author></authors><date>2014-10-01</date><compatibile /><channel>community</channel><description>Turpentine is a Magento extension to improve Magento's compatibility with Varnish, a very-fast caching reverse-proxy. By default, Varnish doesn't cache requests with cookies and Magento sends the frontend cookie with every request causing a (near) zero hit-rate for Varnish's cache. Turpentine provides Varnish configuration files (VCLs) to work with Magento and modifies Magento's behaviour to significantly improve the cache hit rate.</description></package>
|
