Skip to content

Commit 4b0edfe

Browse files
committed
Merge branch '2.x'
* 2.x: Update the removal version in the deprecation message Add a better detection of the deprecation case revert disabling DebugHandler in CLI environments
2 parents 6ea2d32 + b0146bd commit 4b0edfe

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

DependencyInjection/Compiler/DebugHandlerPass.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bundle\MonologBundle\DependencyInjection\Compiler;
1313

14-
@trigger_error('The '.__NAMESPACE__.'\DebugHandlerPass class is deprecated since version 2.12 and will be removed in 3.0. Use AddDebugLogProcessorPass in FrameworkBundle instead.', E_USER_DEPRECATED);
1514

1615
use Symfony\Component\DependencyInjection\Reference;
1716
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -25,14 +24,19 @@
2524
* @author Christophe Coevoet <stof@notk.org>
2625
* @author Jordi Boggiano <j.boggiano@seld.be>
2726
*
28-
* @deprecated since version 2.12, to be removed in 3.0. Use AddDebugLogProcessorPass in FrameworkBundle instead.
27+
* @deprecated since version 2.12, to be removed in 4.0. Use AddDebugLogProcessorPass in FrameworkBundle instead.
2928
*/
3029
class DebugHandlerPass implements CompilerPassInterface
3130
{
3231
private $channelPass;
3332

3433
public function __construct(LoggerChannelPass $channelPass)
3534
{
35+
// Trigger the deprecation only when using a Symfony version supporting the new feature (i.e. 3.2+)
36+
if (class_exists('Symfony\Bridge\Monolog\Processor\DebugProcessor') && class_exists('Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddDebugLogProcessorPass')) {
37+
@trigger_error('The '.__CLASS__.' class is deprecated since version 2.12 and will be removed in 4.0. Use AddDebugLogProcessorPass in FrameworkBundle instead.', E_USER_DEPRECATED);
38+
}
39+
3640
$this->channelPass = $channelPass;
3741
}
3842

@@ -46,11 +50,6 @@ public function process(ContainerBuilder $container)
4650
return;
4751
}
4852

49-
// disable the DebugHandler in CLI as it tends to leak memory if people enable kernel.debug
50-
if ('cli' === PHP_SAPI) {
51-
return;
52-
}
53-
5453
$debugHandler = new Definition('Symfony\Bridge\Monolog\Handler\DebugHandler', array(Logger::DEBUG, true));
5554
$container->setDefinition('monolog.handler.debug', $debugHandler);
5655

MonologBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function build(ContainerBuilder $container)
3434
parent::build($container);
3535

3636
$container->addCompilerPass($channelPass = new LoggerChannelPass());
37-
if (!class_exists('Symfony\Bridge\Monolog\Processor\DebugProcessor')) {
37+
if (!class_exists('Symfony\Bridge\Monolog\Processor\DebugProcessor') || !class_exists('Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddDebugLogProcessorPass')) {
3838
$container->addCompilerPass(new DebugHandlerPass($channelPass));
3939
}
4040
$container->addCompilerPass(new FixEmptyLoggerPass($channelPass));

0 commit comments

Comments
 (0)