Skip to content

Instantly share code, notes, and snippets.

@udovicic
Created January 21, 2015 10:06
Show Gist options
  • Save udovicic/1d2bf20c2b20720a715c to your computer and use it in GitHub Desktop.
Save udovicic/1d2bf20c2b20720a715c to your computer and use it in GitHub Desktop.
Script for triggering module updates and cache refresh for Magento EE
<?php
/**
* Upgrade script based on https://gist.github.com/colinmollenhour/2715268
* Set global/skip_process_modules_updates to '1' in app/etc/local.xml
*
* Execute script to trigger upgrades and cache refresh
*/
require_once 'abstract.php';
class Inchoo_Upgrade
extends Mage_Shell_Abstract
{
// Prevent default loading of Mage::app()
protected $_includeMage = false;
// Environment setup
protected $_appCode = 'admin';
protected $_appType = 'store';
/**
* Extended default constructor: sets global_ban_use_cache to true
*/
public function __construct()
{
echo "Base Mage init...";
require_once $this->_getRootPath() . 'app' . DIRECTORY_SEPARATOR . 'Mage.php';
// Inchoo:: Avoid using cache
// $_includeMage is set to false to avoid default load
Mage::app(
$this->_appCode,
$this->_appType,
array('global_ban_use_cache' => TRUE));
parent::__construct();
echo "\t\t[done]\n";
}
/**
* Point of entry
*/
public function run()
{
// Apply upgrades
echo "Applying structure upgrades...";
Mage_Core_Model_Resource_Setup::applyAllUpdates();
echo "\t[done]\n";
echo "Applying data upgrades...";
Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
echo "\t[done]\n";
// Cache refresh
echo "Flushing cache...";
Mage::getConfig()->getOptions()->setData('global_ban_use_cache', FALSE);
Mage::app()->baseInit(array()); // Re-init cache
Mage::app()->cleanCache();
Enterprise_PageCache_Model_Cache::getCacheInstance()
->clean(Enterprise_PageCache_Model_Processor::CACHE_TAG);
echo "\t\t[done]\n";
echo "Creating config cache...";
Mage::getConfig()->loadModules()->loadDb()->saveCache();
echo "\t[done]\n";
}
}
// Environment setup
umask(0);
ini_set('memory_limit','512M');
set_time_limit(0);
// Execute script
$shell = new Inchoo_Upgrade();
$shell->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment