Skip to content

Commit

Permalink
Merge commit 'c839b9f'
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabrizio Branca committed Sep 28, 2015
2 parents d3f3832 + c839b9f commit 3ff72fc
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
31 changes: 31 additions & 0 deletions app/code/community/Aoe/Scheduler/Controller/AbstractController.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@
*/
abstract class Aoe_Scheduler_Controller_AbstractController extends Mage_Adminhtml_Controller_Action
{

public function preDispatch()
{
parent::preDispatch();
if ($this->getRequest()->getActionName() != 'error' && !$this->checkLocalCodePool()) {
$this->_forward('error');
}
}

public function errorAction()
{
$this->loadLayout();
$this->_setActiveMenu('system');
$this->renderLayout();
}

/**
* Index action
*
Expand All @@ -32,6 +48,21 @@ public function indexAction()
$this->renderLayout();
}

/**
* Aoe_Scheduler used to live in the local code pool.
* When newer version are installed without removing the old files Aoe_Scheduler will produce fatal errors.
* This is an attempt to handle this a little better.
*/
protected function checkLocalCodePool()
{
$helper = Mage::helper('aoe_scheduler/compatibility'); /* @var $helper Aoe_Scheduler_Helper_Compatibility */
if ($helper->oldConfigXmlExists()) {
$this->_getSession()->addError($this->__('Looks like you have an older version of Aoe_Scheduler installed that lived in the local code pool. Please delete everything under "%s"', $helper->getLocalCodeDir()));
return false;
}
return true;
}

/**
* Check heartbeat
*/
Expand Down
21 changes: 21 additions & 0 deletions app/code/community/Aoe/Scheduler/Helper/Compatibility.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/**
* Helper
*
* @author Fabrizio Branca
*/
class Aoe_Scheduler_Helper_Compatibility extends Mage_Core_Helper_Abstract
{

public function getLocalCodeDir()
{
return Mage::getBaseDir('code') . DS . 'local' . DS . 'Aoe' . DS . 'Scheduler';
}

public function oldConfigXmlExists()
{
return is_file($this->getLocalCodeDir() . DS . 'etc' . DS . 'config.xml');
}

}
5 changes: 5 additions & 0 deletions shell/scheduler.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ class Aoe_Scheduler_Shell_Scheduler extends Mage_Shell_Abstract
public function run()
{
try {
$helper = Mage::helper('aoe_scheduler/compatibility'); /* @var $helper Aoe_Scheduler_Helper_Compatibility */
if ($helper->oldConfigXmlExists()) {
echo 'Looks like you have an older version of Aoe_Scheduler installed that lived in the local code pool. Please delete everything under "' .$helper->getLocalCodeDir(). '"';
exit(1);
}
$action = $this->getArg('action');
if (empty($action)) {
echo $this->usageHelp();
Expand Down

0 comments on commit 3ff72fc

Please sign in to comment.