From 8e0fcf933cc4b30f503426c77df7b8c4a868aaeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Mon, 9 Apr 2018 17:58:08 +0200 Subject: [PATCH] [FrameworkBundle] Fixed configuration of php_errors.log --- .../DependencyInjection/Configuration.php | 9 +++++---- .../DependencyInjection/FrameworkExtension.php | 8 +++----- .../FrameworkBundle/Resources/config/debug_prod.xml | 2 +- .../DependencyInjection/FrameworkExtensionTest.php | 12 +++++++++--- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 4f3f65bfff8e..73e7470d9f23 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -889,13 +889,14 @@ private function addPhpErrorsSection(ArrayNodeDefinition $rootNode) ->addDefaultsIfNotSet() ->children() ->scalarNode('log') - ->info('Use the app logger instead of the PHP logger for logging PHP errors.') + ->info('Use the application logger instead of the PHP logger for logging PHP errors.') + ->example('"true" to use the default configuration: log all errors. "false" to disable. An integer bit field of E_* constants.') ->defaultValue($this->debug) ->treatNullLike($this->debug) ->validate() - ->ifTrue(function ($v) { return !(\is_int($v) || \is_bool($v)); }) - ->thenInvalid('The "php_errors.log" parameter should be either an integer or a boolean.') - ->end() + ->ifTrue(function ($v) { return !(\is_int($v) || \is_bool($v)); }) + ->thenInvalid('The "php_errors.log" parameter should be either an integer or a boolean.') + ->end() ->end() ->booleanNode('throw') ->info('Throw PHP errors as \ErrorException instances.') diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index e6825a19bb12..028abd99f200 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -655,12 +655,10 @@ private function registerDebugConfiguration(array $config, ContainerBuilder $con $definition = $container->findDefinition('debug.debug_handlers_listener'); - if (!$config['log']) { + if (false === $config['log']) { $definition->replaceArgument(1, null); - } - - if (\is_int($config['log']) && $config['log']) { - $definition->replaceArgument(3, $config['log']); + } elseif (true !== $config['log']) { + $definition->replaceArgument(2, $config['log']); } if (!$config['throw']) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml index 28a8a8a2c04b..0746f9ccda17 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml @@ -16,7 +16,7 @@ null - -1 + null %debug.error_handler.throw_at% true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index abbfc4944c7f..5157944c7a58 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -340,7 +340,9 @@ public function testEnabledPhpErrorsConfig() { $container = $this->createContainerFromFile('php_errors_enabled'); - $this->assertEquals(new Reference('logger', ContainerInterface::NULL_ON_INVALID_REFERENCE), $container->getDefinition('debug.debug_handlers_listener')->getArgument(1)); + $definition = $container->getDefinition('debug.debug_handlers_listener'); + $this->assertEquals(new Reference('logger', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(1)); + $this->assertNull($definition->getArgument(2)); $this->assertSame(-1, $container->getParameter('debug.error_handler.throw_at')); } @@ -348,7 +350,9 @@ public function testDisabledPhpErrorsConfig() { $container = $this->createContainerFromFile('php_errors_disabled'); - $this->assertNull($container->getDefinition('debug.debug_handlers_listener')->getArgument(1)); + $definition = $container->getDefinition('debug.debug_handlers_listener'); + $this->assertNull($definition->getArgument(1)); + $this->assertNull($definition->getArgument(2)); $this->assertSame(0, $container->getParameter('debug.error_handler.throw_at')); } @@ -356,7 +360,9 @@ public function testPhpErrorsWithLogLevel() { $container = $this->createContainerFromFile('php_errors_log_level'); - $this->assertEquals(8, $container->getDefinition('debug.debug_handlers_listener')->getArgument(3)); + $definition = $container->getDefinition('debug.debug_handlers_listener'); + $this->assertEquals(new Reference('logger', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(1)); + $this->assertSame(8, $definition->getArgument(2)); } public function testRouter()