LiteSpeed_LiteMage - Version 1.3.6

Version Notes

Added a ‘Debug Level’ option for controlling debug log message detail.
Added a ‘Disable Layout Override for Non-Cacheable Routes’ option for sites with issues during the checkout process.
Added an extra check for mismatched mobile detection rules between LiteMage and .htaccess for unresponsive mobile views.
Added the ability to crawl mobile views for unresponsive themes.
LiteMage will now write to it’s own debug log when enabled under Developer testing. Magento debug logging also no longer needs to be enabled.

Download this release

Release Info

Developer LiteSpeed Technologies
Extension LiteSpeed_LiteMage
Version 1.3.6
Comparing to
See all releases


Code changes from version 1.3.5 to 1.3.6

app/code/community/Litespeed/Litemage/Block/Core/Dummy.php CHANGED
@@ -36,13 +36,13 @@ class Litespeed_Litemage_Block_Core_Dummy extends Mage_Core_Block_Abstract
36
  // dummy block not exist in ESILayout, they are not ESI block, safe to ignore
37
  public function __call($method, $args)
38
  {
39
- Mage::helper('litemage/data')->debugMesg('Dummy block ' . $this->_name . " called $method - ignore");
40
 
41
  }
42
 
43
  public static function __callStatic($method, $args)
44
  {
45
- Mage::helper('litemage/data')->debugMesg('Dummy block ' . $this->_name . " called static $method - ignore");
46
  }
47
 
48
  }
36
  // dummy block not exist in ESILayout, they are not ESI block, safe to ignore
37
  public function __call($method, $args)
38
  {
39
+ Mage::helper('litemage/data')->debugMesg('Dummy block ' . $this->_name . " called $method - ignore", Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_SAFEIGNORE);
40
 
41
  }
42
 
43
  public static function __callStatic($method, $args)
44
  {
45
+ Mage::helper('litemage/data')->debugMesg('Dummy block ' . $this->_name . " called static $method - ignore", Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_SAFEIGNORE);
46
  }
47
 
48
  }
app/code/community/Litespeed/Litemage/Block/Core/Esi.php CHANGED
@@ -27,10 +27,13 @@ class Litespeed_Litemage_Block_Core_Esi extends Mage_Core_Block_Abstract
27
  {
28
 
29
  protected $_peer ;
 
30
 
31
  public function initByPeer( $peer )
32
  {
33
  $this->_peer = $peer ;
 
 
34
  parent::setData('litemage_bconf', $peer->getData('litemage_bconf')) ;
35
 
36
  $this->_layout = $peer->_layout ;
@@ -66,7 +69,8 @@ class Litespeed_Litemage_Block_Core_Esi extends Mage_Core_Block_Abstract
66
 
67
  public static function __callStatic($method, $args)
68
  {
69
- Mage::helper('litemage/data')->debugMesg('esi block ' . $this->_nameInLayout . " called static $method - ignore");
 
70
  }
71
 
72
 
@@ -78,7 +82,10 @@ class Litespeed_Litemage_Block_Core_Esi extends Mage_Core_Block_Abstract
78
  }
79
 
80
  $bconf = $this->getData('litemage_bconf') ;
81
- Mage::helper('litemage/data')->debugMesg('Injected ESI block ' . $this->_nameInLayout . ' ' . $esiHtml) ;
 
 
 
82
 
83
  if ( ! $bconf['valueonly'] && Mage::registry('LITEMAGE_SHOWHOLES') ) {
84
  $tip = 'LiteMage ESI block ' . $this->_nameInLayout ;
@@ -111,7 +118,10 @@ class Litespeed_Litemage_Block_Core_Esi extends Mage_Core_Block_Abstract
111
  $ignored = 0;
112
  }
113
  }
114
- Mage::helper('litemage/data')->debugMesg('esi block ' . $this->_nameInLayout . " called setData $key=$value ignored=$ignored");
 
 
 
115
  return parent::setData($key, $value);
116
  }
117
 
@@ -124,7 +134,10 @@ class Litespeed_Litemage_Block_Core_Esi extends Mage_Core_Block_Abstract
124
  parent::setData('litemage_bconf', $bconf);
125
  $ignored = 0;
126
  }
127
- Mage::helper('litemage/data')->debugMesg('esi block ' . $this->_nameInLayout . " called unsetData $key ignored=$ignored");
 
 
 
128
  return parent::unsetData($key);
129
  }
130
  }
27
  {
28
 
29
  protected $_peer ;
30
+ protected $_isDebug;
31
 
32
  public function initByPeer( $peer )
33
  {
34
  $this->_peer = $peer ;
35
+ $this->_isDebug = Mage::helper('litemage/data')->isDebug(Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_SAFEIGNORE);
36
+
37
  parent::setData('litemage_bconf', $peer->getData('litemage_bconf')) ;
38
 
39
  $this->_layout = $peer->_layout ;
69
 
70
  public static function __callStatic($method, $args)
71
  {
72
+ Mage::helper('litemage/data')->debugMesg('esi block ' . $this->_nameInLayout . " called static $method - ignore",
73
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_SAFEIGNORE);
74
  }
75
 
76
 
82
  }
83
 
84
  $bconf = $this->getData('litemage_bconf') ;
85
+ if ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION) {
86
+ Mage::helper('litemage/data')->debugMesg('Injected ESI block ' . $this->_nameInLayout . ' ' . $esiHtml,
87
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION) ;
88
+ }
89
 
90
  if ( ! $bconf['valueonly'] && Mage::registry('LITEMAGE_SHOWHOLES') ) {
91
  $tip = 'LiteMage ESI block ' . $this->_nameInLayout ;
118
  $ignored = 0;
119
  }
120
  }
121
+ if ($this->_isDebug) {
122
+ Mage::helper('litemage/data')->debugMesg('esi block ' . $this->_nameInLayout . " called setData $key=$value ignored=$ignored",
123
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_SAFEIGNORE);
124
+ }
125
  return parent::setData($key, $value);
126
  }
127
 
134
  parent::setData('litemage_bconf', $bconf);
135
  $ignored = 0;
136
  }
137
+ if ($this->_isDebug) {
138
+ Mage::helper('litemage/data')->debugMesg('esi block ' . $this->_nameInLayout . " called unsetData $key ignored=$ignored",
139
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_SAFEIGNORE);
140
+ }
141
  return parent::unsetData($key);
142
  }
143
  }
app/code/community/Litespeed/Litemage/Block/Core/Messages.php CHANGED
@@ -32,8 +32,9 @@ class Litespeed_Litemage_Block_Core_Messages extends Mage_Core_Block_Messages
32
  protected $_peerTemplate ;
33
  protected $_blockIndex ;
34
  protected $_isEsiInject ;
 
35
 
36
- /* Override Mage_Core_Block_Abstract:getMessagesBlock */
37
 
38
  public function getMessagesBlock()
39
  {
@@ -43,6 +44,8 @@ class Litespeed_Litemage_Block_Core_Messages extends Mage_Core_Block_Messages
43
  public function initByPeer( $peer )
44
  {
45
  $this->_peer = $peer ;
 
 
46
  $this->setData('litemage_bconf', $peer->getData('litemage_bconf')) ;
47
  $this->_peerClass = get_class($peer) ;
48
  $this->_peerTemplate = $peer->getTemplate() ; // todo: check if null;
@@ -119,7 +122,10 @@ class Litespeed_Litemage_Block_Core_Messages extends Mage_Core_Block_Messages
119
  }
120
 
121
  $esiHtml = $this->getData('esiHtml') ;
122
- Mage::helper('litemage/data')->debugMesg('Injected ESI Message block renderview ' . $this->_nameInLayout . ' ' . $esiHtml) ;
 
 
 
123
 
124
  if ( Mage::registry('LITEMAGE_SHOWHOLES') ) {
125
  $tip = 'LiteMage ESI message block ' . $this->_nameInLayout ;
32
  protected $_peerTemplate ;
33
  protected $_blockIndex ;
34
  protected $_isEsiInject ;
35
+ protected $_isDebug;
36
 
37
+ /* Override Mage_Core_Block_Abstract:getMessagesBlock */
38
 
39
  public function getMessagesBlock()
40
  {
44
  public function initByPeer( $peer )
45
  {
46
  $this->_peer = $peer ;
47
+ $this->_isDebug = Mage::helper('litemage/data')->isDebug(Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION);
48
+
49
  $this->setData('litemage_bconf', $peer->getData('litemage_bconf')) ;
50
  $this->_peerClass = get_class($peer) ;
51
  $this->_peerTemplate = $peer->getTemplate() ; // todo: check if null;
122
  }
123
 
124
  $esiHtml = $this->getData('esiHtml') ;
125
+ if ($this->_isDebug) {
126
+ Mage::helper('litemage/data')->debugMesg('Injected ESI Message block renderview ' . $this->_nameInLayout . ' ' . $esiHtml,
127
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION) ;
128
+ }
129
 
130
  if ( Mage::registry('LITEMAGE_SHOWHOLES') ) {
131
  $tip = 'LiteMage ESI message block ' . $this->_nameInLayout ;
app/code/community/Litespeed/Litemage/Block/Core/Xml.php CHANGED
@@ -44,13 +44,13 @@ class Litespeed_Litemage_Block_Core_Xml extends Mage_Core_Block_Abstract
44
  // xml block not exist in ESILayout, they are not ESI block, safe to ignore
45
  public function __call($method, $args)
46
  {
47
- Mage::helper('litemage/data')->debugMesg('Xml block ' . $this->_name . " called $method - ignore");
48
 
49
  }
50
 
51
  public static function __callStatic($method, $args)
52
  {
53
- Mage::helper('litemage/data')->debugMesg('Xml block ' . $this->_name . " called static $method - ignore");
54
  }
55
 
56
  protected function _getBlockXmlString($bi)
44
  // xml block not exist in ESILayout, they are not ESI block, safe to ignore
45
  public function __call($method, $args)
46
  {
47
+ Mage::helper('litemage/data')->debugMesg('Xml block ' . $this->_name . " called $method - ignore", Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_SAFEIGNORE);
48
 
49
  }
50
 
51
  public static function __callStatic($method, $args)
52
  {
53
+ Mage::helper('litemage/data')->debugMesg('Xml block ' . $this->_name . " called static $method - ignore", Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_SAFEIGNORE);
54
  }
55
 
56
  protected function _getBlockXmlString($bi)
app/code/community/Litespeed/Litemage/Helper/Data.php CHANGED
@@ -30,6 +30,7 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
30
  const STOREXML_PUBLICTTL = 'litemage/general/public_ttl' ;
31
  const STOREXML_PRIVATETTL = 'litemage/general/private_ttl' ;
32
  const STOREXML_HOMETTL = 'litemage/general/home_ttl' ;
 
33
  const STOREXML_TRACKLASTVIEWED = 'litemage/general/track_viewed' ;
34
  const STOREXML_DIFFCUSTGRP = 'litemage/general/diff_customergroup' ;
35
  const STOREXML_DIFFCUSTGRP_SET = 'litemage/general/diff_customergroup_set' ;
@@ -37,13 +38,13 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
37
  const STOREXML_FPWP_ENABLED = 'litemage/fishpigwp/fpwp_cache';
38
  const STOREXML_FPWP_TTL = 'litemage/fishpigwp/fpwp_ttl';
39
  const CFG_ENABLED = 'enabled' ;
40
- const CFG_DEBUGON = 'debug' ;
41
  const CFG_WARMUP = 'warmup' ;
42
  const CFG_WARMUP_SERVER_IP = 'server_ip' ;
43
  const CFG_WARMUP_LOAD_LIMIT = 'load_limit' ;
44
  const CFG_WARMUP_MAXTIME = 'max_time' ;
45
  const CFG_WARMUP_THREAD_LIMIT = 'thread_limit' ;
46
- const CFG_WARMUP_DELTA_LOG = 'delta_log';
47
  const CFG_AUTOCOLLECT = 'collect' ;
48
  const CFG_TRACKLASTVIEWED = 'track_viewed' ;
49
  const CFG_DIFFCUSTGRP = 'diff_customergroup' ;
@@ -64,18 +65,31 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
64
  const CFG_FPWP_TTL = 'fpwp_ttl';
65
  const CFG_FPWP_PREFIX = 'fpwp_prefix';
66
  const CFG_FLUSH_PRODCAT = 'flush_prodcat' ;
 
67
  const CFG_NEED_ADD_DELTA = 'add_delta' ;
 
68
  const LITEMAGE_GENERAL_CACHE_TAG = 'LITESPEED_LITEMAGE' ;
69
  const LITEMAGE_DELTA_CACHE_ID = 'LITEMAGE_DELTA' ;
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  // config items
72
  protected $_conf = array() ;
73
  protected $_userModuleEnabled = -2 ; // -2: not set, true, false
74
  protected $_moduleEnabled = -2 ; // -2: not set, true, false
75
  protected $_esiTag ;
76
- protected $_isDebug = null;
77
  protected $_translateParams = null ;
78
  protected $_debugTag = 'LiteMage' ;
 
79
 
80
  public function licenseEnabled()
81
  {
@@ -109,8 +123,8 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
109
  $tag = '' ;
110
  $httphelper = Mage::helper('core/http') ;
111
  $remoteAddr = $httphelper->getRemoteAddr() ;
112
- $ua = $httphelper->getHttpUserAgent() ;
113
- if ( $ua == 'litemage_walker' || $ua == 'litemage_runner' ) {
114
  $tag = $ua . ':' ;
115
  }
116
  else if ( $ips = $this->getConf(self::CFG_ALLOWEDIPS) ) {
@@ -118,18 +132,36 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
118
  $allowed = false ;
119
  }
120
  }
121
-
122
- if ( $this->_isDebug && $allowed ) {
123
- $tag .= $remoteAddr ;
124
- $msec = microtime() ;
125
- $msec1 = substr($msec, 2, strpos($msec, ' ') - 2) ;
126
- $this->_debugTag .= ' [' . $tag . ':' . $_SERVER['REMOTE_PORT'] . ':' . $msec1 . ']' ;
127
- }
 
128
  }
129
  $this->_userModuleEnabled = $allowed ;
130
  }
131
  return $this->_userModuleEnabled ;
132
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
 
134
  public function isAdminIP()
135
  {
@@ -147,9 +179,10 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
147
  return ($this->getConf(self::CFG_ALLOWEDIPS) != '') ;
148
  }
149
 
150
- public function isDebug()
151
  {
152
- return $this->getConf(self::CFG_DEBUGON) ;
 
153
  }
154
 
155
  public function esiTag( $type )
@@ -158,8 +191,8 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
158
  return $this->_esiTag[$type] ;
159
  }
160
 
161
- if ( $this->_isDebug ) {
162
- $this->debugMesg('Invalid type for esiTag ' . $type) ;
163
  }
164
  }
165
 
@@ -502,6 +535,9 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
502
  }
503
 
504
  $vary_cgrp = $this->_getStoreWarmUpCustGroupVary($store);
 
 
 
505
 
506
  $env = '' ;
507
 
@@ -528,6 +564,7 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
528
  'default_store' => $is_default_store,
529
  'default_site' => $is_default_site,
530
  'env' => $env,
 
531
  'interval' => $interval,
532
  'ttl' => $ttl,
533
  'priority' => $priority,
@@ -551,6 +588,7 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
551
  'default_store' => $is_default_store,
552
  'default_site' => $is_default_site,
553
  'env' => $env,
 
554
  'interval' => $autointerval,
555
  'ttl' => $ttl,
556
  'priority' => $autopriority,
@@ -568,6 +606,7 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
568
  'default_store' => $is_default_store,
569
  'default_site' => $is_default_site,
570
  'env' => $env,
 
571
  'priority' => $priority,
572
  'depth' => $autoconf['deltaDeep'],
573
  'baseurl' => $baseurl ) ;
@@ -596,6 +635,7 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
596
  'store_name' => $storeName,
597
  'default_curr' => $default_currency,
598
  'env' => $env,
 
599
  'interval' => $custInterval,
600
  'ttl' => $ttl,
601
  'priority' => $custPriority + $orderAdjust,
@@ -700,17 +740,23 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
700
  case self::CFG_HOMETTL:
701
  $this->_conf[self::CFG_HOMETTL] = Mage::getStoreConfig(self::STOREXML_HOMETTL) ;
702
  break;
 
 
 
703
  case self::CFG_TRACKLASTVIEWED:
704
  $this->_conf[self::CFG_TRACKLASTVIEWED] = Mage::getStoreConfig(self::STOREXML_TRACKLASTVIEWED) ;
705
  break;
706
  }
707
 
708
- if ( $type == '' )
709
  return $this->_conf[$name] ;
710
- elseif ( $name == '' )
 
711
  return $this->_conf[$type] ;
712
- else
 
713
  return $this->_conf[$type][$name] ;
 
714
  }
715
 
716
  protected function _parseCustGrpSets($groupings)
@@ -834,21 +880,25 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
834
  self::CFG_WARMUP_THREAD_LIMIT => $warmup[self::CFG_WARMUP_THREAD_LIMIT],
835
  self::CFG_WARMUP_MAXTIME => $warmup[self::CFG_WARMUP_MAXTIME],
836
  self::CFG_WARMUP_SERVER_IP => $server_ip,
837
- self::CFG_WARMUP_DELTA_LOG => $delta_log) ;
838
  break ;
839
 
840
  default:
841
  $general = $this->_conf['defaultlm']['general'] ;
842
  $this->_conf[self::CFG_ENABLED] = $general[self::CFG_ENABLED] ;
843
-
844
- $test = $this->_conf['defaultlm']['test'] ;
845
- $this->_conf[self::CFG_DEBUGON] = $test[self::CFG_DEBUGON] ;
846
- $this->_isDebug = $test[self::CFG_DEBUGON] ; // required by cron, needs to be set even when module disabled.
847
  $adminIps = trim($general[self::CFG_ADMINIPS]) ;
848
  $this->_conf[self::CFG_ADMINIPS] = $adminIps ? preg_split($pattern, $adminIps, null, PREG_SPLIT_NO_EMPTY) : '' ;
849
- if ( ($this->_isDebug == 2) && (empty($this->_conf[self::CFG_ADMINIPS]) || ! in_array(Mage::helper('core/http')->getRemoteAddr(), $this->_conf[self::CFG_ADMINIPS])) ) {
850
- $this->_isDebug = 0 ;
851
- }
 
 
 
 
 
 
 
 
852
 
853
  if ( ! $general[self::CFG_ENABLED] )
854
  break ;
@@ -873,6 +923,7 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
873
  $allowedIps = trim($test[self::CFG_ALLOWEDIPS]) ;
874
  $this->_conf[self::CFG_ALLOWEDIPS] = $allowedIps ? preg_split($pattern, $allowedIps, null, PREG_SPLIT_NO_EMPTY) : '' ;
875
  $this->_conf[self::CFG_FLUSH_PRODCAT] = isset($general[self::CFG_FLUSH_PRODCAT]) ? $general[self::CFG_FLUSH_PRODCAT] : 0 ; // for upgrade, maynot save in config
 
876
 
877
  if (isset($this->_conf['defaultlm']['fishpigwp'])) {
878
  $fpwp = $this->_conf['defaultlm']['fishpigwp'];
@@ -883,6 +934,12 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
883
  else {
884
  $this->_conf[self::CFG_FPWP_ENABLED] = 0;
885
  }
 
 
 
 
 
 
886
  }
887
  }
888
 
@@ -908,14 +965,20 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
908
  Mage::app()->saveCache($data, $id, $tags, null) ;
909
  }
910
 
911
- public function debugMesg( $mesg )
912
  {
913
- if ($this->_isDebug === null) {
914
- $this->_initConf();
915
- }
916
- if ( $this->_isDebug ) {
 
 
 
 
 
917
  $mesg = str_replace("\n", ("\n" . $this->_debugTag . ' '), $mesg) ;
918
- Mage::log($this->_debugTag . ' ' . $mesg) ;
 
919
  }
920
  }
921
 
30
  const STOREXML_PUBLICTTL = 'litemage/general/public_ttl' ;
31
  const STOREXML_PRIVATETTL = 'litemage/general/private_ttl' ;
32
  const STOREXML_HOMETTL = 'litemage/general/home_ttl' ;
33
+ const STOREXML_MOBILETHEME = 'litemage/general/mobile_theme' ;
34
  const STOREXML_TRACKLASTVIEWED = 'litemage/general/track_viewed' ;
35
  const STOREXML_DIFFCUSTGRP = 'litemage/general/diff_customergroup' ;
36
  const STOREXML_DIFFCUSTGRP_SET = 'litemage/general/diff_customergroup_set' ;
38
  const STOREXML_FPWP_ENABLED = 'litemage/fishpigwp/fpwp_cache';
39
  const STOREXML_FPWP_TTL = 'litemage/fishpigwp/fpwp_ttl';
40
  const CFG_ENABLED = 'enabled' ;
41
+ const CFG_DEBUG = 'debug' ;
42
  const CFG_WARMUP = 'warmup' ;
43
  const CFG_WARMUP_SERVER_IP = 'server_ip' ;
44
  const CFG_WARMUP_LOAD_LIMIT = 'load_limit' ;
45
  const CFG_WARMUP_MAXTIME = 'max_time' ;
46
  const CFG_WARMUP_THREAD_LIMIT = 'thread_limit' ;
47
+ const CFG_WARMUP_CRAWLER_LOG = 'delta_log';
48
  const CFG_AUTOCOLLECT = 'collect' ;
49
  const CFG_TRACKLASTVIEWED = 'track_viewed' ;
50
  const CFG_DIFFCUSTGRP = 'diff_customergroup' ;
65
  const CFG_FPWP_TTL = 'fpwp_ttl';
66
  const CFG_FPWP_PREFIX = 'fpwp_prefix';
67
  const CFG_FLUSH_PRODCAT = 'flush_prodcat' ;
68
+ const CFG_MOBILE_THEME = 'mobile_theme';
69
  const CFG_NEED_ADD_DELTA = 'add_delta' ;
70
+ const CFG_SAFE_MODE = 'safe_mode';
71
  const LITEMAGE_GENERAL_CACHE_TAG = 'LITESPEED_LITEMAGE' ;
72
  const LITEMAGE_DELTA_CACHE_ID = 'LITEMAGE_DELTA' ;
73
+ const LITEMAGE_USER_AGENT = 'litemage_walker' ;
74
+ const LITEMAGE_FAST_USER_AGENT = 'litemage_runner' ;
75
+ const DEBUG_LEVEL_EXCEPTION = 1;
76
+ const DEBUG_LEVEL_CHECKROUTE = 2;
77
+ const DEBUG_LEVEL_PURGEEVENT = 3;
78
+ const DEBUG_LEVEL_DELTAQ = 4;
79
+ const DEBUG_LEVEL_ENVCOOKIE = 5;
80
+ const DEBUG_LEVEL_SAFEIGNORE = 7;
81
+ const DEBUG_LEVEL_INJECTION = 8;
82
+ const DEBUG_LEVEL_LAYOUTUPDATE = 8;
83
+ const DEBUG_LEVEL_AUTOCOLLECT = 9;
84
 
85
  // config items
86
  protected $_conf = array() ;
87
  protected $_userModuleEnabled = -2 ; // -2: not set, true, false
88
  protected $_moduleEnabled = -2 ; // -2: not set, true, false
89
  protected $_esiTag ;
 
90
  protected $_translateParams = null ;
91
  protected $_debugTag = 'LiteMage' ;
92
+ protected $_litemageUserAgent = -1;
93
 
94
  public function licenseEnabled()
95
  {
123
  $tag = '' ;
124
  $httphelper = Mage::helper('core/http') ;
125
  $remoteAddr = $httphelper->getRemoteAddr() ;
126
+ $ua = $this->getLiteMageUserAgent();
127
+ if ( $ua ) {
128
  $tag = $ua . ':' ;
129
  }
130
  else if ( $ips = $this->getConf(self::CFG_ALLOWEDIPS) ) {
132
  $allowed = false ;
133
  }
134
  }
135
+ if ($allowed) {
136
+ if ( $this->getConf(self::CFG_DEBUG) ) {
137
+ $tag .= $remoteAddr ;
138
+ $msec = microtime() ;
139
+ $msec1 = substr($msec, 2, strpos($msec, ' ') - 2) ;
140
+ $this->_debugTag .= ' [' . $tag . ':' . $_SERVER['REMOTE_PORT'] . ':' . $msec1 . ']' ;
141
+ }
142
+ }
143
  }
144
  $this->_userModuleEnabled = $allowed ;
145
  }
146
  return $this->_userModuleEnabled ;
147
  }
148
+
149
+ public function getLiteMageUserAgent()
150
+ {
151
+ if ($this->_litemageUserAgent === -1) {
152
+ $ua = Mage::helper('core/http')->getHttpUserAgent() ;
153
+ if (strpos($ua, self::LITEMAGE_USER_AGENT) !== false) {
154
+ $this->_litemageUserAgent = self::LITEMAGE_USER_AGENT;
155
+ }
156
+ elseif (strpos($ua, self::LITEMAGE_FAST_USER_AGENT) !== false) {
157
+ $this->_litemageUserAgent = self::LITEMAGE_FAST_USER_AGENT;
158
+ }
159
+ else {
160
+ $this->_litemageUserAgent = '';
161
+ }
162
+ }
163
+ return $this->_litemageUserAgent;
164
+ }
165
 
166
  public function isAdminIP()
167
  {
179
  return ($this->getConf(self::CFG_ALLOWEDIPS) != '') ;
180
  }
181
 
182
+ public function isDebug($requiredLevel=0)
183
  {
184
+ $debug = $this->getConf(self::CFG_DEBUG) ;
185
+ return ($debug < $requiredLevel) ? 0 : $debug;
186
  }
187
 
188
  public function esiTag( $type )
191
  return $this->_esiTag[$type] ;
192
  }
193
 
194
+ if ( $this->getConf(self::CFG_DEBUG) ) { // should never happen
195
+ $this->debugMesg('Invalid type for esiTag ' . $type, self::DEBUG_LEVEL_EXCEPTION) ;
196
  }
197
  }
198
 
535
  }
536
 
537
  $vary_cgrp = $this->_getStoreWarmUpCustGroupVary($store);
538
+
539
+ $crawl_mobile = Mage::getStoreConfig('litemage/warmup/mobile_view', $storeId)
540
+ && Mage::getStoreConfig('litemage/general/mobile_theme', $storeId);
541
 
542
  $env = '' ;
543
 
564
  'default_store' => $is_default_store,
565
  'default_site' => $is_default_site,
566
  'env' => $env,
567
+ 'crawl_mobile' => $crawl_mobile,
568
  'interval' => $interval,
569
  'ttl' => $ttl,
570
  'priority' => $priority,
588
  'default_store' => $is_default_store,
589
  'default_site' => $is_default_site,
590
  'env' => $env,
591
+ 'crawl_mobile' => $crawl_mobile,
592
  'interval' => $autointerval,
593
  'ttl' => $ttl,
594
  'priority' => $autopriority,
606
  'default_store' => $is_default_store,
607
  'default_site' => $is_default_site,
608
  'env' => $env,
609
+ 'crawl_mobile' => $crawl_mobile,
610
  'priority' => $priority,
611
  'depth' => $autoconf['deltaDeep'],
612
  'baseurl' => $baseurl ) ;
635
  'store_name' => $storeName,
636
  'default_curr' => $default_currency,
637
  'env' => $env,
638
+ 'crawl_mobile' => $crawl_mobile,
639
  'interval' => $custInterval,
640
  'ttl' => $ttl,
641
  'priority' => $custPriority + $orderAdjust,
740
  case self::CFG_HOMETTL:
741
  $this->_conf[self::CFG_HOMETTL] = Mage::getStoreConfig(self::STOREXML_HOMETTL) ;
742
  break;
743
+ case self::CFG_MOBILE_THEME:
744
+ $this->_conf[self::CFG_MOBILE_THEME] = Mage::getStoreConfig(self::STOREXML_MOBILETHEME) ;
745
+ break;
746
  case self::CFG_TRACKLASTVIEWED:
747
  $this->_conf[self::CFG_TRACKLASTVIEWED] = Mage::getStoreConfig(self::STOREXML_TRACKLASTVIEWED) ;
748
  break;
749
  }
750
 
751
+ if ( $type == '' ) {
752
  return $this->_conf[$name] ;
753
+ }
754
+ elseif ( $name == '' ) {
755
  return $this->_conf[$type] ;
756
+ }
757
+ else {
758
  return $this->_conf[$type][$name] ;
759
+ }
760
  }
761
 
762
  protected function _parseCustGrpSets($groupings)
880
  self::CFG_WARMUP_THREAD_LIMIT => $warmup[self::CFG_WARMUP_THREAD_LIMIT],
881
  self::CFG_WARMUP_MAXTIME => $warmup[self::CFG_WARMUP_MAXTIME],
882
  self::CFG_WARMUP_SERVER_IP => $server_ip,
883
+ self::CFG_WARMUP_CRAWLER_LOG => $delta_log) ;
884
  break ;
885
 
886
  default:
887
  $general = $this->_conf['defaultlm']['general'] ;
888
  $this->_conf[self::CFG_ENABLED] = $general[self::CFG_ENABLED] ;
 
 
 
 
889
  $adminIps = trim($general[self::CFG_ADMINIPS]) ;
890
  $this->_conf[self::CFG_ADMINIPS] = $adminIps ? preg_split($pattern, $adminIps, null, PREG_SPLIT_NO_EMPTY) : '' ;
891
+
892
+ $test = $this->_conf['defaultlm']['test'] ;
893
+ $debug = $test['debug']; // 0: no debug, 1: log, 2: log only admin ip
894
+ if (($debug == 2) && !in_array(Mage::helper('core/http')->getRemoteAddr(), $this->_conf[self::CFG_ADMINIPS])) {
895
+ $debug = 0;
896
+ }
897
+ if ($debug) {
898
+ $debug = $test['debug_level'];
899
+ }
900
+
901
+ $this->_conf[self::CFG_DEBUG] = $debug ; // required by cron, needs to be set even when module disabled.
902
 
903
  if ( ! $general[self::CFG_ENABLED] )
904
  break ;
923
  $allowedIps = trim($test[self::CFG_ALLOWEDIPS]) ;
924
  $this->_conf[self::CFG_ALLOWEDIPS] = $allowedIps ? preg_split($pattern, $allowedIps, null, PREG_SPLIT_NO_EMPTY) : '' ;
925
  $this->_conf[self::CFG_FLUSH_PRODCAT] = isset($general[self::CFG_FLUSH_PRODCAT]) ? $general[self::CFG_FLUSH_PRODCAT] : 0 ; // for upgrade, maynot save in config
926
+ $this->_conf[self::CFG_SAFE_MODE] = isset($test['safe_mode']) ? $test['safe_mode'] : 0; // default is disabled
927
 
928
  if (isset($this->_conf['defaultlm']['fishpigwp'])) {
929
  $fpwp = $this->_conf['defaultlm']['fishpigwp'];
934
  else {
935
  $this->_conf[self::CFG_FPWP_ENABLED] = 0;
936
  }
937
+ if (!empty($this->_conf['defaultlm']['mobile_theme'])) {
938
+ $this->_conf[self::CFG_MOBILE_THEME] = $this->_conf['defaultlm']['mobile_theme'];
939
+ }
940
+ else {
941
+ $this->_conf[self::CFG_MOBILE_THEME] = '';
942
+ }
943
  }
944
  }
945
 
965
  Mage::app()->saveCache($data, $id, $tags, null) ;
966
  }
967
 
968
+ public function debugMesg( $mesg, $debugLevel=9 )
969
  {
970
+ $debug = $this->getConf(self::CFG_DEBUG) ;
971
+ if ( $debug >= $debugLevel) {
972
+ if ($debugLevel == self::DEBUG_LEVEL_EXCEPTION) {
973
+ ob_start();
974
+ debug_print_backtrace(0, 30);
975
+ $trace = ob_get_contents();
976
+ ob_end_clean();
977
+ $mesg .= "\n" . $trace;
978
+ }
979
  $mesg = str_replace("\n", ("\n" . $this->_debugTag . ' '), $mesg) ;
980
+ //($message, $level = null, $file = '', $forceLog = false)
981
+ Mage::log($this->_debugTag . ' (' . $debugLevel . ') ' . $mesg, null, 'litemage.log', true) ;
982
  }
983
  }
984
 
app/code/community/Litespeed/Litemage/Helper/Esi.php CHANGED
@@ -87,6 +87,18 @@ class Litespeed_Litemage_Helper_Esi
87
  return ( ($this->_cacheVars['flag'] & self::CHBM_NOT_CACHEABLE) == self::CHBM_NOT_CACHEABLE );
88
  }
89
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  protected function _setEsiOn()
91
  {
92
  if ( ($this->_cacheVars['flag'] & self::CHBM_ESI_ON) == 0 ) {
@@ -133,7 +145,9 @@ class Litespeed_Litemage_Helper_Esi
133
  public function canInjectEsi()
134
  {
135
  $flag = $this->_cacheVars['flag'] ;
136
- return ((($flag & self::CHBM_CACHEABLE) != 0) && (($flag & self::CHBM_ESI_REQ) == 0)) ;
 
 
137
  }
138
 
139
  public function isEsiRequest()
@@ -142,6 +156,33 @@ class Litespeed_Litemage_Helper_Esi
142
  return (($flag & self::CHBM_ESI_REQ) != 0) ;
143
  }
144
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  public function initFormKey()
146
  {
147
  $session = Mage::getSingleton('core/session') ;
@@ -206,8 +247,9 @@ class Litespeed_Litemage_Helper_Esi
206
  $purgeHeader .= trim($t, ',');
207
 
208
  header(self::LSHEADER_PURGE . ': ' . $purgeHeader, true);
209
- if ($this->_isDebug) {
210
- $this->_config->debugMesg("SetPurgeHeader: " . $purgeHeader . ' (triggered by event ' . $eventName . ')') ;
 
211
  }
212
  }
213
  }
@@ -235,8 +277,9 @@ class Litespeed_Litemage_Helper_Esi
235
  $response = Mage::app()->getResponse() ;
236
  }
237
  $response->setHeader(self::LSHEADER_PURGE, $purgeHeader, true) ;
238
- if ($this->_isDebug) {
239
- $this->_config->debugMesg("SetPurgeHeader: " . $purgeHeader . ' (triggered by ' . $by . ')') ;
 
240
  }
241
  }
242
 
@@ -244,8 +287,9 @@ class Litespeed_Litemage_Helper_Esi
244
  {
245
  $response = Mage::app()->getResponse() ;
246
 
247
- if ($this->_isDebug) {
248
- $this->_config->debugMesg("SetPurgeHeader: " . $url . ' (triggered by ' . $by . ')') ;
 
249
  }
250
  $response->setHeader(self::LSHEADER_PURGE, $url, true) ;
251
  }
@@ -320,9 +364,10 @@ class Litespeed_Litemage_Helper_Esi
320
  $this->_esiLayoutCache['blocks'] = unserialize($result) ;
321
  }
322
 
323
- if ( $this->_isDebug ) {
324
  // 0 not in cache, 1 from cache
325
- $this->_config->debugMesg('INJECTING_' . $preload . ' ' . $_SERVER['REQUEST_URI']) ;
 
326
  }
327
  }
328
 
@@ -466,8 +511,9 @@ class Litespeed_Litemage_Helper_Esi
466
  else {
467
  $msg = 'cannot find Fishpig helper';
468
  }
469
- if ($this->_isDebug) {
470
- $this->_config->debugMesg('Fishpig WP - ' . $msg);
 
471
  }
472
 
473
  }
@@ -486,6 +532,7 @@ class Litespeed_Litemage_Helper_Esi
486
  $this->_cacheVars['internal']['response_code'] = $responseCode;
487
 
488
  if ( (($flag & self::CHBM_CACHEABLE) == 0)
 
489
  || $envChanged
490
  || Mage::registry('LITEMAGE_SHOWHOLES')
491
  || Mage::registry('LITEMAGE_PURGE')
@@ -551,11 +598,13 @@ class Litespeed_Litemage_Helper_Esi
551
  }
552
 
553
  $this->_restoreFormKey() ;
 
 
554
 
555
  foreach($extraHeaders as $key => $val) {
556
  $response->setHeader($key, $val);
557
- if ($this->_isDebug) {
558
- $this->_config->debugMesg("Header $key: $val");
559
  }
560
  }
561
 
@@ -571,12 +620,15 @@ class Litespeed_Litemage_Helper_Esi
571
  $tracker = '' ;
572
  $sharedParams = $this->getEsiSharedParams();
573
  $esiIncludeTag = $this->_config->esiTag('include');
 
 
 
574
  if ( (($this->_cacheVars['flag'] & self::CHBM_FORMKEY_REPLACED) != 0) && strpos($responseBody, self::FORMKEY_REPLACE) ) {
575
  // use single quote for pagespeed module
576
  $replace = '<' . $esiIncludeTag . " src='" . $this->getEsiBaseUrl() . "litemage/esi/getFormKey' as-var='1' combine='sub' cache-control='no-vary,private' cache-tag='E.formkey'/>" ;
577
  $responseBody = str_replace(self::FORMKEY_REPLACE, $replace, $responseBody) ;
578
- if ($this->_isDebug) {
579
- $this->_config->debugMesg('FormKey replaced as ' . $replace);
580
  }
581
  $updated = true ;
582
  }
@@ -585,8 +637,8 @@ class Litespeed_Litemage_Helper_Esi
585
  // use single quote for pagespeed module
586
  $replace = '<' . $esiIncludeTag . " src='" . $this->getEsiBaseUrl() . "litemage/esi/getNickName' combine='sub' cache-control='no-vary,private' cache-tag='E.welcome'/>" ;
587
  $responseBody = str_replace(self::NICKNAME_REPLACE, $replace, $responseBody) ;
588
- if ($this->_isDebug) {
589
- $this->_config->debugMesg('Nickname replaced as ' . $replace);
590
  }
