diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rwxr-xr-x | config/global.ini.php | 6 | ||||
-rw-r--r-- | core/FrontController.php | 5 | ||||
-rw-r--r-- | core/Profiler.php | 1 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/FrontControllerTest.php | 2 | ||||
-rw-r--r-- | tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png | 4 |
6 files changed, 16 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 44496c3910..787faa8092 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The Product Changelog at **[matomo.org/changelog](https://matomo.org/changelog)* ### New config.ini.php settings * The `password_hash_algorithm`, `password_hash_argon2_threads`, `password_hash_argon2_memory_cost` and `password_hash_argon2_time_cost` INI config options have been added to allow using specific `password_hash` algorithms and options if desired. +* The `enable_php_profiler` INI config option was added. This must now be set to 1 before profiling is allowed in Matomo. ## Matomo 4.2.0 diff --git a/config/global.ini.php b/config/global.ini.php index 3fec499e6f..12655bcb8d 100755 --- a/config/global.ini.php +++ b/config/global.ini.php @@ -157,6 +157,12 @@ archiving_profile = 0 ; if set to an absolute path, core:archive profiling information will be logged to specified file archive_profiling_log = +; if set to 1, use of a php profiler will be enabled. the profiler will not be activated unless its installation +; can be detected and the correct query and CLI parameters are supplied to toggle it. +; Note: this setting is not dependent on development mode, since it is often required to run the profiler with +; all optimizations and caches enabled. +enable_php_profiler = 0 + [DebugTests] ; When set to 1, standalone plugins (those with their own git repositories) ; will be loaded when executing tests. diff --git a/core/FrontController.php b/core/FrontController.php index ba44e944f1..359df2fa99 100644 --- a/core/FrontController.php +++ b/core/FrontController.php @@ -561,6 +561,11 @@ class FrontController extends Singleton private function handleProfiler() { + $profilerEnabled = Config::getInstance()->Debug['enable_php_profiler'] == 1; + if (!$profilerEnabled) { + return; + } + if (!empty($_GET['xhprof'])) { $mainRun = $_GET['xhprof'] == 1; // core:archive command sets xhprof=2 Profiler::setupProfilerXHProf($mainRun); diff --git a/core/Profiler.php b/core/Profiler.php index 0274a9e8a2..1f69c24266 100644 --- a/core/Profiler.php +++ b/core/Profiler.php @@ -302,6 +302,7 @@ class Profiler $baseUrl = $baseUrlStored; } $baseUrl = $baseUrlStored . "vendor/lox/xhprof/xhprof_html/?source=$profilerNamespace&run=$runId"; + $baseUrl = Common::sanitizeInputValue($baseUrl); $out .= "Profiler report is available at:\n"; $out .= "<a href='$baseUrl'>$baseUrl</a>"; diff --git a/tests/PHPUnit/Integration/FrontControllerTest.php b/tests/PHPUnit/Integration/FrontControllerTest.php index 999c2b1632..f8593e8495 100644 --- a/tests/PHPUnit/Integration/FrontControllerTest.php +++ b/tests/PHPUnit/Integration/FrontControllerTest.php @@ -48,7 +48,7 @@ FORMAT; $this->assertEquals('error', $response['result']); $expectedFormat = <<<FORMAT -test message on {includePath}/tests/resources/trigger-fatal-exception.php(23) #0 [internal function]: {closure}('CoreHome', 'index', Array) #1 {includePath}/core/EventDispatcher.php(141): call_user_func_array(Object(Closure), Array) #2 {includePath}/core/Piwik.php(809): Piwik\EventDispatcher->postEvent('Request.dispatc...', Array, false, Array) #3 {includePath}/core/FrontController.php(590): Piwik\Piwik::postEvent('Request.dispatc...', Array) #4 {includePath}/core/FrontController.php(167): Piwik\FrontController->doDispatch('CoreHome', 'index', Array) #5 {includePath}/tests/resources/trigger-fatal-exception.php(31): Piwik\FrontController->dispatch('CoreHome', 'index') #6 {main} +test message on {includePath}/tests/resources/trigger-fatal-exception.php(23) #0 [internal function]: {closure}('CoreHome', 'index', Array) #1 {includePath}/core/EventDispatcher.php(141): call_user_func_array(Object(Closure), Array) #2 {includePath}/core/Piwik.php(809): Piwik\EventDispatcher->postEvent('Request.dispatc...', Array, false, Array) #3 {includePath}/core/FrontController.php(595): Piwik\Piwik::postEvent('Request.dispatc...', Array) #4 {includePath}/core/FrontController.php(167): Piwik\FrontController->doDispatch('CoreHome', 'index', Array) #5 {includePath}/tests/resources/trigger-fatal-exception.php(31): Piwik\FrontController->dispatch('CoreHome', 'index') #6 {main} FORMAT; $this->assertStringMatchesFormat($expectedFormat, $response['message']); } diff --git a/tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png b/tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png index f0302ae30b..63116f6e82 100644 --- a/tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png +++ b/tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fce9b20b21526eb301aed8206660f85903e37c3b5d2ac562f1e238234104833e -size 4950503 +oid sha256:94a7dd514ab0c6706a45db218b9e02294340d35c21d4ce1c54183208c0bcfdbb +size 4975287 |