Nexcessnet_Turpentine - Version 0.7.2

Version Notes

Supports Magento v1.6 and later

Download this release

Release Info

Developer Chris Wells
Extension Nexcessnet_Turpentine
Version 0.7.2
Comparing to
See all releases


Code changes from version 0.7.10 to 0.7.2

app/code/community/Nexcessnet/Turpentine/Block/Poll/ActivePoll.php CHANGED
@@ -21,19 +21,19 @@
21
 
22
  class Nexcessnet_Turpentine_Block_Poll_ActivePoll extends Mage_Poll_Block_ActivePoll {
23
 
24
- public function setTemplate($template)
25
- {
26
- if ((Mage::getConfig()->getModuleConfig('Mage_Poll')->is('active', 'true')) &&
27
- (!Mage::getStoreConfig('advanced/modules_disable_output/Mage_Poll')))
28
- {
29
- $this->_template = $template;
30
- $this->setPollTemplate('turpentine/ajax.phtml', 'poll');
31
- $this->setPollTemplate('turpentine/ajax.phtml', 'results');
32
- }
33
- else
34
- {
35
- // Mage_Poll is disabled, so do nothing
36
- }
37
- return $this;
38
- }
39
  }
21
 
22
  class Nexcessnet_Turpentine_Block_Poll_ActivePoll extends Mage_Poll_Block_ActivePoll {
23
 
24
+ public function setTemplate($template)
25
+ {
26
+ if ((Mage::getConfig()->getModuleConfig('Mage_Poll')->is('active', 'true')) &&
27
+ (!Mage::getStoreConfig('advanced/modules_disable_output/Mage_Poll')))
28
+ {
29
+ $this->_template = $template;
30
+ $this->setPollTemplate('turpentine/ajax.phtml', 'poll');
31
+ $this->setPollTemplate('turpentine/ajax.phtml', 'results');
32
+ }
33
+ else
34
+ {
35
+ // Mage_Poll is disabled, so do nothing
36
+ }
37
+ return $this;
38
+ }
39
  }
app/code/community/Nexcessnet/Turpentine/Helper/Esi.php CHANGED
@@ -362,6 +362,32 @@ class Nexcessnet_Turpentine_Helper_Esi extends Mage_Core_Helper_Abstract {
362
  return $esiUrl;
363
  }
364
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
  /**
366
  * Load the ESI cache clear events from the layout
367
  *
362
  return $esiUrl;
363
  }
364
 
365
+ /**
366
+ * Grab a block node by name from the layout XML.
367
+ *
368
+ * Multiple blocks with the same name may exist in the layout, because some themes
369
+ * use 'unsetChild' to remove a block and create it with the same name somewhere
370
+ * else. For example Ultimo does this.
371
+ *
372
+ * @param Mage_Core_Model_Layout $layout
373
+ * @param string $blockName value of name= attribute in layout XML
374
+ * @return Mage_Core_Model_Layout_Element
375
+ */
376
+ public function getEsiLayoutBlockNode($layout, $blockName) {
377
+ // first try very specific by checking for action setEsiOptions inside block
378
+ $blockNode = current($layout->getNode()->xpath(
379
+ sprintf('//block[@name=\'%s\'][action[@method=\'setEsiOptions\']]',
380
+ $blockName)
381
+ ));
382
+ // fallback: only match name
383
+ if ( ! ($blockNode instanceof Mage_Core_Model_Layout_Element)) {
384
+ $blockNode = current($layout->getNode()->xpath(
385
+ sprintf('//block[@name=\'%s\']', $blockName)
386
+ ));
387
+ }
388
+ return $blockNode;
389
+ }
390
+
391
  /**
392
  * Load the ESI cache clear events from the layout
393
  *
app/code/community/Nexcessnet/Turpentine/Model/Config/Select/Version.php CHANGED
@@ -26,6 +26,7 @@ class Nexcessnet_Turpentine_Model_Config_Select_Version {
26
  array('value' => '2.1', 'label' => $helper->__('2.1.x')),
27
  array('value' => '3.0', 'label' => $helper->__('3.0.x')),
28
  array('value' => '4.0', 'label' => $helper->__('4.0.x')),
 
29
  array('value' => 'auto', 'label' => $helper->__('Auto')),
30
  );
31
  }
26
  array('value' => '2.1', 'label' => $helper->__('2.1.x')),
27
  array('value' => '3.0', 'label' => $helper->__('3.0.x')),
28
  array('value' => '4.0', 'label' => $helper->__('4.0.x')),
29
+ array('value' => '4.1', 'label' => $helper->__('4.1.x')),
30
  array('value' => 'auto', 'label' => $helper->__('Auto')),
31
  );
32
  }
app/code/community/Nexcessnet/Turpentine/Model/Core/Session.php CHANGED
@@ -56,7 +56,7 @@ class Nexcessnet_Turpentine_Model_Core_Session extends Mage_Core_Model_Session
56
  */
57
  public function renewFormKey()
58
  {
59
- $this->setData('_form_key', Mage::helper('core')->getRandomString(16));
60
  }
61
 
62
  /**
56
  */
57
  public function renewFormKey()
58
  {
59
+ $this->setData('_form_key', Mage::helper('core')->getRandomString(16));
60
  }
61
 
