diff --git a/config/config.inc.php b/config/config.inc.php index ce8fcf12e..7f0783282 100644 --- a/config/config.inc.php +++ b/config/config.inc.php @@ -59,6 +59,14 @@ require_once(dirname(__FILE__).'/settings.inc.php'); require_once(dirname(__FILE__).'/defines.inc.php'); require_once(dirname(__FILE__).'/autoload.php'); +if (_PS_DEBUG_PROFILING_) +{ + include_once(_PS_ROOT_DIR_.'/override/classes/_Controller.php'); + include_once(_PS_ROOT_DIR_.'/override/classes/_Module.php'); + include_once(_PS_ROOT_DIR_.'/override/classes/_ObjectModel.php'); + include_once(_PS_ROOT_DIR_.'/override/classes/db/_Db.php'); +} + /* Redefine REQUEST_URI if empty (on some webservers...) */ if (!isset($_SERVER['REQUEST_URI']) OR empty($_SERVER['REQUEST_URI'])) { diff --git a/config/defines.inc.php b/config/defines.inc.php index a2bfa6dd2..a52a9b2b5 100755 --- a/config/defines.inc.php +++ b/config/defines.inc.php @@ -26,6 +26,7 @@ */ define('_PS_MODE_DEV_', true); +define('_PS_DEBUG_PROFILING_', false); define('_PS_MODE_DEMO_', false); $currentDir = dirname(__FILE__); @@ -119,9 +120,9 @@ define('_PS_ADMIN_PROFILE_', 1); define('_STOCK_MOVEMENT_ORDER_REASON_', 3); define('_STOCK_MOVEMENT_MISSING_REASON_', 4); -/** +/** * @deprecated 1.5.0.1 - * @see Group::CUSTOMER + * @see Group::CUSTOMER */ define('_PS_DEFAULT_CUSTOMER_GROUP_', 3); diff --git a/override/classes/_Controller.php b/override/classes/_Controller.php index db9f7a872..0a0ff0d74 100644 --- a/override/classes/_Controller.php +++ b/override/classes/_Controller.php @@ -166,59 +166,73 @@ abstract class Controller extends ControllerCore ini_set('display_errors', 'on'); error_reporting(E_ALL | E_STRICT); - $this->_memory = array_fill(0, 10, 0); - $this->_time = array_fill(0, 10, 0); - if (!self::$_footer) return; - $this->_memory[-3] = memory_get_usage(); - $this->_time[-3] = microtime(true); - $this->init(); - $this->_memory[-2] = memory_get_usage(); - $this->_time[-2] = microtime(true); + $this->_memory['config'] = memory_get_usage(); + $this->_time['config'] = microtime(true); + parent::__construct(); - $this->_memory[-1] = memory_get_usage(); - $this->_time[-1] = microtime(true); + $this->_memory['constructor'] = memory_get_usage(); + $this->_time['constructor'] = microtime(true); } public function run() { - $this->_memory[0] = memory_get_usage(); - $this->_time[0] = microtime(true); $this->init(); + $this->_memory['init'] = memory_get_usage(); + $this->_time['init'] = microtime(true); - $this->_memory[1] = memory_get_usage(); - $this->_time[1] = microtime(true); - if ($this->ajax && method_exists($this, 'ajaxProcess')) - $this->ajaxProcess(); - else - $this->postProcess(); - - $this->_memory[2] = memory_get_usage(); - $this->_time[2] = microtime(true); - if ($this->display_header) + if ($this->checkAccess()) { - $this->setMedia(); - $this->initHeader(); + $this->_memory['checkAccess'] = memory_get_usage(); + $this->_time['checkAccess'] = microtime(true); + + if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className))) + $this->setMedia(); + $this->_memory['setMedia'] = memory_get_usage(); + $this->_time['setMedia'] = microtime(true); + + // postProcess handles ajaxProcess + $this->postProcess(); + $this->_memory['postProcess'] = memory_get_usage(); + $this->_time['postProcess'] = microtime(true); + + if (!empty($this->redirect_after)) + $this->redirect(); + + if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className))) + $this->initHeader(); + $this->_memory['initHeader'] = memory_get_usage(); + $this->_time['initHeader'] = microtime(true); + + $this->initContent(); + $this->_memory['initContent'] = memory_get_usage(); + $this->_time['initContent'] = microtime(true); + + if (!$this->content_only && ($this->display_footer || (isset($this->className) && $this->className))) + $this->initFooter(); + $this->_memory['initFooter'] = memory_get_usage(); + $this->_time['initFooter'] = microtime(true); + + // default behavior for ajax process is to use $_POST[action] or $_GET[action] + // then using displayAjax[action] + if ($this->ajax) + { + $action = Tools::getValue('action'); + if (!empty($action) && method_exists($this, 'displayAjax'.Tools::toCamelCase($action))) + $this->{'displayAjax'.$action}(); + elseif (method_exists($this, 'displayAjax')) + $this->displayAjax(); + } + else + $this->displayDebug(); } - - $this->_memory[3] = memory_get_usage(); - $this->_time[3] = microtime(true); - $this->initContent(); - - - $this->_memory[4] = memory_get_usage(); - $this->_time[4] = microtime(true); - if ($this->display_footer) - $this->initFooter(); - - $this->_memory[5] = memory_get_usage(); - $this->_time[5] = microtime(true); - if ($this->ajax && method_exists($this, 'displayAjax')) - $this->displayAjax(); else + { + $this->initCursedPage(); $this->displayDebug(); + } } function ini_get_display_errors() @@ -252,16 +266,12 @@ abstract class Controller extends ControllerCore global $start_time; $this->display(); - - if (self::$_footer) - parent::displayFooter(); + $this->_memory['display'] = memory_get_usage(); + $this->_time['display'] = microtime(true); if (!$this->ini_get_display_errors()) return; - $this->_memory[6] = memory_get_usage(); - $this->_time[6] = microtime(true); - $hr = '
'; $totalSize = 0; @@ -291,20 +301,16 @@ abstract class Controller extends ControllerCore echo '

- Load time: '.$this->displayLoadTimeColor($this->_time[6] - $start_time, true).''; + Load time: '.$this->displayLoadTimeColor($this->_time['display'] - $start_time, true).''; if (self::$_footer) - echo ' - '; + echo ''; echo '
Hook processing: '.$this->displayLoadTimeColor($totalHookTime).' @@ -316,17 +322,16 @@ abstract class Controller extends ControllerCore
Memory peak usage: '.$this->displayMemoryColor(memory_get_peak_usage()).''; if (self::$_footer) - echo ' - '; + { + echo ''; + } echo '
'; echo '