591
  $updated = true ;
592
  }
@@ -598,8 +650,8 @@ class Litespeed_Litemage_Helper_Esi
598
  // if response coming from backend, no need to send separate log request
599
  $tracker = '<' . $esiIncludeTag . ' src="' . $this->_getSubReqUrl('litemage/esi/log', $logOptions)
600
  . '" test="$(RESP_HEADER{X-LITESPEED-CACHE})!=\'hit,litemage\'" cache-control="no-cache" combine="sub"/>' ;
601
- if ($this->_isDebug) {
602
- $this->_config->debugMesg('Track recently viewed as ' . $tracker);
603
  }
604
  $updated = true ;
605
  }
@@ -611,8 +663,8 @@ class Litespeed_Litemage_Helper_Esi
611
  if ( ($this->_cacheVars['flag'] & self::CHBM_ESI_ON) != 0 ) {
612
  // no need to use comment, will be removed by minify extensions
613
  $combined = '<' . $esiIncludeTag . ' src="' . $this->_getSubReqUrl('litemage/esi/getCombined', $sharedParams) . '" combine="main2" cache-control="no-cache"/>' ;
614
- if ($this->_isDebug) {
615
- $this->_config->debugMesg('_updateResponseBody combined is ' . $combined);
616
  }
617
  $updated = true;
618
  }
@@ -638,8 +690,8 @@ class Litespeed_Litemage_Helper_Esi
638
  $responseBody);
639
  }
640
  $response->setBody($combined . $tracker . $responseBody) ;
641
- if ($this->_isDebug && !$isAjax) {
642
- $this->_config->debugMesg('_updateResponseBody failed to insert combined after <body>');
643
  }
644
  }
645
  }
@@ -667,8 +719,10 @@ class Litespeed_Litemage_Helper_Esi
667
  }
668
 
669
  $debugMesg = $this->_autoCollectUrls($curStoreId, $tags);
670
- if ($this->_isDebug && $debugMesg) {
671
- $this->_config->debugMesg('_autoCollectUrls: ' . $debugMesg);
 
 
672
  }
673
  }
674
  if ($isPublic) {
@@ -966,7 +1020,7 @@ class Litespeed_Litemage_Helper_Esi
966
  $this->_config->saveInternalCache(serialize($data), $cacheId) ;
967
  }
968
 
969
- if ($this->_isDebug) {
970
  if ($updated == 0)
971
  $msg = 'Delta tags not added, already in pending list';
972
  elseif ($updated == 1)
@@ -974,7 +1028,7 @@ class Litespeed_Litemage_Helper_Esi
974
  else
975
  $msg = 'Delta queue [time=' . $data['time'] . '] appended tag ' . implode(',', $extra);
976
 
977
- $this->_config->debugMesg($msg) ;
978
  }
979
  }
980
 
@@ -1026,8 +1080,9 @@ class Litespeed_Litemage_Helper_Esi
1026
  if ($oldVal != $newVal) {
1027
  Mage::getSingleton('core/cookie')->set($name, $newVal);
1028
  $changed = true;
1029
- if ($this->_isDebug)
1030
- $this->_config->debugMesg('Env ' . $name . ' changed, old=' . $oldVal . ' new=' . $newVal) ;
 
1031
  }
1032
  }
1033
  return $changed;
@@ -1176,8 +1231,9 @@ class Litespeed_Litemage_Helper_Esi
1176
  $this->_cacheVars['cookie'][$cookieName][$cv[$i]] = $cv[$i+1];
1177
  }
1178
  }
1179
- else if ($this->_isDebug) {
1180
- $this->_config->debugMesg('Env Cookie value parse error ' . $cookieName . ' = ' . $cookieVal) ;
 
1181
  }
1182
 
1183
  $this->_cacheVars['cookie'][$cookieName]['_ORG_'] = $cookieVal ;
87
  return ( ($this->_cacheVars['flag'] & self::CHBM_NOT_CACHEABLE) == self::CHBM_NOT_CACHEABLE );
88
  }
89
 
90
+ public function setNotCacheable()
91
+ {
92
+ $oldflag = $flag = $this->_cacheVars['flag'];
93
+ $flag |= self::CHBM_NOT_CACHEABLE;
94
+ $flag &= ~self::CHBM_CACHEABLE;
95
+ $this->_cacheVars['flag'] = $flag;
96
+ if ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION) {
97
+ $this->_config->debugMesg('setNotCacheable from ' . $oldflag . ' to ' . $flag,
98
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION) ;
99
+ }
100
+ }
101
+
102
  protected function _setEsiOn()
103
  {
104
  if ( ($this->_cacheVars['flag'] & self::CHBM_ESI_ON) == 0 ) {
145
  public function canInjectEsi()
146
  {
147
  $flag = $this->_cacheVars['flag'] ;
148
+ return ((($flag & self::CHBM_CACHEABLE) != 0)
149
+ && (($flag & self::CHBM_ESI_REQ) == 0)
150
+ && (($flag & self::CHBM_NOT_CACHEABLE) == 0)) ;
151
  }
152
 
153
  public function isEsiRequest()
156
  return (($flag & self::CHBM_ESI_REQ) != 0) ;
157
  }
158
 
159
+ public function hasMobileThemeMismatch()
160
+ {
161
+ $mobile_theme = $this->_config->getConf(Litespeed_Litemage_Helper_Data::CFG_MOBILE_THEME);
162
+ if ($mobile_theme == '') {
163
+ return false;
164
+ }
165
+ $current_theme = Mage::getDesign()->getTheme('template') ;
166
+ $mismatched = false;
167
+ $vary = '';
168
+ if (isset($_SERVER['LSCACHE_VARY_VALUE'])) {
169
+ // means .htaccess detected mobile
170
+ $mismatched = ($current_theme != $mobile_theme);
171
+ $vary = $_SERVER['LSCACHE_VARY_VALUE'];
172
+ }
173
+ else {
174
+ // means .htaccess detected not mobile
175
+ $mismatched = ($current_theme == $mobile_theme);
176
+ }
177
+
178
+ if ($mismatched && ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_ENVCOOKIE)) {
179
+ $this->_config->debugMesg('hasMobileThemeMismatch current_theme=' . $current_theme
180
+ . ' mobile_theme=' . $mobile_theme . ' LSCACHE_VARY_VALUE=' . $vary,
181
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_ENVCOOKIE) ;
182
+ }
183
+ return $mismatched;
184
+ }
185
+
186
  public function initFormKey()
187
  {
188
  $session = Mage::getSingleton('core/session') ;
247
  $purgeHeader .= trim($t, ',');
248
 
249
  header(self::LSHEADER_PURGE . ': ' . $purgeHeader, true);
250
+ if ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_PURGEEVENT) {
251
+ $this->_config->debugMesg("SetPurgeHeader: " . $purgeHeader . ' (triggered by event ' . $eventName . ')',
252
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_PURGEEVENT) ;
253
  }
254
  }
255
  }
277
  $response = Mage::app()->getResponse() ;
278
  }
279
  $response->setHeader(self::LSHEADER_PURGE, $purgeHeader, true) ;
280
+ if ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_PURGEEVENT) {
281
+ $this->_config->debugMesg("SetPurgeHeader: " . $purgeHeader . ' (triggered by ' . $by . ')',
282
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_PURGEEVENT) ;
283
  }
284
  }
285
 
287
  {
288
  $response = Mage::app()->getResponse() ;
289
 
290
+ if ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_PURGEEVENT) {
291
+ $this->_config->debugMesg("SetPurgeHeader: " . $url . ' (triggered by ' . $by . ')',
292
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_PURGEEVENT) ;
293
  }
294
  $response->setHeader(self::LSHEADER_PURGE, $url, true) ;
295
  }
364
  $this->_esiLayoutCache['blocks'] = unserialize($result) ;
365
  }
366
 
367
+ if ( $this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION ) {
368
  // 0 not in cache, 1 from cache
369
+ $this->_config->debugMesg('INJECTING_' . $preload . ' ' . $_SERVER['REQUEST_URI'],
370
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION) ;
371
  }
372
  }
373
 
511
  else {
512
  $msg = 'cannot find Fishpig helper';
513
  }
514
+ if ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_SAFEIGNORE) {
515
+ $this->_config->debugMesg('Fishpig WP - ' . $msg,
516
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_SAFEIGNORE);
517
  }
518
 
519
  }
532
  $this->_cacheVars['internal']['response_code'] = $responseCode;
533
 
534
  if ( (($flag & self::CHBM_CACHEABLE) == 0)
535
+ || (($flag & self::CHBM_NOT_CACHEABLE) > 0)
536
  || $envChanged
537
  || Mage::registry('LITEMAGE_SHOWHOLES')
538
  || Mage::registry('LITEMAGE_PURGE')
598
  }
599
 
600
  $this->_restoreFormKey() ;
601
+ $debug = ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_PURGEEVENT) ?
602
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_PURGEEVENT : 0;
603
 
604
  foreach($extraHeaders as $key => $val) {
605
  $response->setHeader($key, $val);
606
+ if ($debug) {
607
+ $this->_config->debugMesg("Set Header $key: $val", $debug);
608
  }
609
  }
610
 
620
  $tracker = '' ;
621
  $sharedParams = $this->getEsiSharedParams();
622
  $esiIncludeTag = $this->_config->esiTag('include');
623
+ $debug = ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION) ?
624
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION : 0;
625
+
626
  if ( (($this->_cacheVars['flag'] & self::CHBM_FORMKEY_REPLACED) != 0) && strpos($responseBody, self::FORMKEY_REPLACE) ) {
627
  // use single quote for pagespeed module
628
  $replace = '<' . $esiIncludeTag . " src='" . $this->getEsiBaseUrl() . "litemage/esi/getFormKey' as-var='1' combine='sub' cache-control='no-vary,private' cache-tag='E.formkey'/>" ;
629
  $responseBody = str_replace(self::FORMKEY_REPLACE, $replace, $responseBody) ;
630
+ if ($debug) {
631
+ $this->_config->debugMesg('FormKey replaced as ' . $replace, $debug);
632
  }
633
  $updated = true ;
634
  }
637
  // use single quote for pagespeed module
638
  $replace = '<' . $esiIncludeTag . " src='" . $this->getEsiBaseUrl() . "litemage/esi/getNickName' combine='sub' cache-control='no-vary,private' cache-tag='E.welcome'/>" ;
639
  $responseBody = str_replace(self::NICKNAME_REPLACE, $replace, $responseBody) ;
640
+ if ($debug) {
641
+ $this->_config->debugMesg('Nickname replaced as ' . $replace, $debug);
642
  }
643
  $updated = true ;
644
  }
650
  // if response coming from backend, no need to send separate log request
651
  $tracker = '<' . $esiIncludeTag . ' src="' . $this->_getSubReqUrl('litemage/esi/log', $logOptions)
652
  . '" test="$(RESP_HEADER{X-LITESPEED-CACHE})!=\'hit,litemage\'" cache-control="no-cache" combine="sub"/>' ;
653
+ if ($debug) {
654
+ $this->_config->debugMesg('Track recently viewed as ' . $tracker, $debug);
655
  }
656
  $updated = true ;
657
  }
663
  if ( ($this->_cacheVars['flag'] & self::CHBM_ESI_ON) != 0 ) {
664
  // no need to use comment, will be removed by minify extensions
665
  $combined = '<' . $esiIncludeTag . ' src="' . $this->_getSubReqUrl('litemage/esi/getCombined', $sharedParams) . '" combine="main2" cache-control="no-cache"/>' ;
666
+ if ($debug) {
667
+ $this->_config->debugMesg('_updateResponseBody combined is ' . $combined, $debug);
668
  }
669
  $updated = true;
670
  }
690
  $responseBody);
691
  }
692
  $response->setBody($combined . $tracker . $responseBody) ;
693
+ if ($debug && !$isAjax) {
694
+ $this->_config->debugMesg('_updateResponseBody failed to insert combined after <body>', $debug);
695
  }
696
  }
697
  }
719
  }
720
 
721
  $debugMesg = $this->_autoCollectUrls($curStoreId, $tags);
722
+ if (($this->_isDebug > Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_AUTOCOLLECT)
723
+ && $debugMesg) {
724
+ $this->_config->debugMesg('_autoCollectUrls: ' . $debugMesg,
725
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_AUTOCOLLECT);
726
  }
727
  }
728
  if ($isPublic) {
1020
  $this->_config->saveInternalCache(serialize($data), $cacheId) ;
1021
  }
1022
 
1023
+ if ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_DELTAQ) {
1024
  if ($updated == 0)
1025
  $msg = 'Delta tags not added, already in pending list';
1026
  elseif ($updated == 1)
1028
  else
1029
  $msg = 'Delta queue [time=' . $data['time'] . '] appended tag ' . implode(',', $extra);
1030
 
1031
+ $this->_config->debugMesg($msg, Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_DELTAQ) ;
1032
  }
1033
  }
1034
 
1080
  if ($oldVal != $newVal) {
1081
  Mage::getSingleton('core/cookie')->set($name, $newVal);
1082
  $changed = true;
1083
+ if ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_ENVCOOKIE)
1084
+ $this->_config->debugMesg('Env ' . $name . ' changed, old=' . $oldVal . ' new=' . $newVal,
1085
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_ENVCOOKIE) ;
1086
  }
1087
  }
1088
  return $changed;
1231
  $this->_cacheVars['cookie'][$cookieName][$cv[$i]] = $cv[$i+1];
1232
  }
1233
  }
1234
+ else if ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_SAFEIGNORE) {
1235
+ $this->_config->debugMesg('Env Cookie value parse error ' . $cookieName . ' = ' . $cookieVal,
1236
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_SAFEIGNORE) ;
1237
  }
1238
 
1239
  $this->_cacheVars['cookie'][$cookieName]['_ORG_'] = $cookieVal ;
app/code/community/Litespeed/Litemage/Helper/Viewvary.php CHANGED
@@ -96,7 +96,7 @@ class Litespeed_Litemage_Helper_Viewvary
96
 
97
  if ( $isSave ) {
98
  $saved = false ;
99
- $mesg = 'addEnv ' . $cookieName;
100
  foreach ( $keys as $key ) {
101
  if ( $value = $session->getData($key) ) {
102
  // only save limit_page if mode is same
@@ -119,8 +119,8 @@ class Litespeed_Litemage_Helper_Viewvary
119
  $helper->addEnvVars($cookieName) ;
120
  }
121
 
122
- if ( $isDebug ) {
123
- Mage::helper('litemage/data')->debugMesg($mesg) ;
124
  }
125
 
126
  }
96
 
97
  if ( $isSave ) {
98
  $saved = false ;
99
+ $mesg = 'Add Env ' . $cookieName;
100
  foreach ( $keys as $key ) {
101
  if ( $value = $session->getData($key) ) {
102
  // only save limit_page if mode is same
119
  $helper->addEnvVars($cookieName) ;
120
  }
121
 
122
+ if ( $isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_ENVCOOKIE) {
123
+ Mage::helper('litemage/data')->debugMesg($mesg, Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_ENVCOOKIE) ;
124
  }
125
 
126
  }
app/code/community/Litespeed/Litemage/Model/EsiData.php CHANGED
@@ -310,7 +310,9 @@ class Litespeed_Litemage_Model_EsiData
310
  Mage::dispatchEvent('catalog_controller_product_view', array( 'product' => $product )) ;
311
  } catch ( Exception $e ) {
312
  if ( $this->_isDebug ) {
313
- $this->_config->debugMesg('_logData, exception for product ' . $product->getId() . ' : ' . $e->getMessage()) ;
 
 
314
  }
315
  }
316
  }
310
  Mage::dispatchEvent('catalog_controller_product_view', array( 'product' => $product )) ;
311
  } catch ( Exception $e ) {
312
  if ( $this->_isDebug ) {
313
+ $this->_config->debugMesg('_logData, exception for product '
314
+ . $product->getId() . ' : ' . $e->getMessage(),
315
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_EXCEPTION) ;
316
  }
317
  }
318
  }
app/code/community/Litespeed/Litemage/Model/Layout/EsiUpdate.php CHANGED
@@ -32,7 +32,7 @@ class Litespeed_Litemage_Model_Layout_EsiUpdate extends Mage_Core_Model_Layout_U
32
  public function setCachePrefix($unique)
33
  {
34
  $this->_cachePrefix = 'LAYOUT_ESI_' . $unique . '_';
35
- $this->_isDebug = Mage::helper('litemage/data')->isDebug() ;
36
  }
37
 
38
  public function init($handles)
@@ -54,7 +54,8 @@ class Litespeed_Litemage_Model_Layout_EsiUpdate extends Mage_Core_Model_Layout_U
54
  $tags = $this->getHandles();
55
  $this->_cacheId = $this->_cachePrefix . md5(join('__', $tags));
56
  if ($this->_isDebug) {
57
- Mage::helper('litemage/data')->debugMesg('LU_Load H=' . join(',',$tags) . ' ID=' . substr($this->_cacheId, 7));
 
58
  }
59
 
60
  }
32
  public function setCachePrefix($unique)
33
  {
34
  $this->_cachePrefix = 'LAYOUT_ESI_' . $unique . '_';
35
+ $this->_isDebug = Mage::helper('litemage/data')->isDebug(Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_LAYOUTUPDATE) ;
36
  }
37
 
38
  public function init($handles)
54
  $tags = $this->getHandles();
55
  $this->_cacheId = $this->_cachePrefix . md5(join('__', $tags));
56
  if ($this->_isDebug) {
57
+ Mage::helper('litemage/data')->debugMesg('LU_Load H=' . join(',',$tags) . ' ID=' . substr($this->_cacheId, 7),
58
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_LAYOUTUPDATE);
59
  }
60
 
61
  }