62
  /**
app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php CHANGED
@@ -227,9 +227,9 @@ class Nexcessnet_Turpentine_Model_Observer_Esi extends Varien_Event_Observer {
227
  'Checking ESI block candidate: %s',
228
  $blockObject->getNameInLayout() ? $blockObject->getNameInLayout() : $blockObject->getModuleName() );
229
 
230
- $debugHelper->logInfo( "-- block testing: shouldResponseUseEsi = " . $esiHelper->shouldResponseUseEsi());
231
- $debugHelper->logInfo( "-- block testing: instanceof Mage_Core_Block_Template = " . $blockObject instanceof Mage_Core_Block_Template );
232
- $debugHelper->logInfo( "-- block testing: Esi Options = " . print_r($blockObject->getEsiOptions(), true) );
233
  }
234
  if ($esiHelper->shouldResponseUseEsi() &&
235
  $blockObject instanceof Mage_Core_Block_Template &&
@@ -297,6 +297,11 @@ class Nexcessnet_Turpentine_Model_Observer_Esi extends Varien_Event_Observer {
297
  );
298
  }
299
 
 
 
 
 
 
300
  $esiUrl = Mage::getUrl('turpentine/esi/getBlock', $urlOptions);
301
  if ($esiOptions[$methodParam] == 'esi') {
302
  // setting [web/unsecure/base_url] can be https://... but ESI can never be HTTPS
@@ -332,8 +337,8 @@ class Nexcessnet_Turpentine_Model_Observer_Esi extends Varien_Event_Observer {
332
  $methodParam = $esiHelper->getEsiMethodParam();
333
  $esiData = new Varien_Object();
334
  $esiData->setStoreId(Mage::app()->getStore()->getId());
335
- $esiData->setDesignPackage( Mage::getDesign()->getPackageName() );
336
- $esiData->setDesignTheme( Mage::getDesign()->getTheme( 'layout' ) );
337
  $esiData->setNameInLayout($blockObject->getNameInLayout());
338
  $esiData->setBlockType(get_class($blockObject));
339
  $esiData->setLayoutHandles($this->_getBlockLayoutHandles($blockObject));
@@ -415,9 +420,8 @@ class Nexcessnet_Turpentine_Model_Observer_Esi extends Varien_Event_Observer {
415
  $activeHandles = array();
416
  // get the xml node representing the block we're working on (from the
417
  // default handle probably)
418
- $blockNode = current($layout->getNode()->xpath(sprintf(
419
- '//block[@name=\'%s\']',
420
- $block->getNameInLayout() )));
421
  $childBlocks = Mage::helper('turpentine/data')
422
  ->getChildBlockNames($blockNode);
423
  foreach ($childBlocks as $blockName) {
227
  'Checking ESI block candidate: %s',
228
  $blockObject->getNameInLayout() ? $blockObject->getNameInLayout() : $blockObject->getModuleName() );
229
 
230
+ $debugHelper->logInfo("-- block testing: shouldResponseUseEsi = ".$esiHelper->shouldResponseUseEsi());
231
+ $debugHelper->logInfo("-- block testing: instanceof Mage_Core_Block_Template = ".$blockObject instanceof Mage_Core_Block_Template);
232
+ $debugHelper->logInfo("-- block testing: Esi Options = ".print_r($blockObject->getEsiOptions(), true));
233
  }
234
  if ($esiHelper->shouldResponseUseEsi() &&
235
  $blockObject instanceof Mage_Core_Block_Template &&
297
  );
298
  }
299
 
300
+ /**
301
+ * Keep params from original url
302
+ */
303
+ $urlOptions['_query'] = Mage::app()->getRequest()->getParams();
304
+
305
  $esiUrl = Mage::getUrl('turpentine/esi/getBlock', $urlOptions);
