Version Notes
Fixed a bug where AJAX output containing ESI blocks could break JSON format.
Fixed a bug where an external extension setting the layout cache ID.
Improved compatibility for Magento 1.7 stores not using form_key.
Improved compatibility with customized themes.
Download this release
Release Info
Developer | LiteSpeed Technologies |
Extension | LiteSpeed_LiteMage |
Version | 1.3.5 |
Comparing to | |
See all releases |
Code changes from version 1.3.4 to 1.3.5
- app/code/community/Litespeed/Litemage/Helper/Data.php +6 -0
- app/code/community/Litespeed/Litemage/Helper/Esi.php +17 -16
- app/code/community/Litespeed/Litemage/Model/Layout/Update.php +33 -0
- app/code/community/Litespeed/Litemage/Model/Observer/Cron.php +1 -1
- app/code/community/Litespeed/Litemage/Model/Observer/Esi.php +45 -10
- app/code/community/Litespeed/Litemage/controllers/EsiController.php +39 -9
- app/code/community/Litespeed/Litemage/etc/config.xml +1 -1
- app/code/community/Litespeed/Litemage/etc/system.xml +1 -1
- package.xml +9 -6
app/code/community/Litespeed/Litemage/Helper/Data.php
CHANGED
@@ -670,6 +670,12 @@ class Litespeed_Litemage_Helper_Data extends Mage_Core_Helper_Abstract
|
|
670 |
{
|
671 |
return $this->getConf($name, self::CFG_NOCACHE) ;
|
672 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
673 |
|
674 |
public function getConf( $name, $type = '' )
|
675 |
{
|
670 |
{
|
671 |
return $this->getConf($name, self::CFG_NOCACHE) ;
|
672 |
}
|
673 |
+
|
674 |
+
public function isWholeRouteCache($actionName)
|
675 |
+
{
|
676 |
+
return in_array($actionName,
|
677 |
+
$this->getConf(Litespeed_Litemage_Helper_Data::CFG_FULLCACHE_ROUTE, self::CFG_NOCACHE));
|
678 |
+
}
|
679 |
|
680 |
public function getConf( $name, $type = '' )
|
681 |
{
|
app/code/community/Litespeed/Litemage/Helper/Esi.php
CHANGED
@@ -175,25 +175,27 @@ class Litespeed_Litemage_Helper_Esi
|
|
175 |
$this->_cacheVars['internal']['nickname'] = 1; // replaced
|
176 |
}
|
177 |
|
178 |
-
public function addPrivatePurgeEvent( $eventName )
|
179 |
{
|
180 |
// always set purge header, due to ajax call, before_reponse_send will not be triggered, also it may die out in the middle, so must set raw header using php directly
|
181 |
if (isset($this->_esiPurgeEvents[$eventName]))
|
182 |
return;
|
183 |
|
184 |
-
$
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
|
|
|
|
197 |
|
198 |
if (count($tags)) {
|
199 |
$purgeHeader = 'private,' ;
|
@@ -569,7 +571,6 @@ class Litespeed_Litemage_Helper_Esi
|
|
569 |
$tracker = '' ;
|
570 |
$sharedParams = $this->getEsiSharedParams();
|
571 |
$esiIncludeTag = $this->_config->esiTag('include');
|
572 |
-
|
573 |
if ( (($this->_cacheVars['flag'] & self::CHBM_FORMKEY_REPLACED) != 0) && strpos($responseBody, self::FORMKEY_REPLACE) ) {
|
574 |
// use single quote for pagespeed module
|
575 |
$replace = '<' . $esiIncludeTag . " src='" . $this->getEsiBaseUrl() . "litemage/esi/getFormKey' as-var='1' combine='sub' cache-control='no-vary,private' cache-tag='E.formkey'/>" ;
|
@@ -628,7 +629,7 @@ class Litespeed_Litemage_Helper_Esi
|
|
628 |
$isAjax = $this->_cacheVars['internal']['is_ajax'];
|
629 |
// json output will add slashes
|
630 |
if ($isAjax) {
|
631 |
-
$responseBody = preg_replace_callback('|src=\'.*\\\/litemage\\\/esi
|
632 |
function ($matches) {
|
633 |
$b = stripslashes($matches[0]);
|
634 |
$c = preg_replace('/\/esi\/([^\/]+)\//', '/esi/$1/ajax/strip/', $b);
|
175 |
$this->_cacheVars['internal']['nickname'] = 1; // replaced
|
176 |
}
|
177 |
|
178 |
+
public function addPrivatePurgeEvent( $eventName, $tags=null )
|
179 |
{
|
180 |
// always set purge header, due to ajax call, before_reponse_send will not be triggered, also it may die out in the middle, so must set raw header using php directly
|
181 |
if (isset($this->_esiPurgeEvents[$eventName]))
|
182 |
return;
|
183 |
|
184 |
+
if ($tags == null) {
|
185 |
+
$tags = array() ;
|
186 |
+
$this->_esiPurgeEvents[$eventName] = $eventName ;
|
187 |
+
|
188 |
+
$events = $this->_config->getEsiConf('event');
|
189 |
+
foreach ( $this->_esiPurgeEvents as $e ) {
|
190 |
+
if (isset($events[$e])) {
|
191 |
+
foreach($events[$e] as $t) {
|
192 |
+
if (!in_array($t, $tags)) {
|
193 |
+
$tags[] = $t;
|
194 |
+
}
|
195 |
+
}
|
196 |
+
}
|
197 |
+
}
|
198 |
+
}
|
199 |
|
200 |
if (count($tags)) {
|
201 |
$purgeHeader = 'private,' ;
|
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'/>" ;
|
629 |
$isAjax = $this->_cacheVars['internal']['is_ajax'];
|
630 |
// json output will add slashes
|
631 |
if ($isAjax) {
|
632 |
+
$responseBody = preg_replace_callback('|src=\'.*\\\/litemage\\\/esi\\\/[^>]+\\\/>|U',
|
633 |
function ($matches) {
|
634 |
$b = stripslashes($matches[0]);
|
635 |
$c = preg_replace('/\/esi\/([^\/]+)\//', '/esi/$1/ajax/strip/', $b);
|
app/code/community/Litespeed/Litemage/Model/Layout/Update.php
CHANGED
@@ -44,6 +44,7 @@ class Litespeed_Litemage_Model_Layout_Update extends Mage_Core_Model_Layout_Upda
|
|
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->_isDebug = Mage::helper('litemage/data')->isDebug() ;
|
48 |
}
|
49 |
parent::__construct() ;
|
@@ -68,6 +69,12 @@ class Litespeed_Litemage_Model_Layout_Update extends Mage_Core_Model_Layout_Upda
|
|
68 |
|
69 |
public function getUsedHandles()
|
70 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
return array_keys($this->_handleUpdates) ;
|
72 |
}
|
73 |
|
@@ -140,9 +147,30 @@ class Litespeed_Litemage_Model_Layout_Update extends Mage_Core_Model_Layout_Upda
|
|
140 |
$tags[] = 'LITEMAGE_MODIFY' ;
|
141 |
$this->_cacheId = 'LAYOUT_' . Mage::app()->getStore()->getId() . md5(join('__', $tags)) ;
|
142 |
}
|
|
|
|
|
|
|
|
|
143 |
return $this->_cacheId ;
|
144 |
}
|
145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
public function loadCache()
|
147 |
{
|
148 |
if ( ! Mage::app()->useCache('layout') ) {
|
@@ -233,6 +261,11 @@ class Litespeed_Litemage_Model_Layout_Update extends Mage_Core_Model_Layout_Upda
|
|
233 |
|
234 |
public function getBlockHandles( $blockNameList )
|
235 |
{
|
|
|
|
|
|
|
|
|
|
|
236 |
if ( $this->_handleXml == null ) {
|
237 |
$this->_handleXml = array() ;
|
238 |
foreach ( $this->_handleUpdates as $h => $update ) {
|
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() ;
|
69 |
|
70 |
public function getUsedHandles()
|
71 |
{
|
72 |
+
if ( !$this->_modified ) {
|
73 |
+
if ( $this->_isDebug ) {
|
74 |
+
Mage::helper('litemage/data')->debugMesg('LayoutUpdate SHOULD NOT GET HERE getUsedHandles');
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
return array_keys($this->_handleUpdates) ;
|
79 |
}
|
80 |
|
147 |
$tags[] = 'LITEMAGE_MODIFY' ;
|
148 |
$this->_cacheId = 'LAYOUT_' . Mage::app()->getStore()->getId() . md5(join('__', $tags)) ;
|
149 |
}
|
150 |
+
elseif (empty($this->_layoutHandles)) {
|
151 |
+
// cacheId is set through setCacheId from outside, so handles not initialized
|
152 |
+
$this->_layoutHandles = $this->getHandles() ;
|
153 |
+
}
|
154 |
return $this->_cacheId ;
|
155 |
}
|
156 |
|
157 |
+
/**
|
158 |
+
* Set cache id
|
159 |
+
*
|
160 |
+
* @param string $cacheId
|
161 |
+
* @return Litespeed_Litemage_Model_Layout_Update
|
162 |
+
*/
|
163 |
+
public function setCacheId($cacheId)
|
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) ;
|
172 |
+
}
|
173 |
+
|
174 |
public function loadCache()
|
175 |
{
|
176 |
if ( ! Mage::app()->useCache('layout') ) {
|
261 |
|
262 |
public function getBlockHandles( $blockNameList )
|
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 ) {
|
270 |
$this->_handleXml = array() ;
|
271 |
foreach ( $this->_handleUpdates as $h => $update ) {
|
app/code/community/Litespeed/Litemage/Model/Observer/Cron.php
CHANGED
@@ -155,7 +155,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'] = $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' ;
|
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' ;
|
app/code/community/Litespeed/Litemage/Model/Observer/Esi.php
CHANGED
@@ -71,6 +71,7 @@ class Litespeed_Litemage_Model_Observer_Esi extends Varien_Event_Observer
|
|
71 |
$this->_viewVary[] = 'env';
|
72 |
$this->_viewVary[] = 'review';
|
73 |
$this->_internal['purgeUserPrivateCache'] = 1;
|
|
|
74 |
}
|
75 |
}
|
76 |
|
@@ -179,7 +180,7 @@ class Litespeed_Litemage_Model_Observer_Esi extends Varien_Event_Observer
|
|
179 |
$this->_viewVary[] = 'toolbar' ;
|
180 |
Mage::Helper('litemage/viewvary')->restoreViewVary($this->_viewVary) ;
|
181 |
}
|
182 |
-
elseif (
|
183 |
$this->_setWholeRouteCache($curActionName, $controller);
|
184 |
}
|
185 |
|
@@ -384,13 +385,51 @@ class Litespeed_Litemage_Model_Observer_Esi extends Varien_Event_Observer
|
|
384 |
return ;
|
385 |
|
386 |
$this->_helper->initFormKey() ;
|
387 |
-
|
388 |
foreach ( $this->_injectedBlocks as $block ) {
|
389 |
-
$this->_injectEsiBlock($block);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
390 |
}
|
391 |
|
392 |
$this->_startDynamic = true;
|
393 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
394 |
|
395 |
protected function _injectEsiBlock($block)
|
396 |
{
|
@@ -414,10 +453,8 @@ class Litespeed_Litemage_Model_Observer_Esi extends Varien_Event_Observer
|
|
414 |
{
|
415 |
$app = Mage::app();
|
416 |
$design = Mage::getDesign() ;
|
417 |
-
|
418 |
-
$tags[] = $
|
419 |
-
$tags[] = $design->getPackageName();
|
420 |
-
$tags[] = $design->getTheme('layout') . '_' . $design->getTheme('template') . '_' . $design->getTheme('skin');
|
421 |
$cacheId = 'LITEMAGE_ROUTE_' . md5(join('__', $tags));
|
422 |
|
423 |
$this->_routeCache = array('actionName' => $actionName, 'cacheId' => $cacheId);
|
@@ -515,9 +552,7 @@ class Litespeed_Litemage_Model_Observer_Esi extends Varien_Event_Observer
|
|
515 |
{
|
516 |
if ( $this->_moduleEnabledForUser ) {
|
517 |
if ($value = Mage::registry('LITEMAGE_NEWVISITOR')) {
|
518 |
-
|
519 |
-
Mage::unregister('LITEMAGE_NEWVISITOR'); // to be safe
|
520 |
-
}
|
521 |
}
|
522 |
else {
|
523 |
Mage::register('LITEMAGE_NEWVISITOR', 2);
|
71 |
$this->_viewVary[] = 'env';
|
72 |
$this->_viewVary[] = 'review';
|
73 |
$this->_internal['purgeUserPrivateCache'] = 1;
|
74 |
+
$this->_helper->addPrivatePurgeEvent($eventObj->getEvent()->getName(), array('*')) ;
|
75 |
}
|
76 |
}
|
77 |
|
180 |
$this->_viewVary[] = 'toolbar' ;
|
181 |
Mage::Helper('litemage/viewvary')->restoreViewVary($this->_viewVary) ;
|
182 |
}
|
183 |
+
elseif ($this->_config->isWholeRouteCache($curActionName)) {
|
184 |
$this->_setWholeRouteCache($curActionName, $controller);
|
185 |
}
|
186 |
|
385 |
return ;
|
386 |
|
387 |
$this->_helper->initFormKey() ;
|
388 |
+
|
389 |
foreach ( $this->_injectedBlocks as $block ) {
|
390 |
+
$esiBlock = $this->_injectEsiBlock($block);
|
391 |
+
$block->setData('litemage_lost', $esiBlock);
|
392 |
+
}
|
393 |
+
|
394 |
+
if (count($this->_injectedBlocks)) {
|
395 |
+
$layout = $this->_injectedBlocks[0]->getLayout();
|
396 |
+
// only check header for now, this is to capture bad coded themes
|
397 |
+
$this->_catchLostChildBlocks('header', $layout->getBlock('header'));
|
398 |
}
|
399 |
|
400 |
$this->_startDynamic = true;
|
401 |
}
|
402 |
+
|
403 |
+
protected function _catchLostChildBlocks($alias, $block, $parent=null)
|
404 |
+
{
|
405 |
+
if ($block == null
|
406 |
+
|| $block instanceof Litespeed_Litemage_Block_Core_Esi
|
407 |
+
|| $block instanceof Litespeed_Litemage_Block_Core_Messages) {
|
408 |
+
return;
|
409 |
+
}
|
410 |
+
|
411 |
+
if ($esiReplace = $block->getData('litemage_lost')) {
|
412 |
+
$msg = 'Found Lost child ' . $alias;
|
413 |
+
if ($parent === null) {
|
414 |
+
$msg .= ' - EMPTY PARENT - Ignore';
|
415 |
+
}
|
416 |
+
else {
|
417 |
+
$msg .= ' - REPLACED';
|
418 |
+
$oldParent = $esiReplace->getParentBlock(); // reserve the old parent
|
419 |
+
$parent->setChild($alias, $esiReplace);
|
420 |
+
$esiReplace->setParentBlock($oldParent);
|
421 |
+
}
|
422 |
+
if ($this->_isDebug) {
|
423 |
+
$this->_config->debugMesg('_catchLostChildBlocks ' . $msg) ;
|
424 |
+
}
|
425 |
+
}
|
426 |
+
else {
|
427 |
+
$children = $block->getChild();
|
428 |
+
foreach ($children as $alias => $child) {
|
429 |
+
$this->_catchLostChildBlocks($alias, $child, $block);
|
430 |
+
}
|
431 |
+
}
|
432 |
+
}
|
433 |
|
434 |
protected function _injectEsiBlock($block)
|
435 |
{
|
453 |
{
|
454 |
$app = Mage::app();
|
455 |
$design = Mage::getDesign() ;
|
456 |
+
$tags = $this->_helper->getEsiSharedParams();
|
457 |
+
$tags[] = $actionName;
|
|
|
|
|
458 |
$cacheId = 'LITEMAGE_ROUTE_' . md5(join('__', $tags));
|
459 |
|
460 |
$this->_routeCache = array('actionName' => $actionName, 'cacheId' => $cacheId);
|
552 |
{
|
553 |
if ( $this->_moduleEnabledForUser ) {
|
554 |
if ($value = Mage::registry('LITEMAGE_NEWVISITOR')) {
|
555 |
+
Mage::unregister('LITEMAGE_NEWVISITOR'); // to be safe
|
|
|
|
|
556 |
}
|
557 |
else {
|
558 |
Mage::register('LITEMAGE_NEWVISITOR', 2);
|
app/code/community/Litespeed/Litemage/controllers/EsiController.php
CHANGED
@@ -160,9 +160,17 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
|
|
160 |
unset($esiIncludes[$key]) ;
|
161 |
// need to add getformkey
|
162 |
$extraUrls = array_keys($this->_esiCache);
|
163 |
-
$
|
|
|
164 |
if ( $this->_isDebug ) {
|
165 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
166 |
}
|
167 |
}
|
168 |
else {
|
@@ -330,6 +338,7 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
|
|
330 |
if ( $this->_isDebug ) {
|
331 |
switch ($refreshed) {
|
332 |
case -1: $status = ':no_cache' ; break;
|
|
|
333 |
case 1: $status = ':upd_entry' ; break;
|
334 |
case 2: $status = ':upd_detail' ; break;
|
335 |
case 3: $status = ':match_shared' ; break;
|
@@ -353,6 +362,9 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
|
|
353 |
|
354 |
if ( $this->_env['cache_updated'] && $this->_config->useInternalCache() ) {
|
355 |
$this->_config->saveInternalCache(serialize($this->_esiCache), $this->_env['cache_id']) ;
|
|
|
|
|
|
|
356 |
}
|
357 |
}
|
358 |
|
@@ -506,7 +518,9 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
|
|
506 |
protected function _initEnv( $esiData )
|
507 |
{
|
508 |
$session = Mage::getSingleton('core/session');
|
509 |
-
if (($session->getData('_litemage_user') == 1)
|
|
|
|
|
510 |
if (Mage::registry('LITEMAGE_NEWVISITOR')) {
|
511 |
$this->_env['shared'] = true ;
|
512 |
}
|
@@ -517,9 +531,6 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
|
|
517 |
$this->_env['shared'] = true ;
|
518 |
}
|
519 |
}
|
520 |
-
else { // prior to 1.9
|
521 |
-
$this->_env['shared'] = true ;
|
522 |
-
}
|
523 |
}
|
524 |
}
|
525 |
$session->setData('_litemage_user', 3);
|
@@ -571,16 +582,26 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
|
|
571 |
$this->_env['defaultHandles'] = array( 'customer_logged_out' ) ;
|
572 |
}
|
573 |
|
574 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
575 |
|
576 |
$this->_env['cache_id'] = self::ESICACHE_ID . '_' . md5($unique) ;
|
577 |
$this->_env['cache_updated'] = false ;
|
|
|
578 |
$this->_env['layout_unique'] = $unique . '__' . $this->_env['defaultHandles'][0] ;
|
579 |
|
580 |
$this->_esiCache = array() ;
|
581 |
if ( Mage::app()->useCache('layout') ) {
|
582 |
if ( $data = Mage::app()->loadCache($this->_env['cache_id']) ) {
|
583 |
$this->_esiCache = unserialize($data) ;
|
|
|
|
|
|
|
584 |
}
|
585 |
}
|
586 |
|
@@ -595,7 +616,8 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
|
|
595 |
return null ;
|
596 |
}
|
597 |
|
598 |
-
// return -1:
|
|
|
599 |
protected function _refreshCacheEntry( $url, $esiData, &$inlineHtml )
|
600 |
{
|
601 |
$cacheAttr = $esiData->getCacheAttribute() ;
|
@@ -603,7 +625,15 @@ class Litespeed_Litemage_EsiController extends Mage_Core_Controller_Front_Action
|
|
603 |
return -1 ;
|
604 |
}
|
605 |
|
606 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
607 |
|
608 |
if ( $this->_env['shared'] ) {
|
609 |
if (!isset($this->_esiCache[$url])
|
160 |
unset($esiIncludes[$key]) ;
|
161 |
// need to add getformkey
|
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))
|
169 |
+
$esiInclude1[] = $uri;
|
170 |
+
else
|
171 |
+
$esiInclude1[] = '* ' . $uri;
|
172 |
+
}
|
173 |
+
$this->_config->debugMesg('combined includes * = ' . print_r($esiInclude1, true)) ;
|
174 |
}
|
175 |
}
|
176 |
else {
|
338 |
if ( $this->_isDebug ) {
|
339 |
switch ($refreshed) {
|
340 |
case -1: $status = ':no_cache' ; break;
|
341 |
+
case -2: $status = ':param_mismatch' ; break;
|
342 |
case 1: $status = ':upd_entry' ; break;
|
343 |
case 2: $status = ':upd_detail' ; break;
|
344 |
case 3: $status = ':match_shared' ; break;
|
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 |
}
|
370 |
|
518 |
protected function _initEnv( $esiData )
|
519 |
{
|
520 |
$session = Mage::getSingleton('core/session');
|
521 |
+
if (($session->getData('_litemage_user') == 1)
|
522 |
+
&& (Mage::registry('current_customer') == null)
|
523 |
+
&& (!Mage::getSingleton('customer/session')->isLoggedIn())) {
|
524 |
if (Mage::registry('LITEMAGE_NEWVISITOR')) {
|
525 |
$this->_env['shared'] = true ;
|
526 |
}
|
531 |
$this->_env['shared'] = true ;
|
532 |
}
|
533 |
}
|
|
|
|
|
|
|
534 |
}
|
535 |
}
|
536 |
$session->setData('_litemage_user', 3);
|
582 |
$this->_env['defaultHandles'] = array( 'customer_logged_out' ) ;
|
583 |
}
|
584 |
|
585 |
+
$sharedParams = $this->_helper->getEsiSharedParams();
|
586 |
+
$sharedUrlParts = '';
|
587 |
+
|
588 |
+
foreach ( $sharedParams as $key => $value ) {
|
589 |
+
$sharedUrlParts .= $key . '/' . $value . '/';
|
590 |
+
}
|
591 |
+
$unique = join('__', $sharedParams) ;
|
592 |
|
593 |
$this->_env['cache_id'] = self::ESICACHE_ID . '_' . md5($unique) ;
|
594 |
$this->_env['cache_updated'] = false ;
|
595 |
+
$this->_env['shared_url_parts'] = $sharedUrlParts;
|
596 |
$this->_env['layout_unique'] = $unique . '__' . $this->_env['defaultHandles'][0] ;
|
597 |
|
598 |
$this->_esiCache = array() ;
|
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 |
}
|
607 |
|
616 |
return null ;
|
617 |
}
|
618 |
|
619 |
+
// return -1: no_cache, 0: no update, 1: update entry, 2: update detail, 3: match shared, -2: shared url param not match
|
620 |
+
|
621 |
protected function _refreshCacheEntry( $url, $esiData, &$inlineHtml )
|
622 |
{
|
623 |
$cacheAttr = $esiData->getCacheAttribute() ;
|
625 |
return -1 ;
|
626 |
}
|
627 |
|
628 |
+
$esiAction = $esiData->getAction();
|
629 |
+
$isFormKey = ($esiAction == Litespeed_Litemage_Model_EsiData::ACTION_GET_FORMKEY );
|
630 |
+
|
631 |
+
// validate against shared param
|
632 |
+
if (!$isFormKey
|
633 |
+
&& ($esiAction != Litespeed_Litemage_Model_EsiData::ACTION_GET_NICKNAME)
|
634 |
+
&& (strpos($url, $this->_env['shared_url_parts']) === false)) {
|
635 |
+
return -2;
|
636 |
+
}
|
637 |
|
638 |
if ( $this->_env['shared'] ) {
|
639 |
if (!isset($this->_esiCache[$url])
|
app/code/community/Litespeed/Litemage/etc/config.xml
CHANGED
@@ -26,7 +26,7 @@
|
|
26 |
<config>
|
27 |
<modules>
|
28 |
<Litespeed_Litemage>
|
29 |
-
<version>1.3.
|
30 |
</Litespeed_Litemage>
|
31 |
</modules>
|
32 |
<global>
|
26 |
<config>
|
27 |
<modules>
|
28 |
<Litespeed_Litemage>
|
29 |
+
<version>1.3.5</version>
|
30 |
</Litespeed_Litemage>
|
31 |
</modules>
|
32 |
<global>
|
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.
|
31 |
<sort_order>5000</sort_order>
|
32 |
</Litespeed_Litemage>
|
33 |
</tabs>
|
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>
|
package.xml
CHANGED
@@ -1,19 +1,22 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>LiteSpeed_LiteMage</name>
|
4 |
-
<version>1.3.
|
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>
|
12 |
-
|
|
|
|
|
|
|
13 |
<authors><author><name>LiteSpeed Technologies</name><user>LiteSpeedTech</user><email>lsong@litespeedtech.com</email></author></authors>
|
14 |
-
<date>2017-
|
15 |
-
<time>
|
16 |
-
<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="
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.3.0</min><max>7.1.0</max></php></required></dependencies>
|
19 |
</package>
|
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.
|
12 |
+
Fixed a bug where an external extension setting the layout cache ID.
|
13 |
+
Improved compatibility for Magento 1.7 stores not using form_key.
|
14 |
+
Improved compatibility with customized themes.
|
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>
|