app/code/community/Litespeed/Litemage/Model/Layout/Master.php CHANGED
@@ -37,7 +37,10 @@ class Litespeed_Litemage_Model_Layout_Master
37
  {
38
  $design = Mage::getSingleton('core/design_package') ;
39
  if ( $design->getArea() != 'frontend' ) {
40
- throw Mage::exception('Litespeed_Litemage_Model_Layout_Master should only be used for frontend') ;
 
 
 
41
  }
42
 
43
  $this->_cacheTags = array( Mage_Core_Model_Layout_Update::LAYOUT_GENERAL_CACHE_TAG ) ;
37
  {
38
  $design = Mage::getSingleton('core/design_package') ;
39
  if ( $design->getArea() != 'frontend' ) {
40
+ $errmsg = 'Litespeed_Litemage_Model_Layout_Master should only be used for frontend';
41
+ Mage::helper('litemage/data')->debugMesg($errmsg,
42
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_EXCEPTION);
43
+ throw Mage::exception($errmsg) ;
44
  }
45
 
46
  $this->_cacheTags = array( Mage_Core_Model_Layout_Update::LAYOUT_GENERAL_CACHE_TAG ) ;
app/code/community/Litespeed/Litemage/Model/Layout/Update.php CHANGED
@@ -41,11 +41,11 @@ class Litespeed_Litemage_Model_Layout_Update extends Mage_Core_Model_Layout_Upda
41
 
42
  public function __construct()
43
  {
44
- if ( Mage::getSingleton('core/design_package')->getArea() == 'frontend' && Mage::helper('litemage/data')->moduleEnabled() ) {
45
- $this->_modified = true ;
46
- $this->_layoutMaster = Mage::getSingleton('litemage/layout_master') ;
47
- $this->_resetInternals() ;
48
- $this->_isDebug = Mage::helper('litemage/data')->isDebug() ;
49
  }
50
  parent::__construct() ;
51
  }
@@ -58,6 +58,19 @@ class Litespeed_Litemage_Model_Layout_Update extends Mage_Core_Model_Layout_Upda
58
  return parent::resetHandles() ;
59
  }
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  protected function _resetInternals()
62
  {
63
  $this->_cacheId = null ;
@@ -71,7 +84,8 @@ class Litespeed_Litemage_Model_Layout_Update extends Mage_Core_Model_Layout_Upda
71
  {
72
  if ( !$this->_modified ) {
73
  if ( $this->_isDebug ) {
74
- Mage::helper('litemage/data')->debugMesg('LayoutUpdate SHOULD NOT GET HERE getUsedHandles');
 
75
  }
76
  }
77
 
@@ -164,8 +178,9 @@ class Litespeed_Litemage_Model_Layout_Update extends Mage_Core_Model_Layout_Upda
164
  {
165
  if ( $this->_modified ) {
166
  $this->_resetInternals() ;
167
- if ( $this->_isDebug ) {
168
- Mage::helper('litemage/data')->debugMesg('LayoutUpdate CONTAINS setCacheId ' . $cacheId) ;
 
169
  }
170
  }
171
  return parent::setCacheId($cacheId) ;
@@ -202,10 +217,11 @@ class Litespeed_Litemage_Model_Layout_Update extends Mage_Core_Model_Layout_Upda
202
  return false ;
203
  }
204
  }
205
- if ( $this->_isDebug ) {
206
  Mage::helper('litemage/data')->debugMesg('Layout cache loaded '
207
  . implode(':', array_keys($this->_handleUpdates))
208
- . ' ' . substr($this->_cacheId, 8, 12)) ;
 
209
  }
210
  parent::addUpdate(implode('', $this->_handleUpdates)) ;
211
 
@@ -244,10 +260,11 @@ class Litespeed_Litemage_Model_Layout_Update extends Mage_Core_Model_Layout_Upda
244
  else {
245
  $res = Mage::app()->saveCache(serialize($this->_handleUpdates), $this->getCacheId(), $tags, null) ;
246
  }
247
- if ( $this->_isDebug ) {
248
  Mage::helper('litemage/data')->debugMesg('Layout cache saved '
249
  . implode(':', array_keys($this->_handleUpdates))
250
- . ' ' . substr($this->_cacheId, 8, 12)) ;
 
251
  }
252
 
253
  foreach ( $this->_handleUpdates as $h => $update ) {
@@ -263,7 +280,9 @@ class Litespeed_Litemage_Model_Layout_Update extends Mage_Core_Model_Layout_Upda
263
  {
264
  if ( !$this->_modified ) {
265
  if ( $this->_isDebug ) {
266
- Mage::helper('litemage/data')->debugMesg('LayoutUpdate SHOULD NOT COME HERE ' . implode(',', $blockNameList));
 
 
267
  }
268
  }
269
  if ( $this->_handleXml == null ) {
41
 
42
  public function __construct()
43
  {
44
+ if ( Mage::getSingleton('core/design_package')->getArea() == 'frontend' ) {
45
+ $this->_isDebug = Mage::helper('litemage/data')->isDebug() ;
46
+ $this->_modified = true ;
47
+ $this->_layoutMaster = Mage::getSingleton('litemage/layout_master') ;
48
+ $this->_resetInternals() ;
49
  }
50
  parent::__construct() ;
51
  }
58
  return parent::resetHandles() ;
59
  }
60
 
61
+ public function setNoModify()
62
+ {
63
+ if ( $this->_modified ) {
64
+ $this->_resetInternals() ;
65
+ $this->_modified = false;
66
+ if ( $this->_isDebug) {
67
+ Mage::helper('litemage/data')->debugMesg('LayoutUpdate override disabled',
68
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_LAYOUTUPDATE);
69
+ }
70
+
71
+ }
72
+ }
73
+
74
  protected function _resetInternals()
75
  {
76
  $this->_cacheId = null ;
84
  {
85
  if ( !$this->_modified ) {
86
  if ( $this->_isDebug ) {
87
+ Mage::helper('litemage/data')->debugMesg('LayoutUpdate SHOULD NOT GET HERE getUsedHandles',
88
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_EXCEPTION);
89
  }
90
  }
91
 
178
  {
179
  if ( $this->_modified ) {
180
  $this->_resetInternals() ;
181
+ if ( $this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_SAFEIGNORE) {
182
+ Mage::helper('litemage/data')->debugMesg('LayoutUpdate CONTAINS setCacheId ' . $cacheId,
183
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_SAFEIGNORE) ;
184
  }
185
  }
186
  return parent::setCacheId($cacheId) ;
217
  return false ;
218
  }
219
  }
220
+ if ( $this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_LAYOUTUPDATE) {
221
  Mage::helper('litemage/data')->debugMesg('Layout cache loaded '
222
  . implode(':', array_keys($this->_handleUpdates))
223
+ . ' ' . substr($this->_cacheId, 8, 12),
224
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_LAYOUTUPDATE) ;
225
  }
226
  parent::addUpdate(implode('', $this->_handleUpdates)) ;
227
 
260
  else {
261
  $res = Mage::app()->saveCache(serialize($this->_handleUpdates), $this->getCacheId(), $tags, null) ;
262
  }
263
+ if ( $this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_LAYOUTUPDATE) {
264
  Mage::helper('litemage/data')->debugMesg('Layout cache saved '
265
  . implode(':', array_keys($this->_handleUpdates))
266
+ . ' ' . substr($this->_cacheId, 8, 12),
267
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_LAYOUTUPDATE) ;
268
  }
269
 
270
  foreach ( $this->_handleUpdates as $h => $update ) {
280
  {
281
  if ( !$this->_modified ) {
282
  if ( $this->_isDebug ) {
283
+ Mage::helper('litemage/data')->debugMesg('LayoutUpdate SHOULD NOT COME HERE '
284
+ . implode(',', $blockNameList),
285
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_EXCEPTION);
286
  }
287
  }
288
  if ( $this->_handleXml == null ) {
app/code/community/Litespeed/Litemage/Model/Observer/Cron.php CHANGED
@@ -28,14 +28,13 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
28
  const WARMUP_MAP_FILE = 'litemage_warmup_urlmap' ;
29
  const WARMUP_META_CACHE_ID = 'litemage_warmup_meta' ;
30
  const DELTA_META_CACHE_ID = 'litemage_delta_meta' ;
31
- const USER_AGENT = 'litemage_walker' ;
32
- const FAST_USER_AGENT = 'litemage_runner' ;
33
  const ENV_COOKIE_NAME = '_lscache_vary' ;
 
34
 
35
  protected $_meta ; // time, curfileline
36
  protected $_conf ;
37
  protected $_helper ;
38
- protected $_isDebug ;
39
  protected $_isDelta;
40
  protected $_debugTag ;
41
  protected $_maxRunTime ;
@@ -49,14 +48,11 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
49
  protected function _construct()
50
  {
51
  $this->_helper = Mage::helper('litemage/data') ;
52
- $this->_isDebug = $this->_helper->isDebug() ;
53
  $this->_listDir = $this->_helper->getCrawlerListDir() ;
54
 
55
  $this->_conf = $this->_helper->getWarmUpConf() ;
56
- if ($this->_conf[Litespeed_Litemage_Helper_Data::CFG_WARMUP_DELTA_LOG]) {
57
- $this->_isDebug |= 2;
58
- }
59
- if ( $this->_isDebug ) {
60
  $this->_debugTag = 'LiteMage [cron:' ;
61
  if ( isset($_SERVER['USER']) )
62
  $this->_debugTag .= $_SERVER['USER'] ;
@@ -155,7 +151,7 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
155
  $disp['lastendtime'] = ($store_stat['lastendtime'] > 0) ? date($timefmt, $store_stat['lastendtime']) : ' ' ;
156
  $disp['listsize'] = ($store_stat['listsize'] > 0) ? $store_stat['listsize'] : 'N/A' ;
157
  $disp['curpos'] = $store_stat['curpos'] ;
158
- $disp['env'] = str_replace(',', ', ', $store_stat['env']) ;
159
  $disp['curvary'] = preg_replace("/_lscache_vary=.+;/", '', $store_stat['curvary']) ;
160
  }
161
  $disp['lastquerytime'] = ($store_stat['lastquerytime'] > 0) ? date($timefmt, $store_stat['lastquerytime']) : 'N/A' ;
@@ -189,7 +185,7 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
189
  if ( $errmsg = $this->_init() ) {
190
  $this->_meta['endreason'] = 'Skipped this round - ' . $errmsg ;
191
  $this->_saveMeta() ;
192
- $this->_debugLog('Cron ' . ($isDelta ? 'warmDelta' : 'warmCache' ) . ' skip this round - ' . $errmsg) ;
193
  return;
194
  }
195
 
@@ -198,25 +194,33 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
198
  CURLOPT_SSL_VERIFYHOST => 0,
199
  CURLOPT_TIMEOUT => 180
200
  ) ;
 
 
 
201
 
202
  $server_ip = $this->_conf[Litespeed_Litemage_Helper_Data::CFG_WARMUP_SERVER_IP] ;
203
 
204
  $client = new Varien_Http_Adapter_Curl() ;
205
  $curCookie = '' ;
 
206
  $endReason = '' ;
207
  $pattern = "/:\/\/([^\/^:]+)(\/|:)?/";
208
 
209
- while ( $urls = $this->_getNextUrls($curCookie) ) {
210
  $curlOptions = $options ;
211
  if ( $curCookie ) {
212
  $curlOptions[CURLOPT_COOKIE] = $curCookie ;
213
  }
214
  $id = $this->_curList['id'] ;
215
- $ua = isset($this->_meta[$id]['ua']) ? $this->_meta[$id]['ua'] : self::FAST_USER_AGENT ;
216
  $curlOptions[CURLOPT_USERAGENT] = $ua ;
217
 
218
- if ( $this->_isDebug ) {
219
- $this->_debugLog($ua . ' crawling ' . $server_ip . ' ' . $id . ' urls (cur_pos:' . $this->_meta[$id]['curpos'] . ') with cookie ' . $curCookie . ' ' . print_r($urls, true)) ;
 
 
 
 
220
  }
221
 
222
  $regular = array();
@@ -231,8 +235,8 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
231
  $curlOptions[CURLOPT_HTTPHEADER][] = "Host: $domain";
232
  }
233
  else {
234
- if ( $this->_isDebug ) {
235
- $this->_debugLog('invalid url ' . $url);
236
  }
237
  continue;
238
  }
@@ -249,17 +253,26 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
249
  try {
250
  if (count($regular)) {
251
  $client->multiRequest($regular, $curlOptions) ;
 
 
 
 
 
252
  }
253
  if (count($ajax)) {
254
  $curlOptions[CURLOPT_HTTPHEADER][] = 'X-Requested-With: XMLHttpRequest';
255
  $client->multiRequest($ajax, $curlOptions) ;
 
 
 
 
256
  }
257
  } catch ( Exception $e ) {
258
  $endReason = 'Error when crawling url ' . implode(' ', $urls) . ' : ' . $e->getMessage() ;
259
  break ;
260
  }
261
 
262
- $this->_finishCurPosition() ;
263
 
264
  if ( $this->_meta['lastupdate'] > $this->_maxRunTime ) {
265
  $endReason = Mage::helper('litemage/data')->__('Stopped due to exceeding defined Maximum Run Time.') ;
@@ -273,13 +286,14 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
273
  break ;
274
  }
275
  }
 
276
  usleep(500) ;
277
  }
278
  $this->_meta['endreason'] = $endReason ;
279
 
280
  $this->_saveMeta() ;
281
- if ( $this->_isDebug ) {
282
- $this->_debugLog($endReason . ' cron meta end = ' . print_r($this->_meta, true)) ;
283
  }
284
  }
285
 
@@ -310,15 +324,15 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
310
  . $this->_meta[$listId]['listsize'] . "\t"
311
  . $this->_meta[$listId]['env'] . "\n" ;
312
 
313
- if ( $this->_isDebug ) {
314
- $this->_debugLog('Generate url map for ' . $listId . ' url count=' . $this->_meta[$listId]['listsize']) ;
315
  }
316
 
317
  $buf = $header . implode("\n", $urls) ;
318
 
319
  $filename = $this->_listDir . DS . self::WARMUP_MAP_FILE . '_' . strtolower($listId) ;
320
  if ( ! file_put_contents($filename, $buf) ) {
321
- $this->_debugLog('Failed to save url map file ' . $filename) ;
322
  }
323
  else {
324
  chmod($filename, 0644) ;
@@ -358,8 +372,8 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
358
  == $header[2]) && count($allurls) == $m['listsize'] ) {
359
  $this->_curList['urls'] = $allurls ;
360
  }
361
- else if ( $this->_isDebug ) {
362
- $this->_debugLog('load saved url list, header does not match, will regenerate') ;
363
  }
364
  }
365
 
@@ -381,8 +395,8 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
381
  // reset current pointer
382
  $m['curvary'] = $vary[0] ;
383
  $m['curpos'] = 0 ;
384
- if ( $this->_isDebug ) {
385
- $this->_debugLog('Reset current position pointer to 0. curvary is ' . $m['curvary']) ;
386
  }
387
  }
388
 
@@ -463,8 +477,8 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
463
  // reset current pointer
464
  $m['curvary'] = $vary[0] ;
465
  $m['curpos'] = 0 ;
466
- if ( $this->_isDebug ) {
467
- $this->_debugLog('Reset current position pointer to 0. curvary is ' . $m['curvary']) ;
468
  }
469
  }
470
 
@@ -475,98 +489,103 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
475
  $this->_curList = array(
476
  'id' => 'delta', 'fixed' => $fixed, 'vary' => $vary, 'working' => 0, 'urls' => $urls ) ;
477
 
478
- if ( $this->_isDebug ) {
479
- $this->_debugLog('current delta list for tag ' . $m['curtag'] . ' ' . print_r($this->_curList, true)) ;
480
  }
481
  return true ;
482
  }
483
 
484
- protected function _parseEnvCookies( $env, &$vary )
485
- {
486
- $fixed = '' ;
487
- if ( $env ) {
488
- $lsvary = array() ;
489
- $multiCurr = array( '-' ) ; // default currency
490
- $multiCgrp = array( '-' ) ; // default user group
491
-
492
- $env = trim($env, '/') ;
493
- $envs = explode('/', $env) ;
494
- $envVars = array() ;
495
- $cnt = count($envs) ;
496
- for ( $i = 0 ; ($i + 1) < $cnt ; $i+=2 ) {
497
- $envVars[$envs[$i]] = $envs[$i + 1] ;
498
- }
499
- if ( isset($envVars['vary_dev']) ) {
500
- $lsvary['dev'] = 1 ;
501
- }
502
-
503
- if ( isset($envVars['store']) ) {
504
- $fixed .= Mage_Core_Model_Store::COOKIE_NAME . '=' . $envVars['store'] . ';' ;
505
- $lsvary['st'] = $envVars['storeId'] ;
506
- }
507
-
508
- if ( isset($envVars['vary_cgrp']) ) {
509
- $multiCgrp = explode(',', $envVars['vary_cgrp']) ;
510
- }
511
-
512
- if ( isset($envVars['vary_curr']) ) {
513
- $multiCurr = explode(',', $envVars['vary_curr']) ;
514
- }
515
-
516
- foreach ( $multiCurr as $currency ) {
517
- $cookie_vary = '' ;
518
- $lsvary1 = $lsvary ;
519
-
520
- if ( $currency != '-' ) {
521
- $lsvary1['curr'] = $currency ;
522
- $cookie_vary .= Mage_Core_Model_Store::COOKIE_CURRENCY . '=' . $currency . ';' ;
523
- }
524
-
525
- foreach ( $multiCgrp as $cgrp ) {
526
-
527
- $cookie_vary2 = $cookie_vary;
528
- $lsvary2 = $lsvary1;
529
-
530
- if ( $cgrp != '-' ) {
531
- // need to set user id, group_userid
532
- if ($pos = strpos($cgrp, '_')) {
533
- $group = substr($cgrp, 0, $pos);
534
- $customerId = substr($cgrp, $pos+1);
535
- if ($group == 'review') {
536
- $cookie_vary2 .= '_lscache_vary_review=write%7E1%7E;' ;
537
- }
538
- else {
539
- $lsvary2['cgrp'] = $group ;
540
- }
541
- $cookie_vary2 .= 'lmcron_customer=' . $customerId . ';' ;
542
- }
543
- }
544
-
545
- if ( ! empty($lsvary2) ) {
546
- ksort($lsvary2) ;
547
- $lsvary2_val = '' ;
548
- foreach ( $lsvary2 as $k => $v ) {
549
- $lsvary2_val .= $k . '%7E' . urlencode($v) . '%7E' ; // %7E is "~"
550
- }
551
- $cookie_vary2 .= self::ENV_COOKIE_NAME . '=' . $lsvary2_val . ';' ;
552
- }
553
- $vary[] = $cookie_vary2 ; // can be empty string for default no vary
554
- }
555
- }
556
- }
557
- else {
558
- $vary[] = '' ; // no vary
559
- }
560
- return $fixed ;
561
- }
562
-
563
- protected function _getNextUrls( &$curCookie )
 
 
 
 
 
564
  {
565
  $this->_curList['working'] = 0 ;
566
  $id = $this->_curList['id'] ;
567
  if ( $this->_meta[$id]['endtime'] > 0 ) {
568
  if ( $this->_prepareCurList() ) {
569
- return $this->_getNextUrls($curCookie) ;
570
  }
571
  else {
572
  return null ;
@@ -575,6 +594,7 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
575
  $isAutoList = ($id{0} == 'a');
576
  $curpos = $this->_meta[$id]['curpos'] ;
577
  $curCookie = $this->_curList['fixed'] . $this->_meta[$id]['curvary'] ;
 
578
 
579
  if ($isAutoList) {
580
  // {tag}:url
@@ -606,7 +626,7 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
606
  }
607
  if ($curtag) {
608
  //'litemage_cron=' . $id . ':' . $m['curtag'] . ';' ;
609
- $replace = '$1' . ':' . $curtag . ';';
610
  $curCookie = preg_replace('/(litemage_cron=[^;]+);/', $replace, $curCookie);
611
  }
612
  }
@@ -633,7 +653,7 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
633
  }
634
  }
635
 
636
- protected function _finishCurPosition()
637
  {
638
  $now = time() ;
639
  $id = $this->_curList['id'] ;
@@ -651,7 +671,7 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
651
  $this->_meta[$id]['curpos'] = $this->_meta[$id]['listsize'] ;
652
  }
