Skip to content

Commit

Permalink
Scrutinizer Auto-Fixes
Browse files Browse the repository at this point in the history
This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
  • Loading branch information
scrutinizer-auto-fixer committed Dec 27, 2016
1 parent 95a186f commit bcd5853
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 60 deletions.
30 changes: 15 additions & 15 deletions app/code/community/Nexcessnet/Turpentine/Block/Poll/ActivePoll.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@

class Nexcessnet_Turpentine_Block_Poll_ActivePoll extends Mage_Poll_Block_ActivePoll {

public function setTemplate($template)
{
if ((Mage::getConfig()->getModuleConfig('Mage_Poll')->is('active', 'true')) &&
(!Mage::getStoreConfig('advanced/modules_disable_output/Mage_Poll')))
{
$this->_template = $template;
$this->setPollTemplate('turpentine/ajax.phtml', 'poll');
$this->setPollTemplate('turpentine/ajax.phtml', 'results');
}
else
{
// Mage_Poll is disabled, so do nothing
}
return $this;
}
public function setTemplate($template)
{
if ((Mage::getConfig()->getModuleConfig('Mage_Poll')->is('active', 'true')) &&
(!Mage::getStoreConfig('advanced/modules_disable_output/Mage_Poll')))
{
$this->_template = $template;
$this->setPollTemplate('turpentine/ajax.phtml', 'poll');
$this->setPollTemplate('turpentine/ajax.phtml', 'results');
}
else
{
// Mage_Poll is disabled, so do nothing
}
return $this;
}
}
2 changes: 1 addition & 1 deletion app/code/community/Nexcessnet/Turpentine/Helper/Esi.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public function getFormKeyEsiUrl() {
* @param string $blockName value of name= attribute in layout XML
* @return Mage_Core_Model_Layout_Element
*/
public function getEsiLayoutBlockNode($layout,$blockName) {
public function getEsiLayoutBlockNode($layout, $blockName) {
// first try very specific by checking for action setEsiOptions inside block
$blockNode = current($layout->getNode()->xpath(
sprintf('//block[@name=\'%s\'][action[@method=\'setEsiOptions\']]',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function real_getFormKey()
*/
public function renewFormKey()
{
$this->setData('_form_key', Mage::helper('core')->getRandomString(16));
$this->setData('_form_key', Mage::helper('core')->getRandomString(16));
}

/**
Expand Down
10 changes: 5 additions & 5 deletions app/code/community/Nexcessnet/Turpentine/Model/Observer/Esi.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ public function injectEsi($eventObject) {
'Checking ESI block candidate: %s',
$blockObject->getNameInLayout() ? $blockObject->getNameInLayout() : $blockObject->getModuleName() );

$debugHelper->logInfo( "-- block testing: shouldResponseUseEsi = " . $esiHelper->shouldResponseUseEsi());
$debugHelper->logInfo( "-- block testing: instanceof Mage_Core_Block_Template = " . $blockObject instanceof Mage_Core_Block_Template );
$debugHelper->logInfo( "-- block testing: Esi Options = " . print_r($blockObject->getEsiOptions(), true) );
$debugHelper->logInfo("-- block testing: shouldResponseUseEsi = ".$esiHelper->shouldResponseUseEsi());
$debugHelper->logInfo("-- block testing: instanceof Mage_Core_Block_Template = ".$blockObject instanceof Mage_Core_Block_Template);
$debugHelper->logInfo("-- block testing: Esi Options = ".print_r($blockObject->getEsiOptions(), true));
}
if ($esiHelper->shouldResponseUseEsi() &&
$blockObject instanceof Mage_Core_Block_Template &&
Expand Down Expand Up @@ -332,8 +332,8 @@ protected function _getEsiData($blockObject, $esiOptions) {
$methodParam = $esiHelper->getEsiMethodParam();
$esiData = new Varien_Object();
$esiData->setStoreId(Mage::app()->getStore()->getId());
$esiData->setDesignPackage( Mage::getDesign()->getPackageName() );
$esiData->setDesignTheme( Mage::getDesign()->getTheme( 'layout' ) );
$esiData->setDesignPackage(Mage::getDesign()->getPackageName());
$esiData->setDesignTheme(Mage::getDesign()->getTheme('layout'));
$esiData->setNameInLayout($blockObject->getNameInLayout());
$esiData->setBlockType(get_class($blockObject));
$esiData->setLayoutHandles($this->_getBlockLayoutHandles($blockObject));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function addProductListToolbarRewrite($eventObject) {
public function fixCmRedisSessionLocks($eventObject) {
if (Mage::helper('core')->isModuleEnabled('Cm_RedisSession')) {
if ( ! empty($_COOKIE['frontend']) && 'crawler-session' == $_COOKIE['frontend'] &&
!defined('CM_REDISSESSION_LOCKING_ENABLED') ) {
! defined('CM_REDISSESSION_LOCKING_ENABLED')) {
define('CM_REDISSESSION_LOCKING_ENABLED', false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected function _testEsiSyntaxParam($socket) {
$result = false;

if ($helper->csrfFixupNeeded()) {
if ($socket->getVersion() === '4.0' || $socket->getVersion() === '4.1' ) {
if ($socket->getVersion() === '4.0' || $socket->getVersion() === '4.1') {
$paramName = 'feature';
$value = $socket->param_show($paramName);
$value = explode("\n", $value['text']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ protected function _command($verb, $okCode = 200) {
$response['code'], $response['text'] ));
} else {
if (Mage::getStoreConfig('turpentine_varnish/general/varnish_log_commands')) {
Mage::helper('turpentine/debug')->logDebug('VARNISH command sent: ' . $data);
Mage::helper('turpentine/debug')->logDebug('VARNISH command sent: '.$data);
}
return $response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public function save($generatedConfig) {
* @return string
*/
protected function _getVclTemplateFilename($baseFilename) {
$extensionDir = Mage::getModuleDir('', 'Nexcessnet_Turpentine');
return sprintf('%s/misc/%s', $extensionDir, $baseFilename);
$extensionDir = Mage::getModuleDir('', 'Nexcessnet_Turpentine');
return sprintf('%s/misc/%s', $extensionDir, $baseFilename);
}

/**
Expand All @@ -131,7 +131,7 @@ protected function _getVclFilename() {
*
* @return string
*/
protected function _getCustomIncludeFilename($position='') {
protected function _getCustomIncludeFilename($position = '') {
$key = 'custom_include_file';
$key .= ($position) ? '_'.$position : '';
return $this->_formatTemplate(
Expand All @@ -151,8 +151,7 @@ protected function _getCustomTemplateFilename() {
Mage::getStoreConfig('turpentine_varnish/servers/custom_vcl_template'),
array('root_dir' => Mage::getBaseDir())
);
if (is_file($filePath)) { return $filePath; }
else { return null; }
if (is_file($filePath)) { return $filePath; } else { return null; }
}


Expand Down Expand Up @@ -193,8 +192,8 @@ protected function _vcl_call($subroutine) {
*/
protected function _getAdminFrontname() {
if (Mage::getStoreConfig('admin/url/use_custom_path')) {
if(Mage::getStoreConfig('web/url/use_store')) {
return Mage::getModel('core/store')->load(0)->getCode() . "/" . Mage::getStoreConfig('admin/url/custom_path');
if (Mage::getStoreConfig('web/url/use_store')) {
return Mage::getModel('core/store')->load(0)->getCode()."/".Mage::getStoreConfig('admin/url/custom_path');
} else {
return Mage::getStoreConfig('admin/url/custom_path');
}
Expand Down Expand Up @@ -909,8 +908,8 @@ protected function _vcl_sub_maintenance_allowed_ips() {
*/
protected function _vcl_sub_https_redirect_fix() {
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
$baseUrl = str_replace(array('http://','https://'), '', $baseUrl);
$baseUrl = rtrim($baseUrl,'/');
$baseUrl = str_replace(array('http://', 'https://'), '', $baseUrl);
$baseUrl = rtrim($baseUrl, '/');

switch (Mage::getStoreConfig('turpentine_varnish/servers/version')) {
case 4.0:
Expand Down Expand Up @@ -982,7 +981,7 @@ protected function _vcl_sub_synth_https_fix()
{
$tpl = $this->_vcl_sub_synth();

if(!$tpl){
if ( ! $tpl) {
$tpl = <<<EOS
sub vcl_synth {
if (resp.status == 750) {
Expand All @@ -992,7 +991,7 @@ protected function _vcl_sub_synth_https_fix()
}
}
EOS;
}else{
} else{
$tpl_750 = '
sub vcl_synth {
if (resp.status == 750) {
Expand Down Expand Up @@ -1089,12 +1088,12 @@ protected function _getTemplateVars() {

if (Mage::getStoreConfig('turpentine_varnish/general/https_redirect_fix')) {
$vars['https_redirect'] = $this->_vcl_sub_https_redirect_fix();
if(Mage::getStoreConfig('turpentine_varnish/servers/version') == '4.0' || Mage::getStoreConfig('turpentine_varnish/servers/version') == '4.1'){
if (Mage::getStoreConfig('turpentine_varnish/servers/version') == '4.0' || Mage::getStoreConfig('turpentine_varnish/servers/version') == '4.1') {
$vars['vcl_synth'] = $this->_vcl_sub_synth_https_fix();
}
}

foreach (array('','top') as $position) {
foreach (array('', 'top') as $position) {
$customIncludeFile = $this->_getCustomIncludeFilename($position);
if (is_readable($customIncludeFile)) {
$key = 'custom_vcl_include';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public function generate($doClean = true) {
$customTemplate = $this->_getCustomTemplateFilename();
if ($customTemplate) {
$tplFile = $customTemplate;
}
else {
} else {
$tplFile = $this->_getVclTemplateFilename(self::VCL_TEMPLATE_FILE);
}
$vcl = $this->_formatTemplate(file_get_contents($tplFile),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public function generate($doClean = true) {
$customTemplate = $this->_getCustomTemplateFilename();
if ($customTemplate) {
$tplFile = $customTemplate;
}
else {
} else {
$tplFile = $this->_getVclTemplateFilename(self::VCL_TEMPLATE_FILE);
}
$vcl = $this->_formatTemplate(file_get_contents($tplFile),
Expand Down Expand Up @@ -94,13 +93,13 @@ protected function _vcl_directors()
$backendNodes = Mage::helper('turpentine/data')->cleanExplode(PHP_EOL,
Mage::getStoreConfig('turpentine_vcl/backend/backend_nodes'));

for($i = 0, $iMax = count($backendNodes); $i < $iMax; $i++) {
for ($i = 0, $iMax = count($backendNodes); $i < $iMax; $i++) {
$tpl .= <<<EOS
vdir.add_backend(web{$i});
EOS;
}

for($i = 0, $iMax = count($adminBackendNodes); $i < $iMax; $i++) {
for ($i = 0, $iMax = count($adminBackendNodes); $i < $iMax; $i++) {
$tpl .= <<<EOS
vdir_admin.add_backend(webadmin{$i});
EOS;
Expand Down Expand Up @@ -132,7 +131,7 @@ protected function _vcl_director($name, $backendOptions) {
Mage::getStoreConfig('turpentine_vcl/backend/backend_nodes'));
$probeUrl = Mage::getStoreConfig('turpentine_vcl/backend/backend_probe_url');

if('admin' == $name) {
if ('admin' == $name) {
$prefix = 'admin';
} else {
$prefix = '';
Expand All @@ -145,7 +144,7 @@ protected function _vcl_director($name, $backendOptions) {
$parts = explode(':', $backendNode, 2);
$host = (empty($parts[0])) ? '127.0.0.1' : $parts[0];
$port = (empty($parts[1])) ? '80' : $parts[1];
$backends .= $this->_vcl_director_backend($host, $port, $prefix . $number, $probeUrl, $backendOptions);
$backends .= $this->_vcl_director_backend($host, $port, $prefix.$number, $probeUrl, $backendOptions);

$number++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ protected function _getEsiBlock($esiData) {
}
}
$layout = Mage::getSingleton('core/layout');
Mage::getSingleton( 'core/design_package' )
->setPackageName( $esiData->getDesignPackage() )
->setTheme( $esiData->getDesignTheme() );
Mage::getSingleton('core/design_package')
->setPackageName($esiData->getDesignPackage())
->setTheme($esiData->getDesignTheme());

// dispatch event for adding handles to layout update
Mage::dispatchEvent(
Expand Down
22 changes: 11 additions & 11 deletions contrib/tools/esi-decoder.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php
/**
* ESI DECODER
*
* This tool can be used to decode an ESI request.
* You can just paste the whole ESI URL and push the button to decode it.
*
* Make sure you place this utility on a protected spot on your web server where only authorized users can use it.
*
* If the URLs you see in "varnishlog" or "varnishncsa" are not working because they are cut off, read this FAQ item:
* https://github.com/nexcess/magento-turpentine/wiki/FAQ#im-using-varnishncsa-to-generate-logs-and-the-esi-urls-are-cut-off-how-do-i-get-the-full-url-in-the-logs
*
*/
* ESI DECODER
*
* This tool can be used to decode an ESI request.
* You can just paste the whole ESI URL and push the button to decode it.
*
* Make sure you place this utility on a protected spot on your web server where only authorized users can use it.
*
* If the URLs you see in "varnishlog" or "varnishncsa" are not working because they are cut off, read this FAQ item:
* https://github.com/nexcess/magento-turpentine/wiki/FAQ#im-using-varnishncsa-to-generate-logs-and-the-esi-urls-are-cut-off-how-do-i-get-the-full-url-in-the-logs
*
*/

$tries = 5;
$dir = dirname(__FILE__);
Expand Down

0 comments on commit bcd5853

Please sign in to comment.