Skip to content

Commit 1fc0864

Browse files
committed
Disable DebugHandler when the profiler is disabled, fixes #37
1 parent d401cab commit 1fc0864

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

DependencyInjection/Compiler/DebugHandlerPass.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* Adds the DebugHandler when the profiler is enabled.
2222
*
2323
* @author Christophe Coevoet <[email protected]>
24+
* @author Jordi Boggiano <[email protected]>
2425
*/
2526
class DebugHandlerPass implements CompilerPassInterface
2627
{
@@ -37,6 +38,19 @@ public function process(ContainerBuilder $container)
3738
return;
3839
}
3940

41+
// detect if the profiler is present but will be disabled
42+
$enabled = true;
43+
foreach ($container->getDefinition('profiler')->getMethodCalls() as $call) {
44+
if ($call[0] === 'disable') {
45+
$enabled = false;
46+
} elseif ($call[0] === 'enable') {
47+
$enabled = true;
48+
}
49+
}
50+
if (!$enabled) {
51+
return;
52+
}
53+
4054
$debugHandler = new Definition('%monolog.handler.debug.class%', array(Logger::DEBUG, true));
4155
$container->setDefinition('monolog.handler.debug', $debugHandler);
4256

0 commit comments

Comments
 (0)