653
  }
654
- $this->_meta[$id]['queried'] += $this->_curList['working'] ;
655
  $this->_meta[$id]['lastquerytime'] = $now ;
656
  $this->_meta['lastupdate'] = $now ;
657
  $this->_curList['working'] = 0 ;
@@ -672,7 +692,8 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
672
  'gentime' => 0,
673
  'listsize' => 0,
674
  'env' => $storeInfo['env'],
675
- 'ua' => self::FAST_USER_AGENT,
 
676
  'curpos' => 0,
677
  'curvary' => '',
678
  'queried' => 0,
@@ -702,7 +723,7 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
702
  'priority' => 0,
703
  'gentime' => $now,
704
  'listsize' => 0,
705
- 'ua' => self::FAST_USER_AGENT,
706
  'curtag' => $curtag,
707
  'pending' => 0,
708
  'curlist' => '',
@@ -782,9 +803,11 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
782
  if ( isset($saved[$listId]) ) {
783
  // validate saved
784
  $m = $saved[$listId] ;
785
- if ( isset($m['storeid']) && ($m['storeid'] == $info['storeid']) && isset($m['env'])
786
- && ($m['env'] == $info['env']) && isset($m['interval']) && ($m['interval']
787
- == $info['interval']) && isset($m['priority']) && ($m['priority'] == $info['priority'])
 
 
788
  && isset($m['baseurl']) && ($m['baseurl'] == $info['baseurl']) ) {
789
 
790
  if ( $m['gentime'] == 0 ) {
@@ -804,7 +827,7 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
804
  elseif ( ($m['endtime'] + $m['interval'] < $curtime ) ) {
805
  // expired
806
  $expired[$listId] = $m['priority'] ;
807
- $m['ua'] = self::USER_AGENT ;
808
  $tmpmsg = 'Run interval passed, will restart.' ;
809
  }
810
  else {
@@ -825,7 +848,7 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
825
  }
826
  else {
827
  $expired[$listId] = $m['priority'] ;
828
- $m['ua'] = self::USER_AGENT ;
829
  }
830
  }
831
  }
@@ -928,8 +951,8 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
928
  }
929
  }
930
 
931
- if ( $this->_isDebug ) {
932
- $this->_debugLog('No urls saved for current delta tag ' . $tag . ' - bypass') ;
933
  }
934
  }
935
 
@@ -955,6 +978,12 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
955
  if ( empty($this->_priority) ) {
956
  return 'no URL list scheduled for warm up' ;
957
  }
 
 
 
 
 
 
958
 
959
  $maxTime = (int) ini_get('max_execution_time') ;
960
  if ( $maxTime == 0 )
@@ -1026,8 +1055,8 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
1026
  }
1027
 
1028
 
1029
- if ( $this->_isDebug ) {
1030
- $this->_debugLog('set current threads = ' . $curthreads . ' previous=' . $this->_curThreads
1031
  . ' max_allowed=' . $max . ' load_limit=' . $limit . ' current_load=' . $curload) ;
1032
  }
1033
 
@@ -1134,8 +1163,8 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
1134
  $lines = file($custlist, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ;
1135
  $urls = array() ;
1136
  if ( $lines === false ) {
1137
- if ( $this->_isDebug ) {
1138
- $this->_debugLog('Fail to read custom URL list file ' . $custlist) ;
1139
  }
1140
  }
1141
  else if ( ! empty($lines) ) {
@@ -1306,7 +1335,7 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
1306
  }
1307
  }
1308
  if ( ! file_put_contents($file, serialize($list)) ) {
1309
- $this->_debugLog('Failed to save AUTO list ' . $file) ;
1310
  }
1311
  else {
1312
  chmod($file, 0644) ;
@@ -1315,17 +1344,12 @@ class Litespeed_Litemage_Model_Observer_Cron extends Varien_Event_Observer
1315
  return $list;
1316
  }
1317
 
1318
- protected function _debugLog( $message, $level = 0 )
1319
  {
1320
- if ( $this->_isDebug ) {
1321
  $message = $this->_debugTag . ' ' . str_replace("\n", ("\n" . $this->_debugTag . ' '), $message) ;
1322
- if (($this->_isDebug & 1) == 1) {
1323
- Mage::log($message) ;
1324
- }
1325
- if ($this->_isDelta && (($this->_isDebug & 2) == 2)) {
1326
- //($message, $level = null, $file = '', $forceLog = false)
1327
- Mage::log($message, null, 'lmdelta.log', true) ;
1328
- }
1329
  }
1330
  }
1331
 
28
  const WARMUP_MAP_FILE = 'litemage_warmup_urlmap' ;
29
  const WARMUP_META_CACHE_ID = 'litemage_warmup_meta' ;
30
  const DELTA_META_CACHE_ID = 'litemage_delta_meta' ;
 
 
31
  const ENV_COOKIE_NAME = '_lscache_vary' ;
32
+ const RUNNING_MESG = 'Currently running with pid ';
33
 
34
  protected $_meta ; // time, curfileline
35
  protected $_conf ;
36
  protected $_helper ;
37
+ protected $_logEnabled ;
38
  protected $_isDelta;
39
  protected $_debugTag ;
40
  protected $_maxRunTime ;
48
  protected function _construct()
49
  {
50
  $this->_helper = Mage::helper('litemage/data') ;
 
51
  $this->_listDir = $this->_helper->getCrawlerListDir() ;
52
 
53
  $this->_conf = $this->_helper->getWarmUpConf() ;
54
+ $this->_logEnabled = $this->_conf[Litespeed_Litemage_Helper_Data::CFG_WARMUP_CRAWLER_LOG];
55
+ if ( $this->_logEnabled ) {
 
 
56
  $this->_debugTag = 'LiteMage [cron:' ;
57
  if ( isset($_SERVER['USER']) )
58
  $this->_debugTag .= $_SERVER['USER'] ;
151
  $disp['lastendtime'] = ($store_stat['lastendtime'] > 0) ? date($timefmt, $store_stat['lastendtime']) : ' ' ;
152
  $disp['listsize'] = ($store_stat['listsize'] > 0) ? $store_stat['listsize'] : 'N/A' ;
153
  $disp['curpos'] = $store_stat['curpos'] ;
154
+ $disp['env'] = str_replace(',', ', ', $store_stat['env']) . ($store_stat['crawl_mobile'] ? ' (with mobile view)' : '');
155
  $disp['curvary'] = preg_replace("/_lscache_vary=.+;/", '', $store_stat['curvary']) ;
156
  }
157
  $disp['lastquerytime'] = ($store_stat['lastquerytime'] > 0) ? date($timefmt, $store_stat['lastquerytime']) : 'N/A' ;
185
  if ( $errmsg = $this->_init() ) {
186
  $this->_meta['endreason'] = 'Skipped this round - ' . $errmsg ;
187
  $this->_saveMeta() ;
188
+ $this->_log('Cron ' . ($isDelta ? 'warmDelta' : 'warmCache' ) . ' skip this round - ' . $errmsg) ;
189
  return;
190
  }
191
 
194
  CURLOPT_SSL_VERIFYHOST => 0,
195
  CURLOPT_TIMEOUT => 180
196
  ) ;
197
+
198
+ $mypid = getmypid();
199
+ $this->_meta['endreason'] = self::RUNNING_MESG . $mypid ; // hard coded string, will be compared later
200
 
201
  $server_ip = $this->_conf[Litespeed_Litemage_Helper_Data::CFG_WARMUP_SERVER_IP] ;
202
 
203
  $client = new Varien_Http_Adapter_Curl() ;
204
  $curCookie = '' ;
205
+ $addMobileView = false;
206
  $endReason = '' ;
207
  $pattern = "/:\/\/([^\/^:]+)(\/|:)?/";
208
 
209
+ while ( $urls = $this->_getNextUrls($curCookie, $addMobileView) ) {
210
  $curlOptions = $options ;
211
  if ( $curCookie ) {
212
  $curlOptions[CURLOPT_COOKIE] = $curCookie ;
213
  }
214
  $id = $this->_curList['id'] ;
215
+ $ua = isset($this->_meta[$id]['ua']) ? $this->_meta[$id]['ua'] : Litespeed_Litemage_Helper_Data::LITEMAGE_FAST_USER_AGENT ;
216
  $curlOptions[CURLOPT_USERAGENT] = $ua ;
217
 
218
+ if ( $this->_logEnabled ) {
219
+ $this->_log($ua . ' crawling ' . $server_ip . ' ' . $id
220
+ . ' urls (cur_pos:' . $this->_meta[$id]['curpos']
221
+ . ') with cookie ' . $curCookie
222
+ . ($addMobileView ? ' add_mobile ' : ' ')
223
+ . print_r($urls, true)) ;
224
  }
225
 
226
  $regular = array();
235
  $curlOptions[CURLOPT_HTTPHEADER][] = "Host: $domain";
236
  }
237
  else {
238
+ if ( $this->_logEnabled ) {
239
+ $this->_log('invalid url ' . $url);
240
  }
241
  continue;
242
  }
253
  try {
254
  if (count($regular)) {
255
  $client->multiRequest($regular, $curlOptions) ;
256
+ if ($addMobileView) {
257
+ $mobileOptions = $curlOptions;
258
+ $mobileOptions[CURLOPT_USERAGENT] .= ' (iPhone)' ;
259
+ $client->multiRequest($regular, $mobileOptions) ;
260
+ }
261
  }
262
  if (count($ajax)) {
263
  $curlOptions[CURLOPT_HTTPHEADER][] = 'X-Requested-With: XMLHttpRequest';
264
  $client->multiRequest($ajax, $curlOptions) ;
265
+ if ($addMobileView) {
266
+ $curlOptions[CURLOPT_USERAGENT] .= ' (iPhone)' ;
267
+ $client->multiRequest($ajax, $curlOptions) ;
268
+ }
269
  }
270
  } catch ( Exception $e ) {
271
  $endReason = 'Error when crawling url ' . implode(' ', $urls) . ' : ' . $e->getMessage() ;
272
  break ;
273
  }
274
 
275
+ $this->_finishCurPosition($addMobileView) ;
276
 
277
  if ( $this->_meta['lastupdate'] > $this->_maxRunTime ) {
278
  $endReason = Mage::helper('litemage/data')->__('Stopped due to exceeding defined Maximum Run Time.') ;
286
  break ;
287
  }
288
  }
289
+ $this->_saveMeta() ;
290
  usleep(500) ;
291
  }
292
  $this->_meta['endreason'] = $endReason ;
293
 
294
  $this->_saveMeta() ;
295
+ if ( $this->_logEnabled ) {
296
+ $this->_log($endReason . ' cron meta end = ' . print_r($this->_meta, true)) ;
297
  }
298
  }
299
 
324
  . $this->_meta[$listId]['listsize'] . "\t"
325
  . $this->_meta[$listId]['env'] . "\n" ;
326
 
327
+ if ( $this->_logEnabled ) {
328
+ $this->_log('Generate url map for ' . $listId . ' url count=' . $this->_meta[$listId]['listsize']) ;
329
  }
330
 
331
  $buf = $header . implode("\n", $urls) ;
332
 
333
  $filename = $this->_listDir . DS . self::WARMUP_MAP_FILE . '_' . strtolower($listId) ;
334
  if ( ! file_put_contents($filename, $buf) ) {
335
+ $this->_log('Failed to save url map file ' . $filename) ;
336
  }
337
  else {
338
  chmod($filename, 0644) ;
372
  == $header[2]) && count($allurls) == $m['listsize'] ) {
373
  $this->_curList['urls'] = $allurls ;
374
  }
375
+ else if ( $this->_logEnabled ) {
376
+ $this->_log('load saved url list, header does not match, will regenerate') ;
377
  }
378
  }
379
 
395
  // reset current pointer
396
  $m['curvary'] = $vary[0] ;
397
  $m['curpos'] = 0 ;
398
+ if ( $this->_logEnabled ) {
399
+ $this->_log('Reset current position pointer to 0. curvary is ' . $m['curvary']) ;
400
  }
401
  }
402
 
477
  // reset current pointer
478
  $m['curvary'] = $vary[0] ;
479
  $m['curpos'] = 0 ;
480
+ if ( $this->_logEnabled ) {
481
+ $this->_log('Reset current position pointer to 0. curvary is ' . $m['curvary']) ;
482
  }
483
  }
484
 
489
  $this->_curList = array(
490
  'id' => 'delta', 'fixed' => $fixed, 'vary' => $vary, 'working' => 0, 'urls' => $urls ) ;
491
 
492
+ if ( $this->_logEnabled ) {
493
+ $this->_log('current delta list for tag ' . $m['curtag'] . ' ' . print_r($this->_curList, true)) ;
494
  }
495
  return true ;
496
  }
497
 
498
+ protected function _parseEnvCookies($env, &$vary)
499
+ {
500
+ if (!$env) {
501
+ $vary[] = ''; // no vary
502
+ return '';
503
+ }
504
+ $fixed = '';
505
+
506
+ $lsvary = array();
507
+ $multiCurr = array('-'); // default currency
508
+ $multiCgrp = array('-'); // default user group
509
+ $views = array('-'); // default desktop view
510
+
511
+ $env = trim($env, '/');
512
+ $envs = explode('/', $env);
513
+ $envVars = array();
514
+ $cnt = count($envs);
515
+ for ($i = 0; ($i + 1) < $cnt; $i+=2) {
516
+ $envVars[$envs[$i]] = $envs[$i + 1];
517
+ }
518
+ if (isset($envVars['vary_dev'])) {
519
+ $lsvary['dev'] = 1;
520
+ }
521
+
522
+ if (isset($envVars['store'])) {
523
+ $fixed .= Mage_Core_Model_Store::COOKIE_NAME . '=' . $envVars['store'] . ';';
524
+ $lsvary['st'] = $envVars['storeId'];
525
+ }
526
+
527
+ if (isset($envVars['vary_cgrp'])) {
528
+ $multiCgrp = explode(',', $envVars['vary_cgrp']);
529
+ }
530
+
531
+ if (isset($envVars['vary_mobile'])) {
532
+ $views = explode(',', $envVars['vary_mobile']);
533
+ }
534
+
535
+ if (isset($envVars['vary_curr'])) {
536
+ $multiCurr = explode(',', $envVars['vary_curr']);
537
+ }
538
+
539
+ foreach ($multiCurr as $currency) {
540
+ $cookie_vary = '';
541
+ $lsvary1 = $lsvary;
542
+
543
+ if ($currency != '-') {
544
+ $lsvary1['curr'] = $currency;
545
+ $cookie_vary .= Mage_Core_Model_Store::COOKIE_CURRENCY . '=' . $currency . ';';
546
+ }
547
+
548
+ foreach ($multiCgrp as $cgrp) {
549
+
550
+ $cookie_vary2 = $cookie_vary;
551
+ $lsvary2 = $lsvary1;
552
+
553
+ if ($cgrp != '-') {
554
+ // need to set user id, group_userid
555
+ if ($pos = strpos($cgrp, '_')) {
556
+ $group = substr($cgrp, 0, $pos);
557
+ $customerId = substr($cgrp, $pos + 1);
558
+ if ($group == 'review') {
559
+ $cookie_vary2 .= '_lscache_vary_review=write%7E1%7E;';
560
+ }
561
+ else {
562
+ $lsvary2['cgrp'] = $group;
563
+ }
564
+ $cookie_vary2 .= 'lmcron_customer=' . $customerId . ';';
565
+ }
566
+ }
567
+
568
+ if (!empty($lsvary2)) {
569
+ ksort($lsvary2);
570
+ $lsvary2_val = '';
571
+ foreach ($lsvary2 as $k => $v) {
572
+ $lsvary2_val .= $k . '%7E' . urlencode($v) . '%7E'; // %7E is "~"
573
+ }
574
+ $cookie_vary2 .= self::ENV_COOKIE_NAME . '=' . $lsvary2_val . ';';
575
+ }
576
+ $vary[] = $cookie_vary2; // can be empty string for default no vary
577
+ }
578
+ }
579
+ return $fixed;
580
+ }
581
+
582
+ protected function _getNextUrls( &$curCookie, &$addMobileView )
583
  {
584
  $this->_curList['working'] = 0 ;
585
  $id = $this->_curList['id'] ;
586
  if ( $this->_meta[$id]['endtime'] > 0 ) {
587
  if ( $this->_prepareCurList() ) {
588
+ return $this->_getNextUrls($curCookie, $addMobileView) ;
589
  }
590
  else {
591
  return null ;
594
  $isAutoList = ($id{0} == 'a');
595
  $curpos = $this->_meta[$id]['curpos'] ;
596
  $curCookie = $this->_curList['fixed'] . $this->_meta[$id]['curvary'] ;
597
+ $addMobileView = $this->_meta[$id]['crawl_mobile'] ;
598
 
599
  if ($isAutoList) {
600
  // {tag}:url
626
  }
627
  if ($curtag) {
628
  //'litemage_cron=' . $id . ':' . $m['curtag'] . ';' ;
629
+ $replace = '$1:' . $curtag . ';';
630
  $curCookie = preg_replace('/(litemage_cron=[^;]+);/', $replace, $curCookie);
631
  }
632
  }
653
  }
654
  }
655
 
656
+ protected function _finishCurPosition($addMobileView)
657
  {
658
  $now = time() ;
659
  $id = $this->_curList['id'] ;
671
  $this->_meta[$id]['curpos'] = $this->_meta[$id]['listsize'] ;
672
  }
673
  }
674
+ $this->_meta[$id]['queried'] += $addMobileView ? ($this->_curList['working'] * 2) : $this->_curList['working'];
675
  $this->_meta[$id]['lastquerytime'] = $now ;
676
  $this->_meta['lastupdate'] = $now ;
677
  $this->_curList['working'] = 0 ;
692
  'gentime' => 0,
693
  'listsize' => 0,
694
  'env' => $storeInfo['env'],
695
+ 'crawl_mobile' => $storeInfo['crawl_mobile'],
696
+ 'ua' => Litespeed_Litemage_Helper_Data::LITEMAGE_FAST_USER_AGENT,
697
  'curpos' => 0,
698
  'curvary' => '',
699
  'queried' => 0,
723
  'priority' => 0,
724
  'gentime' => $now,
725
  'listsize' => 0,
726
+ 'ua' => Litespeed_Litemage_Helper_Data::LITEMAGE_FAST_USER_AGENT,
727
  'curtag' => $curtag,
728
  'pending' => 0,
729
  'curlist' => '',