306
  if ($esiOptions[$methodParam] == 'esi') {
307
  // setting [web/unsecure/base_url] can be https://... but ESI can never be HTTPS
337
  $methodParam = $esiHelper->getEsiMethodParam();
338
  $esiData = new Varien_Object();
339
  $esiData->setStoreId(Mage::app()->getStore()->getId());
340
+ $esiData->setDesignPackage(Mage::getDesign()->getPackageName());
341
+ $esiData->setDesignTheme(Mage::getDesign()->getTheme('layout'));
342
  $esiData->setNameInLayout($blockObject->getNameInLayout());
343
  $esiData->setBlockType(get_class($blockObject));
344
  $esiData->setLayoutHandles($this->_getBlockLayoutHandles($blockObject));
420
  $activeHandles = array();
421
  // get the xml node representing the block we're working on (from the
422
  // default handle probably)
423
+ $blockNode = Mage::helper('turpentine/esi')->getEsiLayoutBlockNode(
424
+ $layout, $block->getNameInLayout());
 
425
  $childBlocks = Mage::helper('turpentine/data')
426
  ->getChildBlockNames($blockNode);
427
  foreach ($childBlocks as $blockName) {
app/code/community/Nexcessnet/Turpentine/Model/Observer/Varnish.php CHANGED
@@ -65,7 +65,8 @@ class Nexcessnet_Turpentine_Model_Observer_Varnish extends Varien_Event_Observer
65
  */
66
  public function fixCmRedisSessionLocks($eventObject) {
67
  if (Mage::helper('core')->isModuleEnabled('Cm_RedisSession')) {
68
- if ( ! empty($_COOKIE['frontend']) && 'crawler-session' == $_COOKIE['frontend']) {
 
69
  define('CM_REDISSESSION_LOCKING_ENABLED', false);
70
  }
71
  }
65
  */
66
  public function fixCmRedisSessionLocks($eventObject) {
67
  if (Mage::helper('core')->isModuleEnabled('Cm_RedisSession')) {
68
+ if ( ! empty($_COOKIE['frontend']) && 'crawler-session' == $_COOKIE['frontend'] &&
69
+ ! defined('CM_REDISSESSION_LOCKING_ENABLED')) {
70
  define('CM_REDISSESSION_LOCKING_ENABLED', false);
71
  }
72
  }
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin.php CHANGED
@@ -138,7 +138,7 @@ class Nexcessnet_Turpentine_Model_Varnish_Admin {
138
  $result = false;
139
 
140
  if ($helper->csrfFixupNeeded()) {
141
- if ($socket->getVersion() === '4.0') {
142
  $paramName = 'feature';
143
  $value = $socket->param_show($paramName);
144
  $value = explode("\n", $value['text']);
138
  $result = false;
139
 
140
  if ($helper->csrfFixupNeeded()) {
141
+ if ($socket->getVersion() === '4.0' || $socket->getVersion() === '4.1') {
142
  $paramName = 'feature';
143
  $value = $socket->param_show($paramName);
144
  $value = explode("\n", $value['text']);
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Admin/Socket.php CHANGED
@@ -82,7 +82,7 @@ class Nexcessnet_Turpentine_Model_Varnish_Admin_Socket {
82
  // varnish default, can only be changed at Varnish startup time
83
  // if data to write is over this limit the actual run-time limit is checked
84
  // and used
85
- const CLI_CMD_LENGTH_LIMIT = 8192;
86
 
87
  /**
88
  * Regexp to detect the varnish version number
@@ -93,7 +93,7 @@ class Nexcessnet_Turpentine_Model_Varnish_Admin_Socket {
93
  /**
94
  * VCL config versions, should match config select values
95
  */
96
- static protected $_VERSIONS = array('2.1', '3.0', '4.0');
97
 
98
  /**
99
  * Varnish socket connection
@@ -405,7 +405,7 @@ class Nexcessnet_Turpentine_Model_Varnish_Admin_Socket {
405
  if ($dataLength >= self::CLI_CMD_LENGTH_LIMIT) {
406
  $cliBufferResponse = $this->param_show('cli_buffer');
407
  $regexp = '~^cli_buffer\s+(\d+)\s+\[bytes\]~';
408
- if ($this->getVersion() === '4.0') {
409
  // Varnish4 supports "16k" style notation
410
  $regexp = '~^cli_buffer\s+Value is:\s+(\d+)([k|m|g|b]{1})?\s+\[bytes\]~';
411
  }
@@ -500,7 +500,7 @@ class Nexcessnet_Turpentine_Model_Varnish_Admin_Socket {
500
  $response['code'], $response['text'] ));
501
  } else {
502
  if (Mage::getStoreConfig('turpentine_varnish/general/varnish_log_commands')) {
503
- Mage::helper('turpentine/debug')->logDebug('VARNISH command sent: ' . $data);
504
  }
505
  return $response;
506
  }
@@ -518,6 +518,7 @@ class Nexcessnet_Turpentine_Model_Varnish_Admin_Socket {
518
  case '2.1':
519
  $command = str_replace('ban', 'purge', $command);
520
  break;
 
521
  case '4.0':
522
  case '3.0':
523
  $command = str_replace('purge', 'ban', $command);
82
  // varnish default, can only be changed at Varnish startup time
83
  // if data to write is over this limit the actual run-time limit is checked
84
  // and used
85
+ const CLI_CMD_LENGTH_LIMIT = 16384;
86
 
87
  /**
88
  * Regexp to detect the varnish version number
93
  /**
94
  * VCL config versions, should match config select values
95
  */
96
+ static protected $_VERSIONS = array('2.1', '3.0', '4.0', '4.1');
97
 
98
  /**
99
  * Varnish socket connection
405
  if ($dataLength >= self::CLI_CMD_LENGTH_LIMIT) {
406
  $cliBufferResponse = $this->param_show('cli_buffer');
407
  $regexp = '~^cli_buffer\s+(\d+)\s+\[bytes\]~';
408
+ if ($this->getVersion() === '4.0' || $this->getVersion() === '4.1') {
409
  // Varnish4 supports "16k" style notation
410
  $regexp = '~^cli_buffer\s+Value is:\s+(\d+)([k|m|g|b]{1})?\s+\[bytes\]~';
411
  }
500
  $response['code'], $response['text'] ));
501
  } else {
502
  if (Mage::getStoreConfig('turpentine_varnish/general/varnish_log_commands')) {
503
+ Mage::helper('turpentine/debug')->logDebug('VARNISH command sent: '.$data);
504
  }
505
  return $response;
506
  }
518
  case '2.1':
519
  $command = str_replace('ban', 'purge', $command);
520
  break;
521
+ case '4.1':
522
  case '4.0':
523
  case '3.0':
524
  $command = str_replace('purge', 'ban', $command);
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Abstract.php CHANGED
@@ -40,6 +40,7 @@ abstract class Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract {
40
  }
41
  switch ($version) {
42
  case '4.0':
 
43
  return Mage::getModel(
44
  'turpentine/varnish_configurator_version4',
45
  array('socket' => $socket) );
@@ -110,8 +111,8 @@ abstract class Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract {
110
  * @return string
111
  */
112
  protected function _getVclTemplateFilename($baseFilename) {
113
- $extensionDir = Mage::getModuleDir('', 'Nexcessnet_Turpentine');
114
- return sprintf('%s/misc/%s', $extensionDir, $baseFilename);
115
  }
116
 
117
  /**
@@ -130,7 +131,7 @@ abstract class Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract {
130
  *
131
  * @return string
132
  */
133
- protected function _getCustomIncludeFilename($position='') {
134
  $key = 'custom_include_file';
135
  $key .= ($position) ? '_'.$position : '';
136
  return $this->_formatTemplate(
@@ -150,8 +151,7 @@ abstract class Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract {
150
  Mage::getStoreConfig('turpentine_varnish/servers/custom_vcl_template'),
151
  array('root_dir' => Mage::getBaseDir())
152
  );
153
- if (is_file($filePath)) { return $filePath; }
154
- else { return null; }
155
  }
156
 
157
 
@@ -192,8 +192,8 @@ abstract class Nexcessnet_Turpentine_Model_Varnish_Configurator_Abstract {
192
  */
193
  protected function _getAdminFrontname() {
194
  if (Mage::getStoreConfig('admin/url/use_custom_path')) {
195
- if(Mage::getStoreConfig('web/url/use_store')) {
196
- return Mage::getModel('core/store')->load(0)->getCode() . "/" . Mage::getStoreConfig('admin/url/custom_path');
197
  } else {
198
  return Mage::getStoreConfig('admin/url/custom_path');
199
  }
@@ -868,6 +868,7 @@ EOS;
868
 
869
  switch (Mage::getStoreConfig('turpentine_varnish/servers/version')) {
870
  case 4.0:
 
871
  $tpl = <<<EOS
872
  if (req.http.X-Forwarded-For) {
873
  if (req.http.X-Forwarded-For !~ "{{debug_ips}}") {
@@ -907,11 +908,12 @@ EOS;
907
  */
908
  protected function _vcl_sub_https_redirect_fix() {
909
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
910
- $baseUrl = str_replace(array('http://','https://'), '', $baseUrl);
911
- $baseUrl = rtrim($baseUrl,'/');
912
 
913
  switch (Mage::getStoreConfig('turpentine_varnish/servers/version')) {
914
  case 4.0:
 
915
  $tpl = <<<EOS
916
  if ( (req.http.host ~ "^(?i)www.$baseUrl" || req.http.host ~ "^(?i)$baseUrl") && req.http.X-Forwarded-Proto !~ "(?i)https") {
917
  return (synth(750, ""));
@@ -942,6 +944,7 @@ EOS;
942
 
943
  switch (Mage::getStoreConfig('turpentine_varnish/servers/version')) {
944
  case 4.0:
 
945
  $tpl = <<<EOS
946
  sub vcl_synth {
947
  if (resp.status == 999) {
@@ -978,7 +981,7 @@ EOS;
978
  {
979
  $tpl = $this->_vcl_sub_synth();
980
 
981
- if(!$tpl){
982
  $tpl = <<<EOS
983
  sub vcl_synth {
984
  if (resp.status == 750) {
@@ -988,7 +991,7 @@ sub vcl_synth {
988
  }
989
  }
990
  EOS;
991
- }else{
992
  $tpl_750 = '
993
  sub vcl_synth {
994
  if (resp.status == 750) {
@@ -1085,12 +1088,12 @@ sub vcl_synth {
1085
 
1086
  if (Mage::getStoreConfig('turpentine_varnish/general/https_redirect_fix')) {
1087
  $vars['https_redirect'] = $this->_vcl_sub_https_redirect_fix();
1088
- if(Mage::getStoreConfig('turpentine_varnish/servers/version') == '4.0'){
1089
  $vars['vcl_synth'] = $this->_vcl_sub_synth_https_fix();
1090
  }
1091
  }
1092
 
1093
- foreach (array('','top') as $position) {
1094
  $customIncludeFile = $this->_getCustomIncludeFilename($position);
1095
  if (is_readable($customIncludeFile)) {
1096
  $key = 'custom_vcl_include';
40
  }
41
  switch ($version) {
42
  case '4.0':
43
+ case '4.1':
44
  return Mage::getModel(
45
  'turpentine/varnish_configurator_version4',
46
  array('socket' => $socket) );
111
  * @return string
112
  */
113
  protected function _getVclTemplateFilename($baseFilename) {
114
+ $extensionDir = Mage::getModuleDir('', 'Nexcessnet_Turpentine');
115
+ return sprintf('%s/misc/%s', $extensionDir, $baseFilename);
116
  }
117
 
118
  /**
131
  *
132
  * @return string
133
  */
134
+ protected function _getCustomIncludeFilename($position = '') {
135
  $key = 'custom_include_file';
136
  $key .= ($position) ? '_'.$position : '';
137
  return $this->_formatTemplate(
151
  Mage::getStoreConfig('turpentine_varnish/servers/custom_vcl_template'),
152
  array('root_dir' => Mage::getBaseDir())
153
  );
154
+ if (is_file($filePath)) { return $filePath; } else { return null; }
 
155
  }
156
 
157
 
192
  */
193
  protected function _getAdminFrontname() {
194
  if (Mage::getStoreConfig('admin/url/use_custom_path')) {
195
+ if (Mage::getStoreConfig('web/url/use_store')) {
196
+ return Mage::getModel('core/store')->load(0)->getCode()."/".Mage::getStoreConfig('admin/url/custom_path');
197
  } else {
198
  return Mage::getStoreConfig('admin/url/custom_path');
199
  }
868
 
869
  switch (Mage::getStoreConfig('turpentine_varnish/servers/version')) {
870
  case 4.0:
871
+ case 4.1:
872
  $tpl = <<<EOS
873
  if (req.http.X-Forwarded-For) {
874
  if (req.http.X-Forwarded-For !~ "{{debug_ips}}") {
908
  */
909
  protected function _vcl_sub_https_redirect_fix() {
910
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
911
+ $baseUrl = str_replace(array('http://', 'https://'), '', $baseUrl);
912
+ $baseUrl = rtrim($baseUrl, '/');
913
 
914
  switch (Mage::getStoreConfig('turpentine_varnish/servers/version')) {
915
  case 4.0:
916
+ case 4.1:
917
  $tpl = <<<EOS
918
  if ( (req.http.host ~ "^(?i)www.$baseUrl" || req.http.host ~ "^(?i)$baseUrl") && req.http.X-Forwarded-Proto !~ "(?i)https") {
919
  return (synth(750, ""));
944
 
945
  switch (Mage::getStoreConfig('turpentine_varnish/servers/version')) {
946
  case 4.0:
947
+ case 4.1:
948
  $tpl = <<<EOS
949
  sub vcl_synth {
950
  if (resp.status == 999) {
981
  {
982
  $tpl = $this->_vcl_sub_synth();
983
 
984
+ if ( ! $tpl) {
985
  $tpl = <<<EOS
986
  sub vcl_synth {
987
  if (resp.status == 750) {
991
  }
992
  }
993
  EOS;
994
+ } else{
995
  $tpl_750 = '
996
  sub vcl_synth {
997
  if (resp.status == 750) {
1088
 
1089
  if (Mage::getStoreConfig('turpentine_varnish/general/https_redirect_fix')) {
1090
  $vars['https_redirect'] = $this->_vcl_sub_https_redirect_fix();
1091
+ if (Mage::getStoreConfig('turpentine_varnish/servers/version') == '4.0' || Mage::getStoreConfig('turpentine_varnish/servers/version') == '4.1') {
1092
  $vars['vcl_synth'] = $this->_vcl_sub_synth_https_fix();
1093
  }
1094
  }
1095
 
1096
+ foreach (array('', 'top') as $position) {
1097
  $customIncludeFile = $this->_getCustomIncludeFilename($position);
1098
  if (is_readable($customIncludeFile)) {
1099
  $key = 'custom_vcl_include';
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version3.php CHANGED
@@ -35,8 +35,7 @@ class Nexcessnet_Turpentine_Model_Varnish_Configurator_Version3
35
  $customTemplate = $this->_getCustomTemplateFilename();
36
  if ($customTemplate) {
37
  $tplFile = $customTemplate;
38
- }
39
- else {
40
  $tplFile = $this->_getVclTemplateFilename(self::VCL_TEMPLATE_FILE);
41
  }
42
  $vcl = $this->_formatTemplate(file_get_contents($tplFile),
35
  $customTemplate = $this->_getCustomTemplateFilename();
36
  if ($customTemplate) {
37
  $tplFile = $customTemplate;
38
+ } else {
 
39
  $tplFile = $this->_getVclTemplateFilename(self::VCL_TEMPLATE_FILE);
40
  }
41
  $vcl = $this->_formatTemplate(file_get_contents($tplFile),
app/code/community/Nexcessnet/Turpentine/Model/Varnish/Configurator/Version4.php CHANGED
@@ -35,8 +35,7 @@ class Nexcessnet_Turpentine_Model_Varnish_Configurator_Version4
35
  $customTemplate = $this->_getCustomTemplateFilename();
36
  if ($customTemplate) {
37
  $tplFile = $customTemplate;
38
- }
39
- else {
40
  $tplFile = $this->_getVclTemplateFilename(self::VCL_TEMPLATE_FILE);
41
  }
42
  $vcl = $this->_formatTemplate(file_get_contents($tplFile),
@@ -94,13 +93,13 @@ EOS;
94
  $backendNodes = Mage::helper('turpentine/data')->cleanExplode(PHP_EOL,
95
  Mage::getStoreConfig('turpentine_vcl/backend/backend_nodes'));
96
 
97
- for($i = 0, $iMax = count($backendNodes); $i < $iMax; $i++) {
98
  $tpl .= <<<EOS
99
  vdir.add_backend(web{$i});
100
  EOS;
101
  }
102
 
103
- for($i = 0, $iMax = count($adminBackendNodes); $i < $iMax; $i++) {
104
  $tpl .= <<<EOS
105
  vdir_admin.add_backend(webadmin{$i});
106
  EOS;
@@ -132,7 +131,7 @@ EOS;
132
  Mage::getStoreConfig('turpentine_vcl/backend/backend_nodes'));
133
  $probeUrl = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_url');
134
 
135
- if('admin' == $name) {
136
  $prefix = 'admin';
137
  } else {
138
  $prefix = '';
@@ -145,7 +144,7 @@ EOS;
145
  $parts = explode(':', $backendNode, 2);
146
  $host = (empty($parts[0])) ? '127.0.0.1' : $parts[0];
147
  $port = (empty($parts[1])) ? '80' : $parts[1];
148
- $backends .= $this->_vcl_director_backend($host, $port, $prefix . $number, $probeUrl, $backendOptions);
149
 
150
  $number++;
151
  }
35
  $customTemplate = $this->_getCustomTemplateFilename();
36
  if ($customTemplate) {
37
  $tplFile = $customTemplate;
38
+ } else {
 
39
  $tplFile = $this->_getVclTemplateFilename(self::VCL_TEMPLATE_FILE);
40
  }
41
  $vcl = $this->_formatTemplate(file_get_contents($tplFile),
93
  $backendNodes = Mage::helper('turpentine/data')->cleanExplode(PHP_EOL,
94
  Mage::getStoreConfig('turpentine_vcl/backend/backend_nodes'));
95
 
96
+ for ($i = 0, $iMax = count($backendNodes); $i < $iMax; $i++) {
97
  $tpl .= <<<EOS
98
  vdir.add_backend(web{$i});
99
  EOS;
100
  }
101
 
102
+ for ($i = 0, $iMax = count($adminBackendNodes); $i < $iMax; $i++) {
103
  $tpl .= <<<EOS
104
  vdir_admin.add_backend(webadmin{$i});
105
  EOS;
131
  Mage::getStoreConfig('turpentine_vcl/backend/backend_nodes'));
132
  $probeUrl = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_url');
133
 
134
+ if ('admin' == $name) {
135
  $prefix = 'admin';
136
  } else {
137
  $prefix = '';
144
  $parts = explode(':', $backendNode, 2);
145
  $host = (empty($parts[0])) ? '127.0.0.1' : $parts[0];
146
  $port = (empty($parts[1])) ? '80' : $parts[1];
147
+ $backends .= $this->_vcl_director_backend($host, $port, $prefix.$number, $probeUrl, $backendOptions);
148
 
149
  $number++;
150
  }
app/code/community/Nexcessnet/Turpentine/controllers/EsiController.php CHANGED
@@ -183,9 +183,9 @@ class Nexcessnet_Turpentine_EsiController extends Mage_Core_Controller_Front_Act
183
  }
184
  }
185
  $layout = Mage::getSingleton('core/layout');
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(
@@ -212,10 +212,8 @@ class Nexcessnet_Turpentine_EsiController extends Mage_Core_Controller_Front_Act
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"',
183
  }
184
  }
185
  $layout = Mage::getSingleton('core/layout');
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(
212
  $turpentineHelper = Mage::helper('turpentine/data')
213
  ->setLayout($layout);
214
 
215
+ $blockNode = Mage::helper('turpentine/esi')->getEsiLayoutBlockNode(
216
+ $layout, $esiData->getNameInLayout());
 
 
217
  if ( ! ($blockNode instanceof Mage_Core_Model_Layout_Element)) {
218
  Mage::helper('turpentine/debug')->logWarn(
219
  'No block node found with @name="%s"',
app/code/community/Nexcessnet/Turpentine/etc/config.xml CHANGED
@@ -20,7 +20,7 @@
20
  <config>
21
  <modules>
22
  <Nexcessnet_Turpentine>
23
- <version>0.7.10</version>
24
  </Nexcessnet_Turpentine>
25
  </modules>
26
  <default>
20
  <config>
21
  <modules>
22
  <Nexcessnet_Turpentine>
23
+ <version>0.7.2</version>
24
  </Nexcessnet_Turpentine>
25
  </modules>
26
  <default>
app/code/community/Nexcessnet/Turpentine/misc/version-4.vcl CHANGED
@@ -127,7 +127,7 @@ sub vcl_recv {
127
  if (!{{enable_caching}} || req.http.Authorization ||
128
  req.method !~ "^(GET|HEAD|OPTIONS)$" ||
129
  req.http.Cookie ~ "varnish_bypass={{secret_handshake}}") {
130
- return (pass);
131
  }
132
 
133
  if({{send_unmodified_url}}) {
127
  if (!{{enable_caching}} || req.http.Authorization ||
128
  req.method !~ "^(GET|HEAD|OPTIONS)$" ||
129
  req.http.Cookie ~ "varnish_bypass={{secret_handshake}}") {
130
+ return (pipe);
131
  }
132
 
133
  if({{send_unmodified_url}}) {
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>13:50:04</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>4929b8a5cbd4e62f254a42dae881eda28b0a7dec</__commit_hash><version>0.7.10</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="b564606032d111537d02c8da63470c39" name="varnish_management.phtml" /></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file hash="c77b5ace7bf2300de8cab000c5ccb127" name="turpentine_esi.xml" /></dir><dir name="template"><dir name="turpentine"><file hash="4369ad60461aaf69a17a3357c8fe16c6" name="ajax.phtml" /><file hash="b268c48251ccfccf5c775d3e85513584" name="esi.phtml" /><file hash="50798888953fd1550e4347c39e395d0a" name="notices.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="Block"><file hash="65b7bc93cb512a208e0f48615996a7e2" name="Management.php" /><file hash="390cf75d04b1b098cad562229b649c2d" name="Notices.php" /><dir name="Catalog"><dir name="Product"><dir name="List"><file hash="ce9fca4c273987759f284fe31c1597f5" name="Toolbar.php" /></dir></dir></dir><dir name="Adminhtml"><dir name="Cache"><file hash="8265061356f8096fc82c88334b4effc9" name="Grid.php" /></dir></dir><dir name="Core"><file hash="2b4c814c8aa426fa586459716d7c2659" name="Messages.php" /></dir><dir name="Poll"><file hash="77a2469841c71b1c45d90947e2855ba7" name="ActivePoll.php" /></dir><dir name="Product"><file hash="c86f7e0571583011932b8bad37aa5acd" name="Viewed.php" /><file hash="e907d4de82aba5be25272127674a10e3" name="Compared.php" /></dir></dir><dir name="etc"><file hash="cd25f1233cef68573cb177ac1f4b3790" name="config.xml" /><file hash="80c694720f82ed6c756621b9d5bdce7d" name="system.xml" /><file hash="3b608fbcca3d307833d10604dff23966" name="cache.xml" /></dir><dir name="controllers"><file hash="441c60671b8cdd249dadc05fcdf0373b" name="EsiController.php" /><dir name="Adminhtml"><file hash="9ed581279364b21ead6ad07ff951d90e" name="CacheController.php" /></dir><dir name="Varnish"><file hash="36ed74dba513b500b7a25175d43a4d71" name="ManagementController.php" /></dir></dir><dir name="Helper"><file hash="99ec12c46fd42fbfabdb191c4af7fbe6" name="Varnish.php" /><file hash="66399790e7dda35e709b346889a21b1b" name="Debug.php" /><file hash="a1a0b6aa02aff34f995d3df15c993978" name="Cron.php" /><file hash="c6068752ae71f7fbf58208263d94880d" name="Ban.php" /><file hash="193775458c5fa27cde724aae8b54f489" name="Data.php" /><file hash="7f156b5d3f3aafd56f8ec67f4d70d436" name="Esi.php" /></dir><dir name="misc"><file hash="57b57d1363b8024390c6f0a92e237e91" name="version-3.vcl" /><file hash="ba5d5c7263cd90eea3785953e3549041" name="uuid.c" /><file hash="e032877a7ca037dd8fae4bbb4b49999c" name="version-4.vcl" /><file hash="8bdb8b25b777e19745ec42b251083a8d" name="version-2.vcl" /></dir><dir name="Model"><file hash="ffd2af1c58782a2086422b2077f00282" name="Session.php" /><dir name="Config"><dir name="Select"><file hash="403dcea1f19b377f30af5f89297d9a69" name="Version.php" /><file hash="9348c5e58037fd97d89b84ccab4ef2d0" name="Toggle.php" /><file hash="2a4648995fc87472b2ac33b35a7d69e5" name="LoadBalancing.php" /><file hash="f411ae6da3c2154e78e0f7e845212166" name="StripWhitespace.php" /></dir></dir><dir name="Observer"><file hash="16e4975274e8c3454bf2226d5a0558e6" name="Varnish.php" /><file hash="4f67e6d7c35891451391b13a0eec9847" name="Debug.php" /><file hash="acdb0304a8b89ae5f072d523be63d9c0" name="Cron.php" /><file hash="bdf76e0eb3b31341ae0d80beba83d85b" name="Ban.php" /><file hash="cfa236bb8cceb0accc0f8c3bc74efbf3" name="Esi.php" /></dir><dir name="Core"><file hash="8f512da6e6da419acc07710b079e3ca9" name="Session.php" /></dir><dir name="Shim"><dir name="Mage"><dir name="Core"><file hash="ee6924c626916a8edd49b6037809204a" name="Layout.php" /><file hash="85e9e378b8fd0ab504c751a69d0b28a6" name="App.php" /><file hash="5912fa8ef25346f2a21316d8ea5de867" name="Config.php" /></dir></dir></dir><dir name="PageCache"><dir name="Container"><file hash="6e3b54ae5968af644952b00cd96a3f32" name="Notices.php" /></dir></dir><dir name="Varnish"><file hash="b264dc1982cef539b8dc2c86aa34c5c3" name="Admin.php" /><dir name="Configurator"><file hash="a0f098ef4e538fb9ee671e2e49378796" name="Abstract.php" /><file hash="8ee23e5993ecd7a0d880221fbda74ecf" name="Version4.php" /><file hash="fa8b92a14b7b608dfe0af030b6a78a77" name="Version3.php" /><file hash="d4d66168e43a62ceab30226b44b9e98b" name="Version2.php" /></dir><dir name="Admin"><file hash="add6be96edabcb62a9003dad8d18d808" name="Socket.php" /></dir></dir><dir name="Dummy"><file hash="07e4db6d82110e523d1400dcfec60830" name="Request.php" /></dir></dir></dir></dir></target></contents><dependencies><required><php><min>5.2.13</min><max>7.1.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>2017-01-03</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>
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>09:30:03</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>d2b0b29fd6ac07321bbb3dcc7a4d50f4f4795291</__commit_hash><version>0.7.2</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="b564606032d111537d02c8da63470c39" name="varnish_management.phtml" /></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file hash="c77b5ace7bf2300de8cab000c5ccb127" name="turpentine_esi.xml" /></dir><dir name="template"><dir name="turpentine"><file hash="4369ad60461aaf69a17a3357c8fe16c6" name="ajax.phtml" /><file hash="b268c48251ccfccf5c775d3e85513584" name="esi.phtml" /><file hash="50798888953fd1550e4347c39e395d0a" name="notices.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="Block"><file hash="65b7bc93cb512a208e0f48615996a7e2" name="Management.php" /><file hash="390cf75d04b1b098cad562229b649c2d" name="Notices.php" /><dir name="Catalog"><dir name="Product"><dir name="List"><file hash="ce9fca4c273987759f284fe31c1597f5" name="Toolbar.php" /></dir></dir></dir><dir name="Adminhtml"><dir name="Cache"><file hash="8265061356f8096fc82c88334b4effc9" name="Grid.php" /></dir></dir><dir name="Core"><file hash="2b4c814c8aa426fa586459716d7c2659" name="Messages.php" /></dir><dir name="Poll"><file hash="7e9999bf5f3413294d6eebcd3055538b" name="ActivePoll.php" /></dir><dir name="Product"><file hash="c86f7e0571583011932b8bad37aa5acd" name="Viewed.php" /><file hash="e907d4de82aba5be25272127674a10e3" name="Compared.php" /></dir></dir><dir name="etc"><file hash="bf4fcf82c0c7a9ae3a39096a7c49c540" name="config.xml" /><file hash="80c694720f82ed6c756621b9d5bdce7d" name="system.xml" /><file hash="3b608fbcca3d307833d10604dff23966" name="cache.xml" /></dir><dir name="controllers"><file hash="32b46f18f46e1998a993e95fcba5b936" name="EsiController.php" /><dir name="Adminhtml"><file hash="9ed581279364b21ead6ad07ff951d90e" name="CacheController.php" /></dir><dir name="Varnish"><file hash="36ed74dba513b500b7a25175d43a4d71" name="ManagementController.php" /></dir></dir><dir name="Helper"><file hash="99ec12c46fd42fbfabdb191c4af7fbe6" name="Varnish.php" /><file hash="66399790e7dda35e709b346889a21b1b" name="Debug.php" /><file hash="a1a0b6aa02aff34f995d3df15c993978" name="Cron.php" /><file hash="c6068752ae71f7fbf58208263d94880d" name="Ban.php" /><file hash="193775458c5fa27cde724aae8b54f489" name="Data.php" /><file hash="bb7e501af8ebb74bb06b30098b1cf711" name="Esi.php" /></dir><dir name="misc"><file hash="57b57d1363b8024390c6f0a92e237e91" name="version-3.vcl" /><file hash="ba5d5c7263cd90eea3785953e3549041" name="uuid.c" /><file hash="2a6aa7407a58ae88c0957363a3cd2fff" name="version-4.vcl" /><file hash="8bdb8b25b777e19745ec42b251083a8d" name="version-2.vcl" /></dir><dir name="Model"><file hash="ffd2af1c58782a2086422b2077f00282" name="Session.php" /><dir name="Config"><dir name="Select"><file hash="f615bf43f491c6465b19fd7d7d53d283" name="Version.php" /><file hash="9348c5e58037fd97d89b84ccab4ef2d0" name="Toggle.php" /><file hash="2a4648995fc87472b2ac33b35a7d69e5" name="LoadBalancing.php" /><file hash="f411ae6da3c2154e78e0f7e845212166" name="StripWhitespace.php" /></dir></dir><dir name="Observer"><file hash="dfda7ae2d0a3fc7db5c5b9fbbd8e9f7c" name="Varnish.php" /><file hash="4f67e6d7c35891451391b13a0eec9847" name="Debug.php" /><file hash="acdb0304a8b89ae5f072d523be63d9c0" name="Cron.php" /><file hash="bdf76e0eb3b31341ae0d80beba83d85b" name="Ban.php" /><file hash="d9e8a19490b888a08bccca95724b7f0c" name="Esi.php" /></dir><dir name="Core"><file hash="a557f38e6211582bb37bddb94e007511" name="Session.php" /></dir><dir name="Shim"><dir name="Mage"><dir name="Core"><file hash="ee6924c626916a8edd49b6037809204a" name="Layout.php" /><file hash="85e9e378b8fd0ab504c751a69d0b28a6" name="App.php" /><file hash="5912fa8ef25346f2a21316d8ea5de867" name="Config.php" /></dir></dir></dir><dir name="PageCache"><dir name="Container"><file hash="6e3b54ae5968af644952b00cd96a3f32" name="Notices.php" /></dir></dir><dir name="Varnish"><file hash="7a6b61ec1eb06c192fa11d5fdc2549a2" name="Admin.php" /><dir name="Configurator"><file hash="f417c36643a783fba486a648e651b80e" name="Abstract.php" /><file hash="83bafa6d8f2fa1e1ab7d2247aab1c9ad" name="Version4.php" /><file hash="b5a6b0206dfdb4168941070e49171192" name="Version3.php" /><file hash="d4d66168e43a62ceab30226b44b9e98b" name="Version2.php" /></dir><dir name="Admin"><file hash="d376269b433f2baabac41523c1a3d449" name="Socket.php" /></dir></dir><dir name="Dummy"><file hash="07e4db6d82110e523d1400dcfec60830" name="Request.php" /></dir></dir></dir></dir></target></contents><dependencies><required><php><min>5.2.13</min><max>7.1.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>2017-02-21</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>