Skip to content

Commit b95b1a5

Browse files
andrewhowdencomjignesh-baldha
authored andcommitted
AD-HOC feat (Profiler): Allow supplying complex profiler configuration
1 parent 12fb1cb commit b95b1a5

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

app/bootstrap.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,18 @@
5454
&& isset($_SERVER['HTTP_ACCEPT'])
5555
&& strpos($_SERVER['HTTP_ACCEPT'], 'text/html') !== false
5656
) {
57-
\Magento\Framework\Profiler::applyConfig(
58-
(isset($_SERVER['MAGE_PROFILER']) && strlen($_SERVER['MAGE_PROFILER'])) ? $_SERVER['MAGE_PROFILER'] : trim(file_get_contents(BP . '/var/profiler.flag')),
57+
$profilerString = isset($_SERVER['MAGE_PROFILER']) && strlen($_SERVER['MAGE_PROFILER'])
58+
? $_SERVER['MAGE_PROFILER']
59+
: trim(file_get_contents(BP . '/var/profiler.flag'));
60+
61+
if ($profilerString && $profilerArray = json_decode($profilerString, true)) {
62+
$profilerConfig = $profilerArray;
63+
} else {
64+
$profilerConfig = $profilerString;
65+
}
66+
67+
Magento\Framework\Profiler::applyConfig(
68+
$profilerConfig,
5969
BP,
6070
!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'
6171
);

0 commit comments

Comments
 (0)