From a8a2f9bc7ea3482c86fc5be9ca0e27ae96e94f6e Mon Sep 17 00:00:00 2001 From: mattab <matthieu.aubry@gmail.com> Date: Mon, 18 Nov 2013 12:03:08 +1300 Subject: [PATCH] Refs #4310 --- core/ArchiveProcessor/Parameters.php | 2 +- core/FrontController.php | 12 +++++++++--- core/Profiler.php | 6 +++--- misc/cron/archive.php | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/core/ArchiveProcessor/Parameters.php b/core/ArchiveProcessor/Parameters.php index 70bb06e0ec..49729a4da7 100644 --- a/core/ArchiveProcessor/Parameters.php +++ b/core/ArchiveProcessor/Parameters.php @@ -170,7 +170,7 @@ class Parameters $temporary = 'temporary archive'; } Log::verbose( - "'%s, idSite = %d (%s), segment '%s', report = '%s', UTC datetime [%s -> %s]", + "%s archive, idSite = %d (%s), segment '%s', report = '%s', UTC datetime [%s -> %s]", $this->getPeriod()->getLabel(), $this->getSite()->getId(), $temporary, diff --git a/core/FrontController.php b/core/FrontController.php index e86aceff78..bd010eb936 100644 --- a/core/FrontController.php +++ b/core/FrontController.php @@ -275,9 +275,6 @@ class FrontController extends Singleton Filechecks::dieIfDirectoriesNotWritable($directoriesToCheck); self::assignCliParametersToRequest(); - if(!empty($_GET['xhprof'])) { - Profiler::setupProfilerXHProf($mainRun = false); - } Translate::loadEnglishTranslation(); @@ -289,6 +286,7 @@ class FrontController extends Singleton $this->handleMaintenanceMode(); $this->handleSSLRedirection(); + $this->handleProfiler(); $pluginsManager = \Piwik\Plugin\Manager::getInstance(); $pluginsToLoad = Config::getInstance()->Plugins['Plugins']; @@ -492,6 +490,14 @@ class FrontController extends Singleton } } } + + private function handleProfiler() + { + if (!empty($_GET['xhprof'])) { + $mainRun = $_GET['xhprof'] == 1; // archive.php sets xhprof=2 + Profiler::setupProfilerXHProf($mainRun); + } + } } /** diff --git a/core/Profiler.php b/core/Profiler.php index 7a0f2b0d39..ec48788471 100644 --- a/core/Profiler.php +++ b/core/Profiler.php @@ -227,7 +227,7 @@ class Profiler if($mainRun) { $runIds = implode(',', $runs); $out = "\n\nHere is the profiler URL aggregating all runs triggered from this process: "; - $baseUrl = "http://" . $_SERVER['HTTP_HOST'] . "/" . $_SERVER['REQUEST_URI']; + $baseUrl = "http://" . @$_SERVER['HTTP_HOST'] . "/" . @$_SERVER['REQUEST_URI']; $baseUrlStored = SettingsPiwik::getPiwikUrl(); if(strlen($baseUrlStored) > strlen($baseUrl)) { $baseUrl = $baseUrlStored; @@ -237,7 +237,7 @@ class Profiler $out .= $baseUrl . "$runIds\n\n"; $out .= "Main run profile:"; $out .= $baseUrl . "$runId\n\n"; - Log::info($out); + echo ($out); } else { self::setProfilingRunIds($runs); } @@ -247,7 +247,7 @@ class Profiler private static function setProfilingRunIds($ids) { file_put_contents( self::getPathToXHProfRunIds(), json_encode($ids) ); - chmod(self::getPathToXHProfRunIds(), 0777); + @chmod(self::getPathToXHProfRunIds(), 0777); } private static function getProfilingRunIds() diff --git a/misc/cron/archive.php b/misc/cron/archive.php index dbc947eb4b..8dc70bd0ee 100644 --- a/misc/cron/archive.php +++ b/misc/cron/archive.php @@ -632,7 +632,7 @@ class CronArchive $url = $this->piwikUrl . $url . self::APPEND_TO_API_REQUEST; if($this->shouldStartProfiler) { - $url .= "&xhprof=1"; + $url .= "&xhprof=2"; } //$this->log($url); -- GitLab