803
  if ( isset($saved[$listId]) ) {
804
  // validate saved
805
  $m = $saved[$listId] ;
806
+ if ( isset($m['storeid']) && ($m['storeid'] == $info['storeid'])
807
+ && isset($m['env']) && ($m['env'] == $info['env'])
808
+ && isset($m['crawl_mobile']) && ($m['crawl_mobile'] == $info['crawl_mobile'])
809
+ && isset($m['interval']) && ($m['interval'] == $info['interval'])
810
+ && isset($m['priority']) && ($m['priority'] == $info['priority'])
811
  && isset($m['baseurl']) && ($m['baseurl'] == $info['baseurl']) ) {
812
 
813
  if ( $m['gentime'] == 0 ) {
827
  elseif ( ($m['endtime'] + $m['interval'] < $curtime ) ) {
828
  // expired
829
  $expired[$listId] = $m['priority'] ;
830
+ $m['ua'] = Litespeed_Litemage_Helper_Data::LITEMAGE_USER_AGENT ;
831
  $tmpmsg = 'Run interval passed, will restart.' ;
832
  }
833
  else {
848
  }
849
  else {
850
  $expired[$listId] = $m['priority'] ;
851
+ $m['ua'] = Litespeed_Litemage_Helper_Data::LITEMAGE_USER_AGENT ;
852
  }
853
  }
854
  }
951
  }
952
  }
953
 
954
+ if ( $this->_logEnabled ) {
955
+ $this->_log('No urls saved for current delta tag ' . $tag . ' - bypass') ;
956
  }
957
  }
958
 
978
  if ( empty($this->_priority) ) {
979
  return 'no URL list scheduled for warm up' ;
980
  }
981
+
982
+ // to avoid another process running
983
+ if ( isset($this->_meta['endreason'])
984
+ && (strpos($this->_meta['endreason'], self::RUNNING_MESG) !== false)) {
985
+ return 'another process is ' . $this->_meta['endreason'] . '. You can click resetAll button if that process no longer exists.';
986
+ }
987
 
988
  $maxTime = (int) ini_get('max_execution_time') ;
989
  if ( $maxTime == 0 )
1055
  }
1056
 
1057
 
1058
+ if ( $this->_logEnabled ) {
1059
+ $this->_log('set current threads = ' . $curthreads . ' previous=' . $this->_curThreads
1060
  . ' max_allowed=' . $max . ' load_limit=' . $limit . ' current_load=' . $curload) ;
1061
  }
1062
 
1163
  $lines = file($custlist, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ;
1164
  $urls = array() ;
1165
  if ( $lines === false ) {
1166
+ if ( $this->_logEnabled ) {
1167
+ $this->_log('Fail to read custom URL list file ' . $custlist) ;
1168
  }
1169
  }
1170
  else if ( ! empty($lines) ) {
1335
  }
1336
  }
1337
  if ( ! file_put_contents($file, serialize($list)) ) {
1338
+ $this->_log('Failed to save AUTO list ' . $file) ;
1339
  }
1340
  else {
1341
  chmod($file, 0644) ;
1344
  return $list;
1345
  }
1346
 
1347
+ protected function _log( $message, $level = 0 )
1348
  {
1349
+ if ( $this->_logEnabled ) {
1350
  $message = $this->_debugTag . ' ' . str_replace("\n", ("\n" . $this->_debugTag . ' '), $message) ;
1351
+ //($message, $level = null, $file = '', $forceLog = false)
1352
+ Mage::log($message, null, 'litemage_crawler.log', true) ;
 
 
 
 
 
1353
  }
1354
  }
1355
 
app/code/community/Litespeed/Litemage/Model/Observer/Esi.php CHANGED
@@ -103,6 +103,8 @@ class Litespeed_Litemage_Model_Observer_Esi extends Varien_Event_Observer
103
  $this->_canInjectEsi = 0;
104
  return ;
105
  }
 
 
106
  $req = Mage::app()->getRequest() ;
107
  $controller = $eventObj->getControllerAction();
108
  $curActionName = $controller->getFullActionName() ;
@@ -132,8 +134,9 @@ class Litespeed_Litemage_Model_Observer_Esi extends Varien_Event_Observer
132
 
133
  if ($this->_helper->notCacheable()) {
134
  // from previous redirect
135
- if ( $this->_isDebug ) {
136
- $this->_config->debugMesg('no cache from previous redirect route_action ' . $controller->getFullActionName()) ;
 
137
  }
138
  return;
139
  }
@@ -160,6 +163,13 @@ class Litespeed_Litemage_Model_Observer_Esi extends Varien_Event_Observer
160
 
161
  if ($reason == '') {
162
  $reason = $this->_cannotCache($req, $curActionName, $reqUrl);
 
 
 
 
 
 
 
163
  }
164
 
165
  if ($reason != '') {
@@ -232,8 +242,9 @@ class Litespeed_Litemage_Model_Observer_Esi extends Varien_Event_Observer
232
 
233
  }
234
 
235
- if ( $this->_isDebug ) {
236
- $this->_config->debugMesg('****** PRECHECK route_action [' . $curActionName . '] ' . $req->getRequestString() . $reason) ;
 
237
  }
238
 
239
  }
@@ -257,8 +268,9 @@ class Litespeed_Litemage_Model_Observer_Esi extends Varien_Event_Observer
257
  }
258
  }
259
  else {
260
- if ($this->_isDebug)
261
- $this->_config->debugMesg('Uncaptured Forwarded Info ' . print_r($info,true));
 
262
  }
263
  $this->_internal['before_forward'] = $tags;
264
  }
@@ -276,8 +288,9 @@ class Litespeed_Litemage_Model_Observer_Esi extends Varien_Event_Observer
276
  break;
277
  }
278
  }
279
- if ($this->_isDebug) {
280
- $this->_config->debugMesg('Updated header ' . $xtag . ': ' . $value);
 
281
  }
282
  $resp->setHeader($xtag, $value, true);
283
  }
@@ -345,7 +358,14 @@ class Litespeed_Litemage_Model_Observer_Esi extends Varien_Event_Observer
345
  return ''; // can be cached
346
  }
347
 
348
-
 
 
 
 
 
 
 
349
  // event core_layout_block_create_after
350
  public function checkEsiBlock($eventObj)
351
  {
@@ -353,7 +373,7 @@ class Litespeed_Litemage_Model_Observer_Esi extends Varien_Event_Observer
353
  return;
354
 
355
  if ($this->_canInjectEsi === -1) {
356
- $this->_canInjectEsi = $this->_helper->canInjectEsi();
357
  }
358
 
359
  if ( ! $this->_canInjectEsi )
@@ -378,7 +398,7 @@ class Litespeed_Litemage_Model_Observer_Esi extends Varien_Event_Observer
378
  public function prepareInjection( $eventObj )
379
  {
380
  if ($this->_canInjectEsi === -1) {
381
- $this->_canInjectEsi = $this->_helper->canInjectEsi();
382
  }
383
 
384
  if ( ! $this->_canInjectEsi )
@@ -419,8 +439,9 @@ class Litespeed_Litemage_Model_Observer_Esi extends Varien_Event_Observer
419
  $parent->setChild($alias, $esiReplace);
420
  $esiReplace->setParentBlock($oldParent);
421
  }
422
- if ($this->_isDebug) {
423
- $this->_config->debugMesg('_catchLostChildBlocks ' . $msg) ;
 
424
  }
425
  }
426
  else {
@@ -482,9 +503,10 @@ class Litespeed_Litemage_Model_Observer_Esi extends Varien_Event_Observer
482
  $resp->setHttpResponseCode($this->_routeCache['content']['respcode']);
483
  }
484
  $this->_addForwardTags($resp);
485
- if ($this->_isDebug) {
486
  // last debug mesg
487
- $this->_config->debugMesg('###### Served whole route from cache') ;
 
488
  }
489
  return;
490
  }
@@ -519,8 +541,9 @@ class Litespeed_Litemage_Model_Observer_Esi extends Varien_Event_Observer
519
  }
520
 
521
  $this->_addForwardTags($resp);
522
- if ($this->_isDebug) {
523
- $this->_config->debugMesg('###### end of process, body length ' . strlen($resp->getBody()));
 
524
  }
525
 
526
  }
103
  $this->_canInjectEsi = 0;
104
  return ;
105
  }
106
+ $debug = ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_CHECKROUTE)
107
+ ? Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_CHECKROUTE : 0;
108
  $req = Mage::app()->getRequest() ;
109
  $controller = $eventObj->getControllerAction();
110
  $curActionName = $controller->getFullActionName() ;
134
 
135
  if ($this->_helper->notCacheable()) {
136
  // from previous redirect
137
+ if ( $debug ) {
138
+ $this->_config->debugMesg('NO_CACHE from previous redirect route_action '
139
+ . $controller->getFullActionName(), $debug) ;
140
  }
141
  return;
142
  }
163
 
164
  if ($reason == '') {
165
  $reason = $this->_cannotCache($req, $curActionName, $reqUrl);
166
+ // if non-cacheable route, and safemode enabled, disable layout override
167
+ if ($reason && $this->_config->getConf(Litespeed_Litemage_Helper_Data::CFG_SAFE_MODE) ) {
168
+ $update = $controller->getLayout()->getUpdate();
169
+ if ($update instanceof Litespeed_Litemage_Model_Layout_Update) {
170
+ $update->setNoModify();
171
+ }
172
+ }
173
  }
174
 
175
  if ($reason != '') {
242
 
243
  }
244
 
245
+ if ( $debug ) {
246
+ $this->_config->debugMesg('****** PRECHECK route_action [' . $curActionName . '] '
247
+ . $req->getRequestString() . $reason, $debug) ;
248
  }
249
 
250
  }
268
  }
269
  }
270
  else {
271
+ if ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_SAFEIGNORE)
272
+ $this->_config->debugMesg('Uncaptured Forwarded Info ' . print_r($info,true),
273
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_SAFEIGNORE);
274
  }
275
  $this->_internal['before_forward'] = $tags;
276
  }
288
  break;
289
  }
290
  }
291
+ if ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_ENVCOOKIE) {
292
+ $this->_config->debugMesg('Updated header ' . $xtag . ': ' . $value,
293
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_ENVCOOKIE);
294
  }
295
  $resp->setHeader($xtag, $value, true);
296
  }
358
  return ''; // can be cached
359
  }
360
 
361
+ protected function initCanInjectEsi()
362
+ {
363
+ if ($this->_helper->hasMobileThemeMismatch()) {
364
+ $this->_helper->setNotCacheable();
365
+ }
366
+ $this->_canInjectEsi = $this->_helper->canInjectEsi();
367
+ }
368
+
369
  // event core_layout_block_create_after
370
  public function checkEsiBlock($eventObj)
371
  {
373
  return;
374
 
375
  if ($this->_canInjectEsi === -1) {
376
+ $this->initCanInjectEsi();
377
  }
378
 
379
  if ( ! $this->_canInjectEsi )
398
  public function prepareInjection( $eventObj )
399
  {
400
  if ($this->_canInjectEsi === -1) {
401
+ $this->initCanInjectEsi();
402
  }
403
 
404
  if ( ! $this->_canInjectEsi )
439
  $parent->setChild($alias, $esiReplace);
440
  $esiReplace->setParentBlock($oldParent);
441
  }
442
+ if ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION) {
443
+ $this->_config->debugMesg('_catchLostChildBlocks ' . $msg,
444
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION) ;
445
  }
446
  }
447
  else {
503
  $resp->setHttpResponseCode($this->_routeCache['content']['respcode']);
504
  }
505
  $this->_addForwardTags($resp);
506
+ if ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_CHECKROUTE) {
507
  // last debug mesg
508
+ $this->_config->debugMesg('###### END Served whole route from cache',
509
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_CHECKROUTE) ; // end point
510
  }
511
  return;
512
  }
541
  }
542
 
543
  $this->_addForwardTags($resp);
544
+ if ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_CHECKROUTE) {
545
+ $this->_config->debugMesg('###### END of process, body length ' . strlen($resp->getBody()),
546
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_CHECKROUTE); // end point
547
  }
548
 
549
  }
app/code/community/Litespeed/Litemage/Model/Observer/Purge.php CHANGED
@@ -165,8 +165,10 @@ class Litespeed_Litemage_Model_Observer_Purge extends Varien_Event_Observer
165
  $message = 'category ' . implode(', ', $tags);
166
  }
167
 
168
- Mage::helper('litemage/data')->debugMesg($reason);
169
- if (!empty($tags)) {
 
 
170
  Mage::helper('litemage/esi')->setPurgeHeader($tags, $reason) ;
171
  $this->_getAdminSession()->addSuccess(Mage::helper('litemage/data')->__('Notified LiteSpeed web server to purge ' . $message)) ;
172
  }
@@ -224,7 +226,8 @@ class Litespeed_Litemage_Model_Observer_Purge extends Varien_Event_Observer
224
  }
225
  }
226
  } catch ( Exception $e ) {
227
- Mage::helper('litemage/data')->debugMesg('Error on adminPurgeCatalogCategory: ' . $e->getMessage()) ;
 
228
  }
229
 
230
  }
@@ -257,7 +260,8 @@ class Litespeed_Litemage_Model_Observer_Purge extends Varien_Event_Observer
257
  }
258
  }
259
  } catch ( Exception $e ) {
260
- Mage::helper('litemage/data')->debugMesg('Error on adminPurgeCatalogProduct: ' . $e->getMessage()) ;
 
261
  }
262
  }
263
 
@@ -317,10 +321,11 @@ class Litespeed_Litemage_Model_Observer_Purge extends Varien_Event_Observer
317
  Mage::helper('litemage/esi')->setPurgeHeader($tags, $reason) ;
318
  }
319
  }
320
- Mage::helper('litemage/data')->debugMesg($reason);
321
  }
322
  } catch ( Exception $e ) {
323
- Mage::helper('litemage/data')->debugMesg('Error on purgeCatalogProductByStock: ' . $e->getMessage()) ;
 
324
  }
325
  }
326
 
@@ -339,7 +344,8 @@ class Litespeed_Litemage_Model_Observer_Purge extends Varien_Event_Observer
339
  }
340
  }
341
  } catch ( Exception $e ) {
342
- Mage::helper('litemage/data')->debugMesg('Error on adminPurgeCmsPage: ' . $e->getMessage()) ;
 
343
  }
344
  }
345
 
165
  $message = 'category ' . implode(', ', $tags);
166
  }
167
 
168
+ if (empty($tags)) {
169
+ Mage::helper('litemage/data')->debugMesg($reason, Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_PURGEEVENT);
170
+ }
171
+ else {
172
  Mage::helper('litemage/esi')->setPurgeHeader($tags, $reason) ;
173
  $this->_getAdminSession()->addSuccess(Mage::helper('litemage/data')->__('Notified LiteSpeed web server to purge ' . $message)) ;
174
  }
226
  }
227
  }
228
  } catch ( Exception $e ) {
229
+ Mage::helper('litemage/data')->debugMesg('Error on adminPurgeCatalogCategory: '
230
+ . $e->getMessage(), Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_EXCEPTION) ;
231
  }
232
 
233
  }
260
  }
261
  }
262
  } catch ( Exception $e ) {
263
+ Mage::helper('litemage/data')->debugMesg('Error on adminPurgeCatalogProduct: '
264
+ . $e->getMessage(), Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_EXCEPTION) ;
265
  }
266
  }
267
 
321
  Mage::helper('litemage/esi')->setPurgeHeader($tags, $reason) ;
322
  }
323
  }
324
+ Mage::helper('litemage/data')->debugMesg($reason, Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_PURGEEVENT);
325
  }
326
  } catch ( Exception $e ) {
327
+ Mage::helper('litemage/data')->debugMesg('Error on purgeCatalogProductByStock: '
328
+ . $e->getMessage(), Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_EXCEPTION) ;
329
  }
330
  }
331
 
344
  }
345
  }
346
  } catch ( Exception $e ) {
347
+ Mage::helper('litemage/data')->debugMesg('Error on adminPurgeCmsPage: '
348
+ . $e->getMessage(), Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_EXCEPTION) ;
349
  }
350
  }
351
 
app/code/community/Litespeed/Litemage/Model/Session.php CHANGED
@@ -46,8 +46,10 @@ class Litespeed_Litemage_Model_Session extends Mage_Core_Model_Session_Abstract
46
  $messages = array_merge($stored, $messages);
47
  }
48
  $this->setData($blockName, $messages);
49
- if ($this->_isDebug)
50
- Mage::helper('litemage/data')->debugMesg("saveMessages for $blockName " . print_r($messages, true));
 
 
51
  }
52
 
53
  /**
46
  $messages = array_merge($stored, $messages);
47
  }
48
  $this->setData($blockName, $messages);
49
+ if ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION) {
50
+ Mage::helper('litemage/data')->debugMesg("saveMessages for $blockName "
51
+ . print_r($messages, true), Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION);
52
+ }
53
  }
54
 
55
  /**
app/code/community/Litespeed/Litemage/controllers/AdminController.php CHANGED
@@ -55,7 +55,8 @@ class Litespeed_Litemage_AdminController extends Mage_Core_Controller_Front_Acti
55
  protected function _errorExit($errorMesg)
56
  {
57
  if ( $this->_isDebug ) {
58
- $this->_config->debugMesg('litemage/admin ErrorExit: ' . $errorMesg) ;
 
59
  }
60
  $resp = $this->getResponse() ;
61
  $resp->setHttpResponseCode(500) ;
@@ -80,7 +81,7 @@ class Litespeed_Litemage_AdminController extends Mage_Core_Controller_Front_Acti
80
 
81
  public function shellAction()
82
  {
83
- if (Mage::helper('core/http')->getHttpUserAgent() !== 'litemage_walker'
84
  || ! $this->_config->getConf(Litespeed_Litemage_Helper_Data::CFG_ENABLED)) {
85
  $this->_errorExit('Access denied');
86
  }
55
  protected function _errorExit($errorMesg)
56
  {
57
  if ( $this->_isDebug ) {
58
+ $this->_config->debugMesg('litemage/admin ErrorExit: ' . $errorMesg,
59
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_EXCEPTION) ;
60
  }
61
  $resp = $this->getResponse() ;
62
  $resp->setHttpResponseCode(500) ;
81
 
82
  public function shellAction()
83
  {
84
+ if ($this->_config->getLiteMageUserAgent() !== Litespeed_Litemage_Helper_Data::LITEMAGE_USER_AGENT
85
  || ! $this->_config->getConf(Litespeed_Litemage_Helper_Data::CFG_ENABLED)) {
86
  $this->_errorExit('Access denied');
87
  }
app/code/community/Litespeed/Litemage/controllers/EsiController.php CHANGED
@@ -40,14 +40,17 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
40
 
41
  protected function _construct()
42
  {
43
- $this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_PRE_DISPATCH, true) ;
44
- $this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_POST_DISPATCH, true) ;
45
- $this->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_START_SESSION, true) ; // postdispatch will not set last viewed url
46
- $this->getFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH_BLOCK_EVENT, true) ;
 
47
 
48
  $this->_config = Mage::helper('litemage/data') ;
49
- if ( ! $this->_config->moduleEnabledForUser() ) {
50
- Mage::throwException('LiteMage module not enabled for user') ;
 
 
51
  }
52
 
53
  $this->_isDebug = $this->_config->isDebug() ;
@@ -138,8 +141,9 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
138
  $esiUrl = $this->_setOriginalReq() ;
139
  $esiData = new Litespeed_Litemage_Model_EsiData($esiUrl, $this->_config) ;
140
 
141
- if ( $this->_isDebug ) {
142
- $this->_config->debugMesg('****** EsiController process ' . $esiData->getAction()) ;
 
143
  }
144
  $this->_initEnv($esiData) ;
145
  $this->_scheduleProcess($esiData) ;
@@ -155,6 +159,8 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
155
  $this->_initEnv($esiData) ;
156
 
157
  $esiIncludes = $_REQUEST['esi_include'] ;
 
 
158
 
159
  if ( ($key = array_search('*', $esiIncludes)) !== false ) {
160
  unset($esiIncludes[$key]) ;
@@ -162,7 +168,7 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
162
  $extraUrls = array_keys($this->_esiCache);
163
  $esiInclude0 = $esiIncludes;
164
  $esiIncludes = array_unique(array_merge($esiInclude0, $extraUrls)) ;
165
- if ( $this->_isDebug ) {
166
  $esiInclude1 = array();
167
  foreach($esiIncludes as $uri) {
168
  if (in_array($uri, $esiInclude0))
@@ -170,12 +176,14 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
170
  else
171
  $esiInclude1[] = '* ' . $uri;
172
  }
173
- $this->_config->debugMesg('combined includes * = ' . print_r($esiInclude1, true)) ;
 
174
  }
175
  }
176
  else {
177
- if ( $this->_isDebug ) {
178
- $this->_config->debugMesg('combined includes = ' . print_r($esiIncludes, true)) ;
 
179
  }
180
  }
181
 
@@ -196,8 +204,9 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
196
  $block = $this->_layout->getEsiBlock($blockIndex) ;
197
  $out = '';
198
  if ( ! $block ) {
199
- if ( $this->_isDebug ) {
200
- $this->_config->debugMesg('cannot get esi block ' . $blockIndex) ;
 
201
  }
202
  return $out ;
203
  }
@@ -213,8 +222,9 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
213
  $rcount = 0;
214
  $out1 = preg_replace('/(\/checkout\/cart\/delete\/id\/\d+\/form_key\/\w+\/)uenc\/[^\/]*\//', '$1', $out, -1, $rcount);
215
  if ($rcount > 0) {
216
- if ( $this->_isDebug ) {
217
- $this->_config->debugMesg('removed ' . $rcount . ' uenc from cart delete url') ;
 
218
  }
219
  $out = $out1;
220
  }
@@ -224,7 +234,9 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
224
  }
225
  } catch ( Exception $e ) {
226
  if ( $this->_isDebug ) {
227
- $this->_config->debugMesg('_renderEsiBlock, exception for block ' . $blockIndex . ' : ' . $e->getMessage()) ;
 
 
228
  }
229
  }
230
 
@@ -255,12 +267,16 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
255
  $_SERVER['REQUEST_URI'] = $refererUrl ;
256
  $req->setRequestUri($refererUrl) ;
257
  $req->setPathInfo() ;
258
- if ( $this->_isDebug ) {
259
- $this->_config->debugMesg('****** EsiController process ' . $origEsiUrl . ' referral ' . $refererUrl) ;
 
 
260
  }
261
  }
262
  else {
263
- Mage::throwException('Illegal entrance for LiteMage module') ;
 
 
264
  }
265
  return $origEsiUrl ;
266
  }
@@ -325,6 +341,8 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
325
  $body = '' ;
326
  $esiInlineTag = $this->_env['inline_tag'] ;
327
  $shared = $this->_env['shared'] ;
 
 
328
 
329
  foreach ( $this->_processed as $url => $esiData ) {
330
  if ( is_string($esiData) ) {
@@ -335,7 +353,7 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
335
  $inlineHtml = $esiData->getInlineHtml($esiInlineTag, $shared) ;
336
  $refreshed = $this->_refreshCacheEntry($url, $esiData, $inlineHtml) ;
337
  }
338
- if ( $this->_isDebug ) {
339
  switch ($refreshed) {
340
  case -1: $status = ':no_cache' ; break;
341
  case -2: $status = ':param_mismatch' ; break;
@@ -354,7 +372,8 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
354
  $status .= substr($cacheId, 11, 10) . ' ' ;
355
  }
356
  }
357
- $this->_config->debugMesg('out' . $status . substr($inlineHtml, 0, strpos($inlineHtml, "\n"))) ;
 
358
  }
359
  $body .= $inlineHtml ;
360
  }
@@ -362,8 +381,8 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
362
 
363
  if ( $this->_env['cache_updated'] && $this->_config->useInternalCache() ) {
364
  $this->_config->saveInternalCache(serialize($this->_esiCache), $this->_env['cache_id']) ;
365
- if ( $this->_isDebug ) {
366
- $this->_config->debugMesg('saved esi_data cache');
367
  }
368
  }
369
  }
@@ -402,7 +421,8 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
402
  }
403
  else {
404
  if ( $this->_isDebug ) {
405
- $this->_config->debugMesg('cannot get esi block ' . $bi) ;
 
406
  }
407
  }
408
  }
@@ -479,7 +499,9 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
479
  } catch ( Exception $e ) {
480
  $responseCode = 500 ;
481
  if ( $this->_isDebug ) {
482
- $this->_config->debugMesg('_logData, exception for product ' . $product->getId() . ' : ' . $e->getMessage()) ;
 
 
483
  }
484
  }
485
  $esiData->setRawOutput('', $responseCode) ;
@@ -533,6 +555,9 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
533
  }
534
  }
535
  }
 
 
 
536
  $session->setData('_litemage_user', 3);
537
 
538
  $action = $esiData->getAction() ;
@@ -563,7 +588,11 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
563
  $design->setTheme('layout', $dt[2]);
564
  }
565
 
566
- $curLocale = $app->getLocale() ;
 
 
 
 
567
  $locale = Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE) ;
568
  if ( $curLocale->getLocaleCode() != $locale ) {
569
  $curLocale->setLocale($locale) ;
@@ -599,8 +628,10 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
599
  if ( Mage::app()->useCache('layout') ) {
600
  if ( $data = Mage::app()->loadCache($this->_env['cache_id']) ) {
601
  $this->_esiCache = unserialize($data) ;
602
- if ($this->_isDebug) {
603
- $this->_config->debugMesg('loaded esi_data cache ' . substr($this->_env['cache_id'], 18, 8));
 
 
604
  }
605
  }
606
  }
40
 
41
  protected function _construct()
42
  {
43
+ $action = $this->getRequest()->getActionName();
44
+ $this->setFlag($action, Mage_Core_Controller_Varien_Action::FLAG_NO_PRE_DISPATCH, true) ;
45
+ $this->setFlag($action, Mage_Core_Controller_Varien_Action::FLAG_NO_POST_DISPATCH, true) ;
46
+ $this->setFlag($action, Mage_Core_Controller_Varien_Action::FLAG_NO_START_SESSION, true) ; // postdispatch will not set last viewed url
47
+ $this->setFlag($action, Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH_BLOCK_EVENT, true) ;
48
 
49
  $this->_config = Mage::helper('litemage/data') ;
50
+ if (! $this->_config->moduleEnabledForUser() ) {
51
+ $should_not_happen = 'LiteMage module not enabled for user - enabled=' . $this->_config->getConf(Litespeed_Litemage_Helper_Data::CFG_ENABLED);
52
+ $this->_config->debugMesg($should_not_happen, Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_EXCEPTION);
53
+ Mage::throwException($should_not_happen) ;
54
  }
55
 
56
  $this->_isDebug = $this->_config->isDebug() ;
141
  $esiUrl = $this->_setOriginalReq() ;
142
  $esiData = new Litespeed_Litemage_Model_EsiData($esiUrl, $this->_config) ;
143
 
144
+ if ( $this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_CHECKROUTE) {
145
+ $this->_config->debugMesg('EsiController process ' . $esiData->getAction(),
146
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_CHECKROUTE) ;
147
  }
148
  $this->_initEnv($esiData) ;
149
  $this->_scheduleProcess($esiData) ;
159
  $this->_initEnv($esiData) ;
160
 
161
  $esiIncludes = $_REQUEST['esi_include'] ;
162
+ $debug = ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION) ?
163
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION : 0;
164
 
165
  if ( ($key = array_search('*', $esiIncludes)) !== false ) {
166
  unset($esiIncludes[$key]) ;
168
  $extraUrls = array_keys($this->_esiCache);
169
  $esiInclude0 = $esiIncludes;
170
  $esiIncludes = array_unique(array_merge($esiInclude0, $extraUrls)) ;
171
+ if ( $debug ) {
172
  $esiInclude1 = array();
173
  foreach($esiIncludes as $uri) {
174
  if (in_array($uri, $esiInclude0))
176
  else
177
  $esiInclude1[] = '* ' . $uri;
178
  }
179
+ $this->_config->debugMesg('Combined includes * = '
180
+ . print_r($esiInclude1, true), $debug);
181
  }
182
  }
183
  else {
184
+ if ( $debug ) {
185
+ $this->_config->debugMesg('Combined includes = '
186
+ . print_r($esiIncludes, true), $debug) ;
187
  }
188
  }
189
 
204
  $block = $this->_layout->getEsiBlock($blockIndex) ;
205
  $out = '';
206
  if ( ! $block ) {
207
+ if ( $this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_SAFEIGNORE ) {
208
+ $this->_config->debugMesg('CANNOT get esi block ' . $blockIndex,
209
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_SAFEIGNORE) ;
210
  }
211
  return $out ;
212
  }
222
  $rcount = 0;
223
  $out1 = preg_replace('/(\/checkout\/cart\/delete\/id\/\d+\/form_key\/\w+\/)uenc\/[^\/]*\//', '$1', $out, -1, $rcount);
224
  if ($rcount > 0) {
225
+ if ( $this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION) {
226
+ $this->_config->debugMesg('Removed ' . $rcount . ' uenc from cart delete url',
227
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION) ;
228
  }
229
  $out = $out1;
230
  }
234
  }
235
  } catch ( Exception $e ) {
236
  if ( $this->_isDebug ) {
237
+ $this->_config->debugMesg('_renderEsiBlock, exception for block '
238
+ . $blockIndex . ' : ' . $e->getMessage(),
239
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_EXCEPTION) ;
240
  }
241
  }
242
 
267
  $_SERVER['REQUEST_URI'] = $refererUrl ;
268
  $req->setRequestUri($refererUrl) ;
269
  $req->setPathInfo() ;
270
+ if ( $this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_CHECKROUTE ) {
271
+ $this->_config->debugMesg('EsiController process '
272
+ . $origEsiUrl . ' referral ' . $refererUrl,
273
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_CHECKROUTE) ;
274
  }
275
  }
276
  else {
277
+ $errMsg = 'Illegal entrance for LiteMage module';
278
+ $this->_config->debugMesg($errMsg, Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_EXCEPTION);
279
+ Mage::throwException($errMsg) ;
280
  }
281
  return $origEsiUrl ;
282
  }
341
  $body = '' ;
342
  $esiInlineTag = $this->_env['inline_tag'] ;
343
  $shared = $this->_env['shared'] ;
344
+ $debug = ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION) ?
345
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION : 0;
346
 
347
  foreach ( $this->_processed as $url => $esiData ) {
348
  if ( is_string($esiData) ) {
353
  $inlineHtml = $esiData->getInlineHtml($esiInlineTag, $shared) ;
354
  $refreshed = $this->_refreshCacheEntry($url, $esiData, $inlineHtml) ;
355
  }
356
+ if ( $debug ) {
357
  switch ($refreshed) {
358
  case -1: $status = ':no_cache' ; break;
359
  case -2: $status = ':param_mismatch' ; break;
372
  $status .= substr($cacheId, 11, 10) . ' ' ;
373
  }
374
  }
375
+ $this->_config->debugMesg('out' . $status
376
+ . substr($inlineHtml, 0, strpos($inlineHtml, "\n")), $debug) ;
377
  }
378
  $body .= $inlineHtml ;
379
  }
381
 
382
  if ( $this->_env['cache_updated'] && $this->_config->useInternalCache() ) {
383
  $this->_config->saveInternalCache(serialize($this->_esiCache), $this->_env['cache_id']) ;
384
+ if ( $debug ) {
385
+ $this->_config->debugMesg('saved esi_data cache', $debug);
386
  }
387
  }
388
  }
421
  }
422
  else {
423
  if ( $this->_isDebug ) {
424
+ $this->_config->debugMesg('cannot get esi block ' . $bi,
425
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_SAFEIGNORE) ;
426
  }
427
  }
428
  }
499
  } catch ( Exception $e ) {
500
  $responseCode = 500 ;
501
  if ( $this->_isDebug ) {
502
+ $this->_config->debugMesg('_logData, exception for product '
503
+ . $product->getId() . ' : ' . $e->getMessage(),
504
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_EXCEPTION) ;
505
  }
506
  }
507
  $esiData->setRawOutput('', $responseCode) ;
555
  }
556
  }
557
  }
558
+ if ($this->_env['shared'] && !array_key_exists('HTTP_USER_AGENT', $_SERVER)) {
559
+ $this->_env['shared'] = false;
560
+ }
561
  $session->setData('_litemage_user', 3);
562
 
563
  $action = $esiData->getAction() ;
588
  $design->setTheme('layout', $dt[2]);
589
  }
590
 
591
+ if ($this->_env['shared'] && $this->_helper->hasMobileThemeMismatch()) {
592
+ $this->_env['shared'] = false;
593
+ }
594
+
595
+ $curLocale = $app->getLocale() ;
596
  $locale = Mage::getStoreConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE) ;
597
  if ( $curLocale->getLocaleCode() != $locale ) {
598
  $curLocale->setLocale($locale) ;
628
  if ( Mage::app()->useCache('layout') ) {
629
  if ( $data = Mage::app()->loadCache($this->_env['cache_id']) ) {
630
  $this->_esiCache = unserialize($data) ;
631
+ if ($this->_isDebug >= Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION) {
632
+ $this->_config->debugMesg('loaded esi_data cache '
633
+ . substr($this->_env['cache_id'], 18, 8),
634
+ Litespeed_Litemage_Helper_Data::DEBUG_LEVEL_INJECTION);
635
  }
636
  }
637
  }
app/code/community/Litespeed/Litemage/etc/config.xml CHANGED
@@ -26,7 +26,7 @@
26
  <config>
27
  <modules>
28
  <Litespeed_Litemage>
29
- <version>1.3.5</version>
30
  </Litespeed_Litemage>
31
  </modules>
32
  <global>
@@ -461,13 +461,14 @@
461
  <general>
462
  <enabled>0</enabled>
463
  <admin_ips>127.0.0.1</admin_ips>
464
- <public_ttl>28800</public_ttl>
465
  <private_ttl>1800</private_ttl>
466
- <home_ttl>28800</home_ttl>
467
  <track_viewed>0</track_viewed>
468
  <diff_customergroup>0</diff_customergroup>
469
  <diff_customergroup_set/>
470
  <flush_prodcat>0</flush_prodcat>
 
471
  <alt_esi_syntax>0</alt_esi_syntax>
472
  <cache_tag_prefix>M</cache_tag_prefix>
473
  </general>
@@ -477,11 +478,12 @@
477
  <load_limit>5</load_limit>
478
  <thread_limit>6</thread_limit>
479
  <max_time>360</max_time>
480
- <interval>21600</interval>
481
  <priority>100</priority>
482
  <multi_currency/>
483
  <multi_custgroup/>
484
- <autolist_interval>28800</autolist_interval>
 
485
  <autolist_priority>300</autolist_priority>
486
  <enable_autocollect>0</enable_autocollect>
487
  <auto_collect_add>6</auto_collect_add>
@@ -519,7 +521,9 @@
519
  <test>
520
  <allow_ips/>
521
  <debug>0</debug>
 
522
  <delta_log>0</delta_log>
 
523
  </test>
524
  </litemage>
525
  </default>
26
  <config>
27
  <modules>
28
  <Litespeed_Litemage>
29
+ <version>1.3.6</version>
30
  </Litespeed_Litemage>
31
  </modules>
32
  <global>
461
  <general>
462
  <enabled>0</enabled>
463
  <admin_ips>127.0.0.1</admin_ips>
464
+ <public_ttl>86400</public_ttl>
465
  <private_ttl>1800</private_ttl>
466
+ <home_ttl>43200</home_ttl>
467
  <track_viewed>0</track_viewed>
468
  <diff_customergroup>0</diff_customergroup>
469
  <diff_customergroup_set/>
470
  <flush_prodcat>0</flush_prodcat>
471
+ <mobile_theme/>
472
  <alt_esi_syntax>0</alt_esi_syntax>
473
  <cache_tag_prefix>M</cache_tag_prefix>
474
  </general>
478
  <load_limit>5</load_limit>
479
  <thread_limit>6</thread_limit>
480
  <max_time>360</max_time>
481
+ <interval>57600</interval>
482
  <priority>100</priority>
483
  <multi_currency/>
484
  <multi_custgroup/>
485
+ <mobile_view/>
486
+ <autolist_interval>57600</autolist_interval>
487
  <autolist_priority>300</autolist_priority>
488
  <enable_autocollect>0</enable_autocollect>
489
  <auto_collect_add>6</auto_collect_add>
521
  <test>
522
  <allow_ips/>
523
  <debug>0</debug>
524
+ <debug_level>5</debug_level>
525
  <delta_log>0</delta_log>
526
+ <safe_mode>0</safe_mode>
527
  </test>
528
  </litemage>
529
  </default>
app/code/community/Litespeed/Litemage/etc/system.xml CHANGED
@@ -27,7 +27,7 @@
27
  <config>
28
  <tabs>
29
  <Litespeed_Litemage translate="label">
30
- <label>LiteMage Cache 1.3.5</label>
31
  <sort_order>5000</sort_order>
32
  </Litespeed_Litemage>
33
  </tabs>
@@ -80,7 +80,7 @@
80
  </admin_ips>
81
  <public_ttl translate="label,comment">
82
  <label>Default Public Cache TTL (seconds)</label>
83
- <comment>Default timeout for public cache pages. Recommended value is 28800.</comment>
84
  <frontend_type>text</frontend_type>
85
  <validate>validate-digits validate-digits-range digits-range-600-</validate>
86
  <sort_order>20</sort_order>
@@ -150,12 +150,23 @@
150
  <show_in_website>0</show_in_website>
151
  <show_in_store>0</show_in_store>
152
  </flush_prodcat>
 
 
 
 
 
 
 
 
 
 
 
153
  <alt_esi_syntax translate="label,comment">
154
  <label>Use Alternative ESI Syntax</label>
155
  <comment>If the standard ESI include tags are being filtered by some extension(s) and causing ESI parser errors, you can enable Alternative ESI Syntax, which is known only by LiteMage and LiteSpeed Web Server. </comment>
156
  <frontend_type>select</frontend_type>
157
  <source_model>adminhtml/system_config_source_yesno</source_model>
158
- <sort_order>80</sort_order>
159
  <show_in_default>1</show_in_default>
160
  <show_in_website>0</show_in_website>
161
  <show_in_store>0</show_in_store>
@@ -377,6 +388,16 @@
377
  <show_in_website>1</show_in_website>
378
  <show_in_store>1</show_in_store>
379
  </multi_custgroup>
 
 
 
 
 
 
 
 
 
 
380
  <custlist_note translate="label,comment">
381
  <label>Custom Defined URL List Files</label>
382
  <comment>You can supply your own URL list for each store view. To do this go to the “Current Configuration Scope” box and select a store.</comment>
@@ -566,7 +587,7 @@ Each file listed should contain a list of custom-defined URLs (one per line). Th
566
  </allow_ips>
567
  <debug translate="label,comment">
568
  <label>Enable Debug Log</label>
569
- <comment>Prints additional information to var/log/system.log for debugging purposes. (Ensure developer log is enabled.)
570
  <![CDATA[<span class="notice">Turn off for production use.</span>]]></comment>
571
  <frontend_type>select</frontend_type>
572
  <source_model>litemage/config_source_enableDebugLog</source_model>
@@ -575,17 +596,37 @@ Each file listed should contain a list of custom-defined URLs (one per line). Th
575
  <show_in_website>0</show_in_website>
576
  <show_in_store>0</show_in_store>
577
  </debug>
 
 
 
 
 
 
 
 
 
 
578
  <delta_log translate="label,comment">
579
- <label>Enable Log for Delta crawler</label>
580
- <comment>Prints delta crawler activities to var/log/lmdelta.log.</comment>
581
  <frontend_type>select</frontend_type>
582
  <source_model>adminhtml/system_config_source_yesno</source_model>
583
- <sort_order>30</sort_order>
584
  <show_in_default>1</show_in_default>
585
  <show_in_website>0</show_in_website>
586
  <show_in_store>0</show_in_store>
587
  </delta_log>
588
-
 
 
 
 
 
 
 
 
 
 
589
  </fields>
590
  </test>
591
 
27
  <config>
28
  <tabs>
29
  <Litespeed_Litemage translate="label">
30
+ <label>LiteMage Cache 1.3.6</label>
31
  <sort_order>5000</sort_order>
32
  </Litespeed_Litemage>
33
  </tabs>
80
  </admin_ips>
81
  <public_ttl translate="label,comment">
82
  <label>Default Public Cache TTL (seconds)</label>
83
+ <comment>Default timeout for public cache pages. Recommended value is 86400.</comment>
84
  <frontend_type>text</frontend_type>
85
  <validate>validate-digits validate-digits-range digits-range-600-</validate>
86
  <sort_order>20</sort_order>
150
  <show_in_website>0</show_in_website>
151
  <show_in_store>0</show_in_store>
152
  </flush_prodcat>
153
+ <mobile_theme translate="label,comment">
154
+ <label>Mobile Theme</label>
155
+ <comment><![CDATA[Adds extra protection against cache contamination in unresponsive themes that use a different template theme for mobile view.
156
+ Make sure the mobile detection rules in .htaccess match those used in the theme (<a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:litemage:configuration:general_settings#mobile_theme">more info</a>)
157
+ ]]></comment>
158
+ <frontend_type>text</frontend_type>
159
+ <sort_order>80</sort_order>
160
+ <show_in_default>1</show_in_default>
161
+ <show_in_website>1</show_in_website>
162
+ <show_in_store>0</show_in_store>
163
+ </mobile_theme>
164
  <alt_esi_syntax translate="label,comment">
165
  <label>Use Alternative ESI Syntax</label>
166
  <comment>If the standard ESI include tags are being filtered by some extension(s) and causing ESI parser errors, you can enable Alternative ESI Syntax, which is known only by LiteMage and LiteSpeed Web Server. </comment>
167
  <frontend_type>select</frontend_type>
168
  <source_model>adminhtml/system_config_source_yesno</source_model>
169
+ <sort_order>90</sort_order>
170
  <show_in_default>1</show_in_default>
171
  <show_in_website>0</show_in_website>
172
  <show_in_store>0</show_in_store>
388
  <show_in_website>1</show_in_website>
389
  <show_in_store>1</show_in_store>
390
  </multi_custgroup>
391
+ <mobile_view translate="label,comment">
392
+ <label>Crawl for Mobile Views</label>
393
+ <comment>Warm up pages for a different mobile theme. Only use this setting if a different template theme is used for mobile view. "Mobile Theme" must also be set under LiteMage configuration - General Settings.</comment>
394
+ <frontend_type>select</frontend_type>
395
+ <source_model>adminhtml/system_config_source_yesno</source_model>
396
+ <sort_order>76</sort_order>
397
+ <show_in_default>1</show_in_default>
398
+ <show_in_website>1</show_in_website>
399
+ <show_in_store>1</show_in_store>
400
+ </mobile_view>
401
  <custlist_note translate="label,comment">
402
  <label>Custom Defined URL List Files</label>
403
  <comment>You can supply your own URL list for each store view. To do this go to the “Current Configuration Scope” box and select a store.</comment>
587
  </allow_ips>
588
  <debug translate="label,comment">
589
  <label>Enable Debug Log</label>
590
+ <comment>Prints additional information to var/log/litemage.log for debugging purposes.
591
  <![CDATA[<span class="notice">Turn off for production use.</span>]]></comment>
592
  <frontend_type>select</frontend_type>
593
  <source_model>litemage/config_source_enableDebugLog</source_model>
596
  <show_in_website>0</show_in_website>
597
  <show_in_store>0</show_in_store>
598
  </debug>
599
+ <debug_level translate="label,comment">
600
+ <label>Debug Level</label>
601
+ <comment>Specifies debug level ranging from 1 to 9. The higher the value, the more detailed the output.</comment>
602
+ <frontend_type>text</frontend_type>
603
+ <validate>validate-digits validate-digits-range digits-range-1-9</validate>
604
+ <sort_order>30</sort_order>
605
+ <show_in_default>1</show_in_default>
606
+ <show_in_website>0</show_in_website>
607
+ <show_in_store>0</show_in_store>
608
+ </debug_level>
609
  <delta_log translate="label,comment">
610
+ <label>Enable Log for Crawlers</label>
611
+ <comment>Prints warmup and delta crawler activities to var/log/litemage_crawler.log.</comment>
612
  <frontend_type>select</frontend_type>
613
  <source_model>adminhtml/system_config_source_yesno</source_model>
614
+ <sort_order>40</sort_order>
615
  <show_in_default>1</show_in_default>
616
  <show_in_website>0</show_in_website>
617
  <show_in_store>0</show_in_store>
618
  </delta_log>
619
+ <safe_mode>
620
+ <label>Disable Layout Override for Non-Cacheable Routes</label>
621
+ <comment>This will disable LiteMage’s layout class override for non-cacheable frontend pages at the expense of performance.
622
+ Enable this setting if there are issues during the checkout process.</comment>
623
+ <frontend_type>select</frontend_type>
624
+ <source_model>adminhtml/system_config_source_yesno</source_model>
625
+ <sort_order>50</sort_order>
626
+ <show_in_default>1</show_in_default>
627
+ <show_in_website>0</show_in_website>
628
+ <show_in_store>0</show_in_store>
629
+ </safe_mode>
630
  </fields>
631
  </test>
632
 
package.xml CHANGED
@@ -1,22 +1,23 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>LiteSpeed_LiteMage</name>
4
- <version>1.3.5</version>
5
  <stability>stable</stability>
6
  <license uri="https://opensource.org/licenses/GPL-3.0 ">GPL v3</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>LiteMage Cache speeds up Magento by automatically integrating Magento with LiteSpeed's superior ESI implementation.</summary>
10
  <description>LiteMage Cache is a powerful Magento page caching utility built into LiteSpeed Web Server. It combines superior ESI implementation with easy set up. LiteMage Cache contains a number of optimizations, including combined subrequests, that give it faster, more efficient performance than other page caching utilities. In addition, because it is part of the web server, LiteMage Cache does away with the communication problems and overhead other page caching solutions suffer from. The LiteMage Magento extension then automatically integrates Magento installations with LiteSpeed's top-of-the-line ESI implementation, combining the greatest Magento performance enhancement possible with a painless set up.</description>
11
- <notes>Fixed a bug where AJAX output containing ESI blocks could break JSON format.&#xD;
12
- Fixed a bug where an external extension setting the layout cache ID.&#xD;
13
- Improved compatibility for Magento 1.7 stores not using form_key.&#xD;
14
- Improved compatibility with customized themes.&#xD;
 
15
  </notes>
16
  <authors><author><name>LiteSpeed Technologies</name><user>LiteSpeedTech</user><email>lsong@litespeedtech.com</email></author></authors>
17
- <date>2017-03-10</date>
18
- <time>18:58:04</time>
19
- <contents><target name="magecommunity"><dir name="Litespeed"><dir name="Litemage"><dir name="Block"><dir name="Adminhtml"><dir name="Cache"><file name="Management.php" hash="126c636bebf6a1933f45781d6e95863d"/></dir><file name="ItemSave.php" hash="399a23c090fd92436793b1e0e38038a1"/></dir><dir name="Core"><file name="Dummy.php" hash="ae50751905056dd3eb34c3222d17a310"/><file name="Esi.php" hash="07d81757cca6ecd91121d6b26e21f0c6"/><file name="Messages.php" hash="da581eb4adaa1ac4e2d4b86ff30f08d4"/><file name="Xml.php" hash="f1bca825e34c7fdac648a9ef9b87b47c"/></dir><dir name="Inject"><file name="Jsvar.php" hash="cc0590fe211c81d6d29de570503fe8fd"/><file name="Nickname.php" hash="deba1efffd6449b6492bb13aaca4658b"/></dir></dir><dir name="Helper"><file name="Data.php" hash="637e0a2ea3281bd77cacf4c0e681d7a7"/><file name="Esi.php" hash="4091ebf887e5dd6b5fa7591cf6437e2e"/><file name="Viewvary.php" hash="9dfe26a70510a1899f4dcde62d91a21d"/></dir><dir name="Model"><dir name="Config"><dir name="Backend"><file name="WarmUp.php" hash="663ecf7689115059eb94898f37adeb6f"/></dir><dir name="Source"><file name="CustomerGroup.php" hash="f28a5381d6b79f71c054b3072973041b"/><file name="EnableDebugLog.php" hash="27d4b6030f564dfae8c89a84264b1175"/><file name="EnableWarmUp.php" hash="f44aafa2f6ba65a0e4926b7635ff264d"/><file name="FlushCategory.php" hash="b8017a1859b320f05af272f4d4e442e2"/></dir></dir><file name="EsiData.php" hash="b5035683d77cf0840152e654dd431600"/><file name="EsiLayout.php" hash="26bef4ee2a873ecb26ba7f292cfe0fd6"/><dir name="Layout"><file name="EsiUpdate.php" hash="3c98a2961b08f0acb3d334ab932eb397"/><file name="Master.php" hash="5eb57ba3677b76468ccf6f74741dcc63"/><file name="Update.php" hash="04a34f07e01c4a9bad3bf4988cba582c"/></dir><dir name="Observer"><file name="Cron.php" hash="40a0a36bdd6d08d6ab8e023196ae3faa"/><file name="Esi.php" hash="893a4e51330291fd0420b144951c6d3a"/><file name="Purge.php" hash="84e83b6aa28a72a6c8b86b0656d2f022"/></dir><file name="Session.php" hash="558a80fb45a532af59727ae5657cd380"/><file name="Translate.php" hash="35326b8d2214f516d7dba82519902529"/></dir><dir name="controllers"><file name="AdminController.php" hash="549098ba10e19b066a6d52eab0f7bbb6"/><dir name="Adminhtml"><file name="LitemageCacheController.php" hash="506c63ddec598d39fa8a1dd1e58549d9"/></dir><file name="EsiController.php" hash="97e601ea5f3578a16d10db0a5a0aae82"/></dir><dir name="etc"><file name="config.xml" hash="13806a11e9d33fa3fd26ebe18358bf47"/><file name="system.xml" hash="ea73a6627e232cebb050af5ded732199"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="litemage.xml" hash="f4dd1848120e353da9a84a7fd5565093"/></dir><dir name="template"><dir name="litemage"><file name="cache_management.phtml" hash="478836f2a9aa54e6d1e3fbf2164bbfcc"/><file name="category_save.phtml" hash="b29d102b8f90ce4da881a30efa3b2838"/><file name="product_save.phtml" hash="01863cb9acd33ca51db4f2a26e233eec"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="litemage.xml" hash="4c840b12cc6246f68b1b028f0ef1056d"/></dir><dir name="template"><dir name="litemage"><dir name="inject"><file name="jsvar.phtml" hash="5bbd9992e7ba5925d09f21cf03237676"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Litespeed_Litemage.xml" hash="ba0c8904bc89219c6829e37cc14d9bdd"/></dir></target><target name="mage"><dir name="shell"><file name="litemage_purge.php" hash="fbcc05832098dfbda5d30bfe24973fab"/></dir></target></contents>
20
  <compatible/>
21
- <dependencies><required><php><min>5.3.0</min><max>7.1.0</max></php></required></dependencies>
22
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>LiteSpeed_LiteMage</name>
4
+ <version>1.3.6</version>
5
  <stability>stable</stability>
6
  <license uri="https://opensource.org/licenses/GPL-3.0 ">GPL v3</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>LiteMage Cache speeds up Magento by automatically integrating Magento with LiteSpeed's superior ESI implementation.</summary>
10
  <description>LiteMage Cache is a powerful Magento page caching utility built into LiteSpeed Web Server. It combines superior ESI implementation with easy set up. LiteMage Cache contains a number of optimizations, including combined subrequests, that give it faster, more efficient performance than other page caching utilities. In addition, because it is part of the web server, LiteMage Cache does away with the communication problems and overhead other page caching solutions suffer from. The LiteMage Magento extension then automatically integrates Magento installations with LiteSpeed's top-of-the-line ESI implementation, combining the greatest Magento performance enhancement possible with a painless set up.</description>
11
+ <notes>Added a &#x2018;Debug Level&#x2019; option for controlling debug log message detail.&#xD;
12
+ Added a &#x2018;Disable Layout Override for Non-Cacheable Routes&#x2019; option for sites with issues during the checkout process.&#xD;
13
+ Added an extra check for mismatched mobile detection rules between LiteMage and .htaccess for unresponsive mobile views.&#xD;
14
+ Added the ability to crawl mobile views for unresponsive themes.&#xD;
15
+ LiteMage will now write to it&#x2019;s own debug log when enabled under Developer testing. Magento debug logging also no longer needs to be enabled. &#xD;
16
  </notes>
17
  <authors><author><name>LiteSpeed Technologies</name><user>LiteSpeedTech</user><email>lsong@litespeedtech.com</email></author></authors>
18
+ <date>2017-06-06</date>
19
+ <time>15:42:59</time>
20
+ <contents><target name="magecommunity"><dir name="Litespeed"><dir name="Litemage"><dir name="Block"><dir name="Adminhtml"><dir name="Cache"><file name="Management.php" hash="126c636bebf6a1933f45781d6e95863d"/></dir><file name="ItemSave.php" hash="399a23c090fd92436793b1e0e38038a1"/></dir><dir name="Core"><file name="Dummy.php" hash="1877c23e3e4718c33af50cca2162a7dd"/><file name="Esi.php" hash="4cb9490db19c9fff11101c52d056dc3c"/><file name="Messages.php" hash="59c9d686693cb07af89af4d4372087a1"/><file name="Xml.php" hash="6aaa425cbefc3fc96e94228a683ea64d"/></dir><dir name="Inject"><file name="Jsvar.php" hash="cc0590fe211c81d6d29de570503fe8fd"/><file name="Nickname.php" hash="deba1efffd6449b6492bb13aaca4658b"/></dir></dir><dir name="Helper"><file name="Data.php" hash="a8690ab8c2fab5799a1de0842a064077"/><file name="Esi.php" hash="0ef3fefa6b3efe38d134223ea7b7f42c"/><file name="Viewvary.php" hash="83d8bcd8ebc317a0781e856fdc6ed760"/></dir><dir name="Model"><dir name="Config"><dir name="Backend"><file name="WarmUp.php" hash="663ecf7689115059eb94898f37adeb6f"/></dir><dir name="Source"><file name="CustomerGroup.php" hash="f28a5381d6b79f71c054b3072973041b"/><file name="EnableDebugLog.php" hash="27d4b6030f564dfae8c89a84264b1175"/><file name="EnableWarmUp.php" hash="f44aafa2f6ba65a0e4926b7635ff264d"/><file name="FlushCategory.php" hash="b8017a1859b320f05af272f4d4e442e2"/></dir></dir><file name="EsiData.php" hash="d29e8f9aed79b06db1dbffc3480a1a47"/><file name="EsiLayout.php" hash="26bef4ee2a873ecb26ba7f292cfe0fd6"/><dir name="Layout"><file name="EsiUpdate.php" hash="6bd169613bfb2a79968e196a61a847af"/><file name="Master.php" hash="f0269fdd9a66fd5b66bb87c4d4e865e1"/><file name="Update.php" hash="0cd79fd5c2cb3b3f0d69bcdc577fc740"/></dir><dir name="Observer"><file name="Cron.php" hash="67a35bbae819cf3e28e93bbd7a9bcc6d"/><file name="Esi.php" hash="aaa0104a9527d452351bb4d40832ae37"/><file name="Purge.php" hash="881f6f33eafb39f8a1c9d87e8221ef15"/></dir><file name="Session.php" hash="08092ba5488fddb0fb7f9b50a7fad1e2"/><file name="Translate.php" hash="35326b8d2214f516d7dba82519902529"/></dir><dir name="controllers"><file name="AdminController.php" hash="76106610794b3fce7fa5c3a8283b6d7e"/><dir name="Adminhtml"><file name="LitemageCacheController.php" hash="506c63ddec598d39fa8a1dd1e58549d9"/></dir><file name="EsiController.php" hash="d1206f3dcec0a5e3547be302139a41c4"/></dir><dir name="etc"><file name="config.xml" hash="a47e247a62f99aa0bec0edf7162666dd"/><file name="system.xml" hash="124683c84743ecff2dc9cb5d6d8dc24b"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="litemage.xml" hash="f4dd1848120e353da9a84a7fd5565093"/></dir><dir name="template"><dir name="litemage"><file name="cache_management.phtml" hash="478836f2a9aa54e6d1e3fbf2164bbfcc"/><file name="category_save.phtml" hash="b29d102b8f90ce4da881a30efa3b2838"/><file name="product_save.phtml" hash="01863cb9acd33ca51db4f2a26e233eec"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="litemage.xml" hash="4c840b12cc6246f68b1b028f0ef1056d"/></dir><dir name="template"><dir name="litemage"><dir name="inject"><file name="jsvar.phtml" hash="5bbd9992e7ba5925d09f21cf03237676"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Litespeed_Litemage.xml" hash="ba0c8904bc89219c6829e37cc14d9bdd"/></dir></target><target name="mage"><dir name="shell"><file name="litemage_purge.php" hash="fbcc05832098dfbda5d30bfe24973fab"/></dir></target></contents>
21
  <compatible/>
22
+ <dependencies><required><php><min>5.3.0</min><max>7.2.0</max></php></required></dependencies>
23
  </package>