Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9a99955

Browse files
bug #26874 [FrameworkBundle] Fixed configuration of php_errors.log (lyrixx)
This PR was merged into the 4.1-dev branch. Discussion ---------- [FrameworkBundle] Fixed configuration of php_errors.log | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #26504 and #26740 (wrong implementation) | License | MIT | Doc PR | Commits ------- 8e0fcf9 [FrameworkBundle] Fixed configuration of php_errors.log
2 parents a726f05 + 8e0fcf9 commit 9a99955

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -889,13 +889,14 @@ private function addPhpErrorsSection(ArrayNodeDefinition $rootNode)
889889
->addDefaultsIfNotSet()
890890
->children()
891891
->scalarNode('log')
892-
->info('Use the app logger instead of the PHP logger for logging PHP errors.')
892+
->info('Use the application logger instead of the PHP logger for logging PHP errors.')
893+
->example('"true" to use the default configuration: log all errors. "false" to disable. An integer bit field of E_* constants.')
893894
->defaultValue($this->debug)
894895
->treatNullLike($this->debug)
895896
->validate()
896-
->ifTrue(function ($v) { return !(\is_int($v) || \is_bool($v)); })
897-
->thenInvalid('The "php_errors.log" parameter should be either an integer or a boolean.')
898-
->end()
897+
->ifTrue(function ($v) { return !(\is_int($v) || \is_bool($v)); })
898+
->thenInvalid('The "php_errors.log" parameter should be either an integer or a boolean.')
899+
->end()
899900
->end()
900901
->booleanNode('throw')
901902
->info('Throw PHP errors as \ErrorException instances.')

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -655,12 +655,10 @@ private function registerDebugConfiguration(array $config, ContainerBuilder $con
655655

656656
$definition = $container->findDefinition('debug.debug_handlers_listener');
657657

658-
if (!$config['log']) {
658+
if (false === $config['log']) {
659659
$definition->replaceArgument(1, null);
660-
}
661-
662-
if (\is_int($config['log']) && $config['log']) {
663-
$definition->replaceArgument(3, $config['log']);
660+
} elseif (true !== $config['log']) {
661+
$definition->replaceArgument(2, $config['log']);
664662
}
665663

666664
if (!$config['throw']) {

src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<tag name="monolog.logger" channel="php" />
1717
<argument>null</argument><!-- Exception handler -->
1818
<argument type="service" id="logger" on-invalid="null" />
19-
<argument>-1</argument><!-- Log levels map for enabled error levels -->
19+
<argument>null</argument><!-- Log levels map for enabled error levels -->
2020
<argument>%debug.error_handler.throw_at%</argument>
2121
<argument>true</argument>
2222
<argument type="service" id="debug.file_link_formatter"></argument>

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,23 +340,29 @@ public function testEnabledPhpErrorsConfig()
340340
{
341341
$container = $this->createContainerFromFile('php_errors_enabled');
342342

343-
$this->assertEquals(new Reference('logger', ContainerInterface::NULL_ON_INVALID_REFERENCE), $container->getDefinition('debug.debug_handlers_listener')->getArgument(1));
343+
$definition = $container->getDefinition('debug.debug_handlers_listener');
344+
$this->assertEquals(new Reference('logger', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(1));
345+
$this->assertNull($definition->getArgument(2));
344346
$this->assertSame(-1, $container->getParameter('debug.error_handler.throw_at'));
345347
}
346348

347349
public function testDisabledPhpErrorsConfig()
348350
{
349351
$container = $this->createContainerFromFile('php_errors_disabled');
350352

351-
$this->assertNull($container->getDefinition('debug.debug_handlers_listener')->getArgument(1));
353+
$definition = $container->getDefinition('debug.debug_handlers_listener');
354+
$this->assertNull($definition->getArgument(1));
355+
$this->assertNull($definition->getArgument(2));
352356
$this->assertSame(0, $container->getParameter('debug.error_handler.throw_at'));
353357
}
354358

355359
public function testPhpErrorsWithLogLevel()
356360
{
357361
$container = $this->createContainerFromFile('php_errors_log_level');
358362

359-
$this->assertEquals(8, $container->getDefinition('debug.debug_handlers_listener')->getArgument(3));
363+
$definition = $container->getDefinition('debug.debug_handlers_listener');
364+
$this->assertEquals(new Reference('logger', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(1));
365+
$this->assertSame(8, $definition->getArgument(2));
360366
}
361367

362368
public function testRouter()

0 commit comments

Comments
 (0)