Skip to content

Commit ae3762c

Browse files
committed
Add a better detection of the deprecation case
1 parent d148888 commit ae3762c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

DependencyInjection/Compiler/DebugHandlerPass.php

Lines changed: 5 additions & 1 deletion
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;
@@ -33,6 +32,11 @@ class DebugHandlerPass implements CompilerPassInterface
3332

3433
public function __construct(LoggerChannelPass $channelPass)
3534
{
35+
// Trigger the deprecation only when using a Symfony version supporting the new feature
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 3.0. Use AddDebugLogProcessorPass in FrameworkBundle instead.', E_USER_DEPRECATED);
38+
}
39+
3640
$this->channelPass = $channelPass;
3741
}
3842

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)