From 7879f92b7c5d81ac843aaaf3bf23eafd2b618fde Mon Sep 17 00:00:00 2001 From: Pierre RAMBAUD Date: Thu, 4 Jun 2020 14:25:17 +0200 Subject: [PATCH] Cs fixer and little refacto --- .php_cs.dist | 1 + tools/profiling/Controller.php | 247 +++++++++++++++++--------------- tools/profiling/Db.php | 21 ++- tools/profiling/ObjectModel.php | 13 +- tools/profiling/Tools.php | 11 +- tools/profiling/index.php | 13 +- 6 files changed, 158 insertions(+), 148 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index a144a11e83f76..0b3e7f2a156f3 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -7,6 +7,7 @@ $finder = PhpCsFixer\Finder::create()->in([ __DIR__.'/classes', __DIR__.'/controllers', __DIR__.'/tests', + __DIR__.'/tools/profiling', ]); return PhpCsFixer\Config::create() diff --git a/tools/profiling/Controller.php b/tools/profiling/Controller.php index 872bab5f81547..5e5852bccaed8 100644 --- a/tools/profiling/Controller.php +++ b/tools/profiling/Controller.php @@ -23,182 +23,195 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ - abstract class Controller extends ControllerCore { + const COLOR_WARNING = '#EF8B00'; + const COLOR_SUCCESS = 'green'; + const COLOR_ERROR = 'red'; + protected $total_filesize = 0; protected $total_query_time = 0; protected $total_global_var_size = 0; protected $total_modules_time = 0; protected $total_modules_memory = 0; - protected $global_var_size = array(); + protected $global_var_size = []; - protected $modules_perfs = array(); - protected $hooks_perfs = array(); + protected $modules_perfs = []; + protected $hooks_perfs = []; - protected $array_queries = array(); + protected $array_queries = []; - protected $profiler = array(); + protected $profiler = []; private function getMemoryColor($n) { $n /= 1048576; if ($n > 3) { - return ''.sprintf('%0.2f', $n).''; - } elseif ($n > 1) { - return ''.sprintf('%0.2f', $n).''; - } elseif (round($n, 2) > 0) { - return ''.sprintf('%0.2f', $n).''; + return '' . sprintf('%0.2f', $n) . ''; + } + + if ($n > 1) { + return '' . sprintf('%0.2f', $n) . ''; } - return '-'; + if (round($n, 2) > 0) { + return '' . sprintf('%0.2f', $n) . ''; + } + + return '-'; } private function getPeakMemoryColor($n) { $n /= 1048576; if ($n > 16) { - return ''.sprintf('%0.1f', $n).''; + return '' . sprintf('%0.1f', $n) . ''; } + if ($n > 12) { - return ''.sprintf('%0.1f', $n).''; + return '' . sprintf('%0.1f', $n) . ''; } - return ''.sprintf('%0.1f', $n).''; + return '' . sprintf('%0.1f', $n) . ''; } private function displaySQLQueries($n) { if ($n > 150) { - return ''.$n.' queries'; + return '' . $n . ' queries'; } if ($n > 100) { - return ''.$n.' queries'; + return '' . $n . ' queries'; } - return ''.$n.' quer'.($n == 1 ? 'y' : 'ies').''; + return '' . $n . ' quer' . ($n == 1 ? 'y' : 'ies') . ''; } private function displayRowsBrowsed($n) { if ($n > 400) { - return ''.$n.' rows browsed'; + return '' . $n . ' rows browsed'; } if ($n > 100) { - return ''.$n.' rows browsed'; + return '' . $n . ' rows browsed'; } - return ''.$n.' row'.($n == 1 ? '' : 's').' browsed'; + return '' . $n . ' row' . ($n == 1 ? '' : 's') . ' browsed'; } private function getPhpVersionColor($version) { if (version_compare($version, '5.6') < 0) { - return ''.$version.' (Upgrade strongly recommended)'; + return '' . $version . ' (Upgrade strongly recommended)'; } elseif (version_compare($version, '7.1') < 0) { - return ''.$version.' (Consider upgrading)'; + return '' . $version . ' (Consider upgrading)'; } - return ''.$version.' (OK)'; + return '' . $version . ' (OK)'; } private function getMySQLVersionColor($version) { if (version_compare($version, '5.5') < 0) { - return ''.$version.' (Upgrade strongly recommended)'; + return '' . $version . ' (Upgrade strongly recommended)'; } elseif (version_compare($version, '5.6') < 0) { - return ''.$version.' (Consider upgrading)'; + return '' . $version . ' (Consider upgrading)'; } - return ''.$version.' (OK)'; + return '' . $version . ' (OK)'; } private function getLoadTimeColor($n, $kikoo = false) { if ($n > 1.6) { - return ''.round($n * 1000).''.($kikoo ? ' ms - You\'d better run your shop on a toaster' : ''); + return '' . round($n * 1000) . '' . ($kikoo ? ' ms - You\'d better run your shop on a toaster' : ''); } elseif ($n > 0.8) { - return ''.round($n * 1000).''.($kikoo ? ' ms - OK... for a shared hosting' : ''); + return '' . round($n * 1000) . '' . ($kikoo ? ' ms - OK... for a shared hosting' : ''); } elseif ($n > 0) { - return ''.round($n * 1000).''.($kikoo ? ' ms - Unicorn powered webserver!' : ''); + return '' . round($n * 1000) . '' . ($kikoo ? ' ms - Unicorn powered webserver!' : ''); } - return '-'.($kikoo ? ' ms - Faster than light' : ''); + return '-' . ($kikoo ? ' ms - Faster than light' : ''); } private function getTotalQueriyingTimeColor($n) { if ($n >= 100) { - return ''.$n.''; + return '' . $n . ''; } elseif ($n >= 50) { - return ''.$n.''; + return '' . $n . ''; } - return ''.$n.''; + return '' . $n . ''; } private function getNbQueriesColor($n) { if ($n >= 100) { - return ''.$n.''; + return '' . $n . ''; } elseif ($n >= 50) { - return ''.$n.''; + return '' . $n . ''; } - return ''.$n.''; + return '' . $n . ''; } private function getTimeColor($n) { if ($n > 4) { - return 'style="color:red"'; + return 'style="color:' . static::COLOR_ERROR . '"'; } if ($n > 2) { - return 'style="color:#EF8B00"'; + return 'style="color:' . static::COLOR_WARNING . '"'; } - return 'style="color:green"'; + return 'style="color:' . static::COLOR_SUCCESS . '"'; } private function getQueryColor($n) { if ($n > 5) { - return 'style="color:red"'; + return 'style="color:' . static::COLOR_ERROR . '"'; } if ($n > 2) { - return 'style="color:#EF8B00"'; + return 'style="color:' . static::COLOR_WARNING . '"'; } - return 'style="color:green"'; + return 'style="color:' . static::COLOR_SUCCESS . '"'; } private function getTableColor($n) { if ($n > 30) { - return 'style="color:red"'; + return 'style="color:' . static::COLOR_ERROR . '"'; } if ($n > 20) { - return 'style="color:#EF8B00"'; + return 'style="color:' . static::COLOR_WARNING . '"'; } - return 'style="color:green"'; + return 'style="color:' . static::COLOR_SUCCESS . '"'; } private function getObjectModelColor($n) { if ($n > 50) { - return 'style="color:red"'; + return 'style="color:' . static::COLOR_ERROR . '"'; } if ($n > 10) { - return 'style="color:#EF8B00"'; + return 'style="color:' . static::COLOR_WARNING . '"'; } - return 'style="color:green"'; + return 'style="color:' . static::COLOR_SUCCESS . '"'; } protected function stamp($block) { - return array('block' => $block, 'memory_usage' => memory_get_usage(), 'peak_memory_usage' => memory_get_peak_usage(), 'time' => microtime(true)); + return [ + 'block' => $block, + 'memory_usage' => memory_get_usage(), + 'peak_memory_usage' => memory_get_peak_usage(), + 'time' => microtime(true) + ]; } public function __construct() @@ -240,8 +253,8 @@ public function run() if ($this->ajax) { $action = Tools::toCamelCase(Tools::getValue('action'), true); - if (!empty($action) && method_exists($this, 'displayAjax'.$action)) { - $this->{'displayAjax'.$action}(); + if (!empty($action) && method_exists($this, 'displayAjax' . $action)) { + $this->{'displayAjax' . $action}(); } elseif (method_exists($this, 'displayAjax')) { $this->displayAjax(); } @@ -275,7 +288,7 @@ private function getVarData($var) return $var; } - return (string)$var; + return (string) $var; } protected function processProfilingData() @@ -308,17 +321,17 @@ protected function processProfilingData() $queries = Db::getInstance()->queries; uasort($queries, 'prestashop_querytime_sort'); foreach ($queries as $data) { - $query_row = array( + $query_row = [ 'time' => $data['time'], 'query' => $data['query'], - 'location' => str_replace('\\', '/', substr($data['stack'][0]['file'], strlen(_PS_ROOT_DIR_))).':'.$data['stack'][0]['line'], + 'location' => str_replace('\\', '/', substr($data['stack'][0]['file'], strlen(_PS_ROOT_DIR_))) . ':' . $data['stack'][0]['line'], 'filesort' => false, 'rows' => 1, 'group_by' => false, - 'stack' => array(), - ); + 'stack' => [], + ]; if (preg_match('/^\s*select\s+/i', $data['query'])) { - $explain = Db::getInstance()->executeS('explain '.$data['query']); + $explain = Db::getInstance()->executeS('explain ' . $data['query']); if (stristr($explain[0]['Extra'], 'filesort')) { $query_row['filesort'] = true; } @@ -332,7 +345,7 @@ protected function processProfilingData() array_shift($data['stack']); foreach ($data['stack'] as $call) { - $query_row['stack'][] = str_replace('\\', '/', substr($call['file'], strlen(_PS_ROOT_DIR_))).':'.$call['line']; + $query_row['stack'][] = str_replace('\\', '/', substr($call['file'], strlen(_PS_ROOT_DIR_))) . ':' . $call['line']; } $this->array_queries[] = $query_row; @@ -351,7 +364,7 @@ protected function displayProfilingLinks()
  • Stopwatch SQL
  • Doubles
  • Tables stress
  • - '.(isset(ObjectModel::$debug_list) ? '
  • ObjectModel instances
  • ' : '').' + ' . (isset(ObjectModel::$debug_list) ? '
  • ObjectModel instances
  • ' : '') . '
  • Included Files
  • '; @@ -432,15 +445,15 @@ protected function displayProfilingSummary() echo '
    - - - - - - '; + + + + + + '; foreach ($this->global_var_size as $global => $size) { - echo ''; + echo ''; } echo '
    Load Time'.$this->getLoadTimeColor($this->profiler[count($this->profiler) - 1]['time'] - $start_time, true).'
    Querying Time'.$this->getTotalQueriyingTimeColor(round(1000 * $this->total_query_time)).' ms -
    Queries'.$this->getNbQueriesColor(count($this->array_queries)).'
    Memory Peak Usage'.$this->getPeakMemoryColor($this->profiler[count($this->profiler) - 1]['peak_memory_usage']).' Mb
    Included Files'.count(get_included_files()).' files - '.$this->getMemoryColor($this->total_filesize).' Mb
    PrestaShop Cache'.$this->getMemoryColor($this->total_cache_size).' Mb
    Global vars'.$this->getMemoryColor($this->total_global_var_size).' Mb
    Load Time' . $this->getLoadTimeColor($this->profiler[count($this->profiler) - 1]['time'] - $start_time, true) . '
    Querying Time' . $this->getTotalQueriyingTimeColor(round(1000 * $this->total_query_time)) . ' ms +
    Queries' . $this->getNbQueriesColor(count($this->array_queries)) . '
    Memory Peak Usage' . $this->getPeakMemoryColor($this->profiler[count($this->profiler) - 1]['peak_memory_usage']) . ' Mb
    Included Files' . count(get_included_files()) . ' files - ' . $this->getMemoryColor($this->total_filesize) . ' Mb
    PrestaShop Cache' . $this->getMemoryColor($this->total_cache_size) . ' Mb
    Global vars' . $this->getMemoryColor($this->total_global_var_size) . ' Mb
    @@ -452,13 +465,13 @@ protected function displayProfilingConfiguration() echo '
    - - - - - - - + + + + + + +
    PrestaShop Version'._PS_VERSION_.'
    PHP Version'.$this->getPhpVersionColor(PHP_VERSION).'
    MySQL Version'.$this->getMySQLVersionColor(Db::getInstance()->getVersion()).'
    Memory Limit'.ini_get('memory_limit').'
    Max Execution Time'.ini_get('max_execution_time').'s
    Smarty Cacheenabled' : 'red">disabled').'
    Smarty Compilationnever recompile' : (Configuration::get('PS_SMARTY_FORCE_COMPILE') == 1 ? '#EF8B00">auto' : 'red">force compile')).'
    PrestaShop Version' . _PS_VERSION_ . '
    PHP Version' . $this->getPhpVersionColor(PHP_VERSION) . '
    MySQL Version' . $this->getMySQLVersionColor(Db::getInstance()->getVersion()) . '
    Memory Limit' . ini_get('memory_limit') . '
    Max Execution Time' . ini_get('max_execution_time') . 's
    Smarty Cacheenabled' : 'red">disabled') . '
    Smarty Compilationnever recompile' : (Configuration::get('PS_SMARTY_FORCE_COMPILE') == 1 ? '#EF8B00">auto' : 'red">force compile')) . '
    '; } @@ -471,17 +484,17 @@ protected function displayProfilingRun()
    '; - $last = array('time' => $start_time, 'memory_usage' => 0); + $last = ['time' => $start_time, 'memory_usage' => 0]; foreach ($this->profiler as $row) { if ($row['block'] == 'checkAccess' && $row['time'] == $last['time']) { continue; } echo ' - - - - - + + + + + '; $last = $row; } @@ -506,34 +519,34 @@ protected function displayProfilingHooks() echo ' '; foreach ($hooks_perfs['modules'] as $module => $perfs) { echo ' - + '; } } echo ' - - - + + +
     TimeCumulated TimeMemory UsageMemory Peak Usage
    '.$row['block'].''.$this->getLoadTimeColor($row['time'] - $last['time']).' ms'.$this->getLoadTimeColor($row['time'] - $start_time).' ms'.$this->getMemoryColor($row['memory_usage'] - $last['memory_usage']).' Mb'.$this->getMemoryColor($row['peak_memory_usage']).' Mb' . $row['block'] . '' . $this->getLoadTimeColor($row['time'] - $last['time']) . ' ms' . $this->getLoadTimeColor($row['time'] - $start_time) . ' ms' . $this->getMemoryColor($row['memory_usage'] - $last['memory_usage']) . ' Mb' . $this->getMemoryColor($row['peak_memory_usage']) . ' Mb
    - '.$hook.' + ' . $hook . ' - '.$this->getLoadTimeColor($hooks_perfs['time']).' ms + ' . $this->getLoadTimeColor($hooks_perfs['time']) . ' ms - '.$this->getMemoryColor($hooks_perfs['memory']).' Mb + ' . $this->getMemoryColor($hooks_perfs['memory']) . ' Mb
    '.($count_hooks == 1 ? '1 hook' : (int)$count_hooks.' hooks').''.$this->getLoadTimeColor($this->total_modules_time).' ms'.$this->getMemoryColor($this->total_modules_memory).' Mb' . ($count_hooks == 1 ? '1 hook' : (int) $count_hooks . ' hooks') . '' . $this->getLoadTimeColor($this->total_modules_time) . ' ms' . $this->getMemoryColor($this->total_modules_memory) . ' Mb
    '; @@ -555,34 +568,34 @@ protected function displayProfilingModules() echo ' - '.$module.' + ' . $module . ' - '.$this->getLoadTimeColor($modules_perfs['time']).' ms + ' . $this->getLoadTimeColor($modules_perfs['time']) . ' ms - '.$this->getMemoryColor($modules_perfs['memory']).' Mb + ' . $this->getMemoryColor($modules_perfs['memory']) . ' Mb '; foreach ($modules_perfs['methods'] as $hook => $perfs) { echo ' - + - => '.$hook.' + => ' . $hook . ' - '.$this->getLoadTimeColor($perfs['time']).' ms + ' . $this->getLoadTimeColor($perfs['time']) . ' ms - '.$this->getMemoryColor($perfs['memory']).' Mb + ' . $this->getMemoryColor($perfs['memory']) . ' Mb '; } } echo ' - '.($count_modules == 1 ? '1 module' : (int)$count_modules.' modules').' - '.$this->getLoadTimeColor($this->total_modules_time).' ms - '.$this->getMemoryColor($this->total_modules_memory).' Mb + ' . ($count_modules == 1 ? '1 module' : (int) $count_modules . ' modules') . ' + ' . $this->getLoadTimeColor($this->total_modules_time) . ' ms + ' . $this->getMemoryColor($this->total_modules_memory) . ' Mb
    '; @@ -592,7 +605,7 @@ protected function displayProfilingStopwatch() { echo '
    -

    Stopwatch SQL - '.count($this->array_queries).' queries

    +

    Stopwatch SQL - ' . count($this->array_queries) . ' queries

    @@ -611,14 +624,14 @@ protected function displayProfilingStopwatch() echo ' - - - - - - + + + + + '; } @@ -633,7 +646,7 @@ protected function displayProfilingDoubles()
    '.preg_replace("/(^[\s]*)/m", "", htmlspecialchars($data['query'], ENT_NOQUOTES, 'utf-8', false)).'
    getTimeColor($data['time'] * 1000).'>'.(round($data['time'] * 1000, 1) < 0.1 ? '< 1' : round($data['time'] * 1000, 1)).''.(int)$data['rows'].''.($data['filesort'] ? 'Yes' : '').''.($data['group_by'] ? 'Yes' : '').' - '.$data['location'].' - +
    ' . preg_replace("/(^[\s]*)/m", '', htmlspecialchars($data['query'], ENT_NOQUOTES, 'utf-8', false)) . '
    getTimeColor($data['time'] * 1000) . '>' . (round($data['time'] * 1000, 1) < 0.1 ? '< 1' : round($data['time'] * 1000, 1)) . '' . (int) $data['rows'] . '' . ($data['filesort'] ? 'Yes' : '') . '' . ($data['group_by'] ? 'Yes' : '') . ' + ' . $data['location'] . ' +
    '; foreach (Db::getInstance()->uniqQueries as $q => $nb) { if ($nb > 1) { - echo ''; + echo ''; } } echo '
    getQueryColor($nb).'>'.$nb.'
    '.$q.'
    getQueryColor($nb) . '>' . $nb . '
    ' . $q . '
    @@ -646,7 +659,7 @@ protected function displayProfilingTableStress()

    Tables stress

    '; foreach (Db::getInstance()->tables as $table => $nb) { - echo ''; + echo ''; } echo '
    getTableColor($nb).'>'.$nb.' '.$table.'
    getTableColor($nb) . '>' . $nb . ' ' . $table . '
    '; @@ -661,11 +674,11 @@ protected function displayProfilingObjectModel() NameInstancesSource'; foreach (ObjectModel::$debug_list as $class => $info) { echo ' - '.$class.' - getObjectModelColor(count($info)).'>'.count($info).' + ' . $class . ' + getObjectModelColor(count($info)) . '>' . count($info) . ' '; foreach ($info as $trace) { - echo str_replace(array(_PS_ROOT_DIR_, '\\'), array('', '/'), $trace['file']).' ['.$trace['line'].']
    '; + echo str_replace([_PS_ROOT_DIR_, '\\'], ['', '/'], $trace['file']) . ' [' . $trace['line'] . ']
    '; } echo ' '; @@ -687,7 +700,7 @@ protected function displayProfilingFiles() if (strpos($file, '/tools/profiling/') === 0) { continue; } - echo ''.(++$i).''.$file.''; + echo '' . (++$i) . '' . $file . ''; } echo ' '; @@ -708,7 +721,7 @@ public function displayProfiling()
    '; } else { diff --git a/tools/profiling/Db.php b/tools/profiling/Db.php index 2872d71cca8d6..2431079249d68 100644 --- a/tools/profiling/Db.php +++ b/tools/profiling/Db.php @@ -23,7 +23,6 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ - abstract class Db extends DbCore { /** @@ -45,21 +44,21 @@ abstract class Db extends DbCore * * @var array */ - public $queries = array(); + public $queries = []; /** * List of uniq queries (replace numbers by XX) * * @var array */ - public $uniqQueries = array(); + public $uniqQueries = []; /** * List of tables * * @var array */ - public $tables = array(); + public $tables = []; /** * Execute the query and log some informations @@ -79,7 +78,7 @@ public function query($sql) if (!isset($this->uniqQueries[$uniqSql])) { $this->uniqQueries[$uniqSql] = 0; } - $this->uniqQueries[$uniqSql]++; + ++$this->uniqQueries[$uniqSql]; // No cache for query if ($this->disableCache && !stripos($sql, 'SQL_NO_CACHE')) { @@ -87,12 +86,12 @@ public function query($sql) } // Get tables in query - preg_match_all('/(from|join)\s+`?'._DB_PREFIX_.'([a-z0-9_-]+)/ui', $sql, $matches); + preg_match_all('/(from|join)\s+`?' . _DB_PREFIX_ . '([a-z0-9_-]+)/ui', $sql, $matches); foreach ($matches[2] as $table) { if (!isset($this->tables[$table])) { $this->tables[$table] = 0; } - $this->tables[$table]++; + ++$this->tables[$table]; } $start = microtime(true); @@ -108,16 +107,16 @@ public function query($sql) while (preg_match('@[/\\\\]classes[/\\\\]db[/\\\\]@i', $stack[0]['file'])) { array_shift($stack); } - $stack_light = array(); + $stack_light = []; foreach ($stack as $call) { - $stack_light[] = array('file' => isset($call['file']) ? $call['file'] : 'undefined', 'line' => isset($call['line']) ? $call['line'] : 'undefined'); + $stack_light[] = ['file' => isset($call['file']) ? $call['file'] : 'undefined', 'line' => isset($call['line']) ? $call['line'] : 'undefined']; } - $this->queries[] = array( + $this->queries[] = [ 'query' => $sql, 'time' => $end - $start, 'stack' => $stack_light, - ); + ]; } return $result; diff --git a/tools/profiling/ObjectModel.php b/tools/profiling/ObjectModel.php index ec5a2bb0eebaa..169b2336ca2fd 100644 --- a/tools/profiling/ObjectModel.php +++ b/tools/profiling/ObjectModel.php @@ -23,10 +23,9 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ - abstract class ObjectModel extends ObjectModelCore { - public static $debug_list = array(); + public static $debug_list = []; public function __construct($id = null, $id_lang = null, $id_shop = null) { @@ -34,21 +33,21 @@ public function __construct($id = null, $id_lang = null, $id_shop = null) $classname = get_class($this); if (!isset(self::$debug_list[$classname])) { - self::$debug_list[$classname] = array(); + self::$debug_list[$classname] = []; } - $class_list = array('ObjectModel', 'ObjectModelCore', $classname, $classname.'Core'); + $class_list = ['ObjectModel', 'ObjectModelCore', $classname, $classname . 'Core']; $backtrace = debug_backtrace(); foreach ($backtrace as $trace_id => $row) { if (!isset($backtrace[$trace_id]['class']) || !in_array($backtrace[$trace_id]['class'], $class_list)) { break; } } - $trace_id--; + --$trace_id; - self::$debug_list[$classname][] = array( + self::$debug_list[$classname][] = [ 'file' => @$backtrace[$trace_id]['file'], 'line' => @$backtrace[$trace_id]['line'], - ); + ]; } } diff --git a/tools/profiling/Tools.php b/tools/profiling/Tools.php index d2ad7ed0216bf..780b159dff275 100644 --- a/tools/profiling/Tools.php +++ b/tools/profiling/Tools.php @@ -23,7 +23,6 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ - class Tools extends ToolsCore { public static function redirect($url, $base_uri = __PS_BASE_URI__, Link $link = null, $headers = null) @@ -49,14 +48,14 @@ public static function redirect($url, $base_uri = __PS_BASE_URI__, Link $link = $use_ssl = !empty($url); $url = $link->getPageLink($explode[0], $use_ssl); if (isset($explode[1])) { - $url .= '?'.$explode[1]; + $url .= '?' . $explode[1]; } } // Send additional headers if ($headers) { if (!is_array($headers)) { - $headers = array($headers); + $headers = [$headers]; } foreach ($headers as $header) { @@ -70,12 +69,12 @@ public static function redirect($url, $base_uri = __PS_BASE_URI__, Link $link = public static function getDefaultControllerClass() { if (isset(Context::getContext()->employee) && Validate::isLoadedObject(Context::getContext()->employee) && isset(Context::getContext()->employee->default_tab)) { - $default_controller = Tab::getClassNameById((int)Context::getContext()->employee->default_tab); + $default_controller = Tab::getClassNameById((int) Context::getContext()->employee->default_tab); } if (empty($default_controller)) { $default_controller = 'AdminDashboard'; } - $controllers = Dispatcher::getControllers(array(_PS_ADMIN_DIR_.'/tabs/', _PS_ADMIN_CONTROLLER_DIR_, _PS_OVERRIDE_DIR_.'controllers/admin/')); + $controllers = Dispatcher::getControllers([_PS_ADMIN_DIR_ . '/tabs/', _PS_ADMIN_CONTROLLER_DIR_, _PS_OVERRIDE_DIR_ . 'controllers/admin/']); if (!isset($controllers[strtolower($default_controller)])) { $default_controller = 'adminnotfound'; } @@ -93,7 +92,7 @@ public static function redirectLink($url) $explode = explode('?', $url); $url = Context::getContext()->link->getPageLink($explode[0]); if (isset($explode[1])) { - $url .= '?'.$explode[1]; + $url .= '?' . $explode[1]; } } } diff --git a/tools/profiling/index.php b/tools/profiling/index.php index 76cd9dd33aea9..c7835bc882bbf 100644 --- a/tools/profiling/index.php +++ b/tools/profiling/index.php @@ -23,13 +23,12 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ +header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); +header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); +header('Cache-Control: no-store, no-cache, must-revalidate'); +header('Cache-Control: post-check=0, pre-check=0', false); +header('Pragma: no-cache'); -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); +header('Location: ../'); exit;