Skip to content

Commit

Permalink
Merge pull request #1062 from nexcess/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
miguelbalparda committed Jan 14, 2016
2 parents 35d44f5 + b6ca483 commit 6ffc751
Show file tree
Hide file tree
Showing 45 changed files with 1,841 additions and 1,582 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,4 +419,16 @@ Magento CE 1.8+ or EE 1.13+, see [these instructions](https://github.com/nexcess
* [#945] Send unmodified url to the backend server (@thampe)
* [#885] Add maintenance mode that will allow debug_ips through to visit the site, all other users get the landing page (@craigcarnell)
* [#955] Include theme specific handles to ESI data (@LyndonHook)
* [#972] Fixed bug with wrong return value of ->getSkinUrl() (@ceckoslab)
* [#972] Fixed bug with wrong return value of ->getSkinUrl() (@ceckoslab)

### RELEASE-0.6.7
* [#951] Added 'disableEsiInjection' ESI policy option.
* [#1005] Invalidating cms pages with url enging with slash. (@sivaschenko)
* [#1020] Add the form key to wishlist submit to prevent 403 errors. (@paulpartington)
* [#1036] Prime Checkout and Light Checkout Compatibility. (@sprankhub)
* [#1050] Use Simple Hash" option for static files. (@jeroenvermeulen)
* [#1031] Improved helper function getModelName(). (@jeroenvermeulen)
* [#1066] Fix for crawler lock problem with CM_RedisSession. (@jeroenvermeulen)

### RELEASE-0.6.8
* [#1065] Added ESI policy for cookie notice block. (@aricwatson)
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# [Nexcess.net](https://www.nexcess.net/) Turpentine Extension for Magento
[![Build Status](https://travis-ci.org/nexcess/magento-turpentine.png?branch=master,devel)](https://travis-ci.org/nexcess/magento-turpentine)
[![Scrutinizer](https://scrutinizer-ci.com/g/nexcess/magento-turpentine/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/nexcess/magento-turpentine/)

Turpentine is a full page cache extension for [Magento](https://www.magentocommerce.com/)
that works with [Varnish](https://www.varnish-cache.org/), a very fast caching reverse-proxy. By
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ protected function _prepareCollection()
$fullPageEnabled = false;
foreach ($collection as $key=>$item)
{
if($item->getStatus()==1 && ($item->getId()=='turpentine_pages' || $item->getId()=='turpentine_esi_blocks'))
if ($item->getStatus() == 1 && ($item->getId() == 'turpentine_pages' || $item->getId() == 'turpentine_esi_blocks'))
{
$turpentineEnabled = true;
}
if($item->getStatus()==1 && $item->getId()=='full_page')
if ($item->getStatus() == 1 && $item->getId() == 'full_page')
{
$fullPageEnabled = true;
}
}
if($turpentineEnabled)
if ($turpentineEnabled)
{
$collection->removeItemByKey('full_page');
}
if($fullPageEnabled)
if ($fullPageEnabled)
{
$collection->removeItemByKey('turpentine_pages');
$collection->removeItemByKey('turpentine_esi_blocks');
Expand Down
130 changes: 65 additions & 65 deletions app/code/community/Nexcessnet/Turpentine/Block/Core/Messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ class Nexcessnet_Turpentine_Block_Core_Messages extends Mage_Core_Block_Messages
* can't use null because that is the default so no way to tell between
* the default and not actually calling it
*/
const NO_SINGLE_RENDER_TYPE = -1;
const NO_SINGLE_RENDER_TYPE = -1;

/**
* Hold the message type to call getHtml with
* @var mixed
*/
protected $_singleRenderType = null;
protected $_singleRenderType = null;

/**
* Sentinel to check if the toHtml method was skipped (getGroupedHtml was
Expand All @@ -41,7 +41,7 @@ class Nexcessnet_Turpentine_Block_Core_Messages extends Mage_Core_Block_Messages
*
* @var boolean
*/
protected $_directCall = false;
protected $_directCall = false;

/**
* List of session types to load messages from for the "messages" block.
Expand All @@ -65,10 +65,10 @@ class Nexcessnet_Turpentine_Block_Core_Messages extends Mage_Core_Block_Messages
*
* @var array
*/
protected $_usedStorageTypes = array( 'core/session' );
protected $_usedStorageTypes = array('core/session');

public function _prepareLayout() {
if( $this->_fixMessages() ) {
if ($this->_fixMessages()) {
/* do nothing */
return $this;
} else {
Expand All @@ -82,11 +82,11 @@ public function _prepareLayout() {
* @param Mage_Core_Model_Message_Collection $messages
* @return Mage_Core_Block_Messages
*/
public function setMessages( Mage_Core_Model_Message_Collection $messages ) {
if( $this->_fixMessages() ) {
$this->_saveMessages( $messages->getItems() );
public function setMessages(Mage_Core_Model_Message_Collection $messages) {
if ($this->_fixMessages()) {
$this->_saveMessages($messages->getItems());
} else {
parent::setMessages( $messages );
parent::setMessages($messages);
}
return $this;
}
Expand All @@ -97,11 +97,11 @@ public function setMessages( Mage_Core_Model_Message_Collection $messages ) {
* @param Mage_Core_Model_Message_Collection $messages
* @return Mage_Core_Block_Messages
*/
public function addMessages( Mage_Core_Model_Message_Collection $messages ) {
if( $this->_fixMessages() ) {
$this->_saveMessages( $messages->getItems() );
public function addMessages(Mage_Core_Model_Message_Collection $messages) {
if ($this->_fixMessages()) {
$this->_saveMessages($messages->getItems());
} else {
parent::addMessages( $messages );
parent::addMessages($messages);
}
return $this;
}
Expand All @@ -112,11 +112,11 @@ public function addMessages( Mage_Core_Model_Message_Collection $messages ) {
* @param Mage_Core_Model_Message_Abstract $message
* @return Mage_Core_Block_Messages
*/
public function addMessage( Mage_Core_Model_Message_Abstract $message ) {
if( $this->_fixMessages() ) {
$this->_saveMessages( array( $message ) );
public function addMessage(Mage_Core_Model_Message_Abstract $message) {
if ($this->_fixMessages()) {
$this->_saveMessages(array($message));
} else {
parent::addMessage( $message );
parent::addMessage($message);
}
return $this;
}
Expand All @@ -125,12 +125,11 @@ public function addMessage( Mage_Core_Model_Message_Abstract $message ) {
* Override this in case some dumb layout decides to use it instead of the
* standard toHtml stuff
*
* @param mixed $type=self::NO_SINGLE_RENDER_TYPE
* @return string
*/
public function getHtml( $type=self::NO_SINGLE_RENDER_TYPE ) {
public function getHtml($type = self::NO_SINGLE_RENDER_TYPE) {
$this->_singleRenderType = $type;
return $this->_handleDirectCall( 'getHtml' )->toHtml();
return $this->_handleDirectCall('getHtml')->toHtml();
}

/**
Expand All @@ -140,7 +139,7 @@ public function getHtml( $type=self::NO_SINGLE_RENDER_TYPE ) {
* @return string
*/
public function getGroupedHtml() {
return $this->_handleDirectCall( 'getGroupedHtml' )->toHtml();
return $this->_handleDirectCall('getGroupedHtml')->toHtml();
}

/**
Expand All @@ -150,37 +149,38 @@ public function getGroupedHtml() {
*
* @param string $type
*/
public function addStorageType( $type ) {
public function addStorageType($type) {
$this->_usedStorageTypes[] = $type;
}

/**
* Load layout options
*
* @return null
* @param string $methodCalled
* @return Nexcessnet_Turpentine_Block_Core_Messages
*/
protected function _handleDirectCall( $methodCalled ) {
protected function _handleDirectCall($methodCalled) {
// this doesn't actually do anything because _real_toHtml() won't be
// called in this request context (unless the flash message isn't
// actually supposed to be ajax/esi'd in)
$this->_directCall = $methodCalled;
if( $this->_fixMessages() ) {
if ($this->_fixMessages()) {
$layout = $this->getLayout();
$layoutUpdate = $layout->getUpdate()->load( 'default' );
if( Mage::app()->useCache( 'layout' ) ) {
$layoutUpdate = $layout->getUpdate()->load('default');
if (Mage::app()->useCache('layout')) {
// this is skipped in the layout update load() if the "layout"
// cache is enabled, which seems to cause the esi layout stuff
// to not load, so we manually do it here
foreach( $layoutUpdate->getHandles() as $handle ) {
$layoutUpdate->merge( $handle );
foreach ($layoutUpdate->getHandles() as $handle) {
$layoutUpdate->merge($handle);
}
}
$layout->generateXml();
$layoutShim = Mage::getSingleton( 'turpentine/shim_mage_core_layout' );
foreach( $layout->getNode()->xpath(
sprintf( '//reference[@name=\'%s\']/action',
$this->getNameInLayout() ) ) as $node ) {
$layoutShim->shim_generateAction( $node );
$layoutShim = Mage::getSingleton('turpentine/shim_mage_core_layout');
foreach ($layout->getNode()->xpath(
sprintf('//reference[@name=\'%s\']/action',
$this->getNameInLayout()) ) as $node) {
$layoutShim->shim_generateAction($node);
}
}
return $this;
Expand All @@ -192,13 +192,13 @@ protected function _handleDirectCall( $methodCalled ) {
* @return string
*/
protected function _toHtml() {
if( $this->_fixMessages() ) {
if( $this->_shouldUseInjection() ) {
if ($this->_fixMessages()) {
if ($this->_shouldUseInjection()) {
$html = $this->renderView();
} else {
$this->_loadMessages();
$this->_loadSavedMessages();
if ( count($this->getMessages()) ) {
if (count($this->getMessages())) {
$html = $this->_real_toHtml();
} else {
// Prevent returning an empty <ul></ul>
Expand All @@ -219,7 +219,7 @@ protected function _toHtml() {
*/
protected function _hasInjectOptions() {
return $this->getEsiOptions() &&
Mage::helper( 'turpentine/esi' )->shouldResponseUseEsi();
Mage::helper('turpentine/esi')->shouldResponseUseEsi();
}

/**
Expand All @@ -241,18 +241,18 @@ protected function _shouldUseInjection() {
* @return boolean
*/
protected function _hasTemplateSet() {
return (bool)$this->getTemplate();
return (bool) $this->getTemplate();
}

/**
* Preserve messages for later display
*
* @return null
*/
protected function _saveMessages( $messages ) {
if( $this->_fixMessages() && !$this->_isEsiRequest() ) {
Mage::getSingleton( 'turpentine/session' )
->saveMessages( $this->getNameInLayout(), $messages );
protected function _saveMessages($messages) {
if ($this->_fixMessages() && ! $this->_isEsiRequest()) {
Mage::getSingleton('turpentine/session')
->saveMessages($this->getNameInLayout(), $messages);
}
}

Expand All @@ -262,14 +262,14 @@ protected function _saveMessages( $messages ) {
* @return null
*/
protected function _loadMessages() {
if( $this->getNameInLayout() == 'messages' ) {
foreach( $this->_messageStorageTypes as $type ) {
$storage = sprintf( '%s/session', $type );
$this->addStorageType( $storage );
$this->_loadMessagesFromStorage( $storage );
if ($this->getNameInLayout() == 'messages') {
foreach ($this->_messageStorageTypes as $type) {
$storage = sprintf('%s/session', $type);
$this->addStorageType($storage);
$this->_loadMessagesFromStorage($storage);
}
} else {
$this->_loadMessagesFromStorage( 'core/session' );
$this->_loadMessagesFromStorage('core/session');
}
}

Expand All @@ -279,9 +279,9 @@ protected function _loadMessages() {
* @return null
*/
protected function _loadSavedMessages() {
$session = Mage::getSingleton( 'turpentine/session' );
foreach( $session->loadMessages( $this->getNameInLayout() ) as $msg ) {
parent::addMessage( $msg );
$session = Mage::getSingleton('turpentine/session');
foreach ($session->loadMessages($this->getNameInLayout()) as $msg) {
parent::addMessage($msg);
}
$this->_clearMessages();
}
Expand All @@ -292,10 +292,10 @@ protected function _loadSavedMessages() {
* @param string $type
* @return null
*/
protected function _loadMessagesFromStorage( $type ) {
foreach( Mage::getSingleton( $type )
->getMessages( true )->getItems() as $msg ) {
parent::addMessage( $msg );
protected function _loadMessagesFromStorage($type) {
foreach (Mage::getSingleton($type)
->getMessages(true)->getItems() as $msg) {
parent::addMessage($msg);
}
}

Expand All @@ -305,8 +305,8 @@ protected function _loadMessagesFromStorage( $type ) {
* @return null
*/
protected function _clearMessages() {
Mage::getSingleton( 'turpentine/session' )
->clearMessages( $this->getNameInLayout() );
Mage::getSingleton('turpentine/session')
->clearMessages($this->getNameInLayout());
}

/**
Expand All @@ -315,8 +315,8 @@ protected function _clearMessages() {
* @return string
*/
protected function _real_toHtml() {
if( !$this->_directCall ) {
switch( $this->getNameInLayout() ) {
if ( ! $this->_directCall) {
switch ($this->getNameInLayout()) {
case 'global_messages':
$this->_directCall = 'getHtml';
break;
Expand All @@ -326,9 +326,9 @@ protected function _real_toHtml() {
break;
}
}
switch( $this->_directCall ) {
switch ($this->_directCall) {
case 'getHtml':
$html = parent::getHtml( $this->_singleRenderType );
$html = parent::getHtml($this->_singleRenderType);
$this->_singleRenderType = self::NO_SINGLE_RENDER_TYPE;
break;
case 'getGroupedHtml':
Expand All @@ -346,7 +346,7 @@ protected function _real_toHtml() {
* @return bool
*/
protected function _fixMessages() {
return Mage::helper( 'turpentine/esi' )->shouldFixFlashMessages();
return Mage::helper('turpentine/esi')->shouldFixFlashMessages();
}

/**
Expand All @@ -358,7 +358,7 @@ protected function _fixMessages() {
* @return boolean
*/
protected function _isEsiRequest() {
return is_a( Mage::app()->getRequest(),
'Nexcessnet_Turpentine_Model_Dummy_Request' );
return is_a(Mage::app()->getRequest(),
'Nexcessnet_Turpentine_Model_Dummy_Request');
}
}
Loading

0 comments on commit 6ffc751

Please sign in to comment.