Esempio n. 1
0
 public function __construct()
 {
     parent::__construct();
     Mage::setIsDeveloperMode(true);
     //always enable developer mode when run through the shell.
     if ($this->getArg('profiler') == '1') {
         Varien_Profiler::enable();
     }
 }
 public function enableProfiling(Varien_Event_Observer $event)
 {
     if (!Mage::helper('developertoolbar')->isEnabledForCurrentIp()) {
         return;
     }
     // TODO: Enable/disable based on config setting? Perhaps cookie set by frontend toolbar?
     Varien_Profiler::enable();
     // Enable query profiling on read + write connection
     $resource = Mage::getSingleton('core/resource');
     $resource->getConnection('core_write')->getProfiler()->setEnabled(true);
     $resource->getconnection('core_read')->getProfiler()->setEnabled(true);
 }
Esempio n. 3
0
 /**
  * Handle the initial setup, including profiling and bootstrapping the
  * Magento environment
  *
  * @return void
  * 
  **/
 public function setup()
 {
     // We need to profiler to be enabled to get nice profiling information, duh!
     Varien_Profiler::enable();
     // Can't be bothered to look up what this does,
     // but it sounds like the kind of thing which should be in here.
     // We're developers aren't we!
     Mage::setIsDeveloperMode(true);
     // Bootstrap that environment! This does loads of
     // stuff and is pretty neccessary
     Mage::app('', 'store');
 }
 public static function enableProfiler($status = true)
 {
     self::$_profilerEnabled = $status;
     if (!$status) {
         return;
     }
     require_once MagentoDebugger::getProjectDir() . '/lib/Varien/Profiler.php';
     //require_once(self::getDebuggerDir() . '/libs/Varien/Profiler.php');
     Varien_Profiler::enable();
     $serverKey = MagentoDebugger::getKeyFromString(isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'console');
     $time = time();
     self::$_uniqId = $time . '_' . uniqid();
     self::$_jsonLog = MagentoDebugger::getDebuggerVarDir() . '/profiler/' . $serverKey . '.' . self::$_uniqId;
     $url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : 'Not specified';
     $profilerHeader = array('time' => $time, 'url' => $url, 'key' => self::$_uniqId);
     file_put_contents(self::$_jsonLog . '.jshe', json_encode($profilerHeader));
 }
Esempio n. 5
0
 /**
  * Init a working magento environment
  */
 protected function initMagento()
 {
     if (version_compare(phpversion(), '5.2.0', '<') === true) {
         $this->log("Magento requires php 5.2.0 or later version", Project::MSG_ERR);
         exit;
     }
     $mageFilename = $this->getMagentoRootDir() . DS . 'app' . DS . 'Mage.php';
     if (!file_exists($mageFilename)) {
         $this->log($mageFilename . " was not found", Project::MSG_ERR);
         exit;
     }
     require_once $mageFilename;
     Varien_Profiler::enable();
     Mage::setIsDeveloperMode(true);
     ini_set('display_errors', 1);
     umask(0);
     Mage::app();
 }
Esempio n. 6
0
$mageFilename = MAGENTO_ROOT . '/app/Mage.php';
$maintenanceFile = 'maintenance.flag';
if (!file_exists($mageFilename)) {
    if (is_dir('downloader')) {
        header("Location: downloader");
    } else {
        echo $mageFilename . " was not found";
    }
    exit;
}
if (file_exists($maintenanceFile)) {
    include_once dirname(__FILE__) . '/errors/503.php';
    exit;
}
require_once $mageFilename;
Varien_Profiler::enable();
// if (isset($_SERVER['MAGE_IS_DEVELOPER_MODE'])) {
Mage::setIsDeveloperMode(true);
// }
ini_set('display_errors', 1);
umask(0);
/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
Mage::run($mageRunCode, $mageRunType);
//    $url = Mage::app()->getRequest()->getRequestString();
//    $times = Varien_Profiler::getTimers();
//    $data = array();
//    foreach ($times as $k=>$v) {
//        if (strpos($k, "EVENT") !== false) {
 public function profilePre($o)
 {
     $ca = $o->getEvent()->getControllerAction();
     if ($this->_canProfile($ca) === FALSE) {
         return $o;
     }
     Mage::getSingleton('core/resource')->getConnection('core_write')->getProfiler()->setEnabled(TRUE);
     Varien_Profiler::enable();
 }
Esempio n. 8
0
File: Wiz.php Progetto: nvahalik/Wiz
 /**
  * Instantiates and sets up Magento.  By default, use the admin scopeCode so we run
  * inside of the administration context.
  *
  * @param string $scopeCode 
  * @param string $scopeId 
  * @return Mage_Core_Model_App
  * @author Nicholas Vahalik <*****@*****.**>
  */
 public static function getMagento($scopeCode = 'admin', $scopeId = 'store')
 {
     /**
      * Our local copy of the Magento Application Object
      * 
      * @see Mage_Core_Model_App
      */
     static $_magento;
     if (!$_magento) {
         // Did we get a directory from an environment variable?
         $wizMagentoRoot = Wiz::getMagentoRoot();
         // No dice. :-(
         if ($wizMagentoRoot === FALSE) {
             die('Please specify a Magento root directory by setting WIZ_MAGE_ROOT.' . PHP_EOL);
         }
         chdir($wizMagentoRoot);
         /**
          * Attempt to bootstrap Magento.
          */
         $compilerConfig = 'includes/config.php';
         if (file_exists($compilerConfig)) {
             include $compilerConfig;
         }
         require 'app/Mage.php';
         umask(0);
         // If someone passes a scope code via he CLI, then use that.
         foreach (array('store', 'website') as $scope) {
             if (($argScopeCode = Wiz::getWiz()->getArg($scope)) !== FALSE) {
                 // If --store is specified, but not provided, use the default.
                 $scopeCode = $argScopeCode === TRUE ? '' : $argScopeCode;
                 $scopeId = $scope;
                 break;
             }
         }
         // We only want to enable profiling if it has been turned on within the
         // configuration AND if the --profile argument was passed into the command.
         if (Mage::getStoreConfig('dev/debug/profiler') && Wiz::getWiz()->getArg('profile')) {
             Varien_Profiler::enable();
         }
         $_magento = Mage::app($scopeCode, $scopeId);
     }
     return $_magento;
 }