Skip to content

Commit e5123df

Browse files
Merge branch '5.4' into 6.3
* 5.4: [FrameworkBundle] Configure `logger` as error logger if the Monolog Bundle is not registered DX: PHP CS Fixer - drop explicit nullable_type_declaration_for_default_null_value config, as it's part of ruleset anyway Revert "Add keyword `dev` to leverage composer hint" [Validator] Add missing Ukrainian translations #51960 [Validator] Add missing translations for Indonesian (id) [Validator] Add missing translations for Vietnamese (VI) Add missing Validator translations - Croatian (hr) Run high-deps tests with ORM 3 and DBAL 4 [FrameworkBundle] Fix calling Kernel::warmUp() when running cache:warmup
2 parents 83d6b80 + 6715a81 commit e5123df

File tree

5 files changed

+52
-6
lines changed

5 files changed

+52
-6
lines changed

Command/CacheWarmupCommand.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Symfony\Component\Console\Style\SymfonyStyle;
2020
use Symfony\Component\DependencyInjection\Dumper\Preloader;
2121
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate;
22+
use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;
2223

2324
/**
2425
* Warmup the cache.
@@ -65,8 +66,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6566
if (!$input->getOption('no-optional-warmers')) {
6667
$this->cacheWarmer->enableOptionalWarmers();
6768
}
69+
$cacheDir = $kernel->getContainer()->getParameter('kernel.cache_dir');
6870

69-
$preload = $this->cacheWarmer->warmUp($cacheDir = $kernel->getContainer()->getParameter('kernel.cache_dir'));
71+
if ($kernel instanceof WarmableInterface) {
72+
$kernel->warmUp($cacheDir);
73+
}
74+
75+
$preload = $this->cacheWarmer->warmUp($cacheDir);
7076

7177
if ($preload && file_exists($preloadFile = $cacheDir.'/'.$kernel->getContainer()->getParameter('kernel.container_class').'.preload.php')) {
7278
Preloader::append($preloadFile, $preload);
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
13+
14+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
use Symfony\Component\DependencyInjection\Reference;
17+
18+
/**
19+
* @internal
20+
*/
21+
class ErrorLoggerCompilerPass implements CompilerPassInterface
22+
{
23+
public function process(ContainerBuilder $container)
24+
{
25+
if (!$container->hasDefinition('debug.debug_handlers_listener')) {
26+
return;
27+
}
28+
29+
$definition = $container->getDefinition('debug.debug_handlers_listener');
30+
if ($container->hasDefinition('monolog.logger.php')) {
31+
$definition->replaceArgument(0, new Reference('monolog.logger.php'));
32+
}
33+
if ($container->hasDefinition('monolog.logger.deprecation')) {
34+
$definition->replaceArgument(5, new Reference('monolog.logger.deprecation'));
35+
}
36+
}
37+
}

FrameworkBundle.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass;
1919
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass;
2020
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\EnableLoggerDebugModePass;
21+
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ErrorLoggerCompilerPass;
2122
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass;
2223
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass;
2324
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RemoveUnusedSessionMarshallingHandlerPass;
@@ -181,6 +182,8 @@ public function build(ContainerBuilder $container)
181182
$container->addCompilerPass(new RegisterReverseContainerPass(true));
182183
$container->addCompilerPass(new RegisterReverseContainerPass(false), PassConfig::TYPE_AFTER_REMOVING);
183184
$container->addCompilerPass(new RemoveUnusedSessionMarshallingHandlerPass());
185+
// must be registered after MonologBundle's LoggerChannelPass
186+
$container->addCompilerPass(new ErrorLoggerCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32);
184187

185188
if ($container->getParameter('kernel.debug')) {
186189
$container->addCompilerPass(new EnableLoggerDebugModePass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -33);

Resources/config/debug_prod.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
->set('debug.error_handler_configurator', ErrorHandlerConfigurator::class)
2323
->public()
2424
->args([
25-
service('monolog.logger.php')->nullOnInvalid(),
25+
service('logger')->nullOnInvalid(),
2626
null, // Log levels map for enabled error levels
2727
param('debug.error_handler.throw_at'),
2828
param('kernel.debug'),
2929
param('kernel.debug'),
30-
service('monolog.logger.deprecation')->nullOnInvalid(),
30+
service('logger')->nullOnInvalid(),
3131
])
3232
->tag('monolog.logger', ['channel' => 'php'])
3333

Tests/DependencyInjection/FrameworkExtensionTestCase.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ public function testEnabledPhpErrorsConfig()
548548
$container = $this->createContainerFromFile('php_errors_enabled');
549549

550550
$definition = $container->getDefinition('debug.error_handler_configurator');
551-
$this->assertEquals(new Reference('monolog.logger.php', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(0));
551+
$this->assertEquals(new Reference('logger', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(0));
552552
$this->assertNull($definition->getArgument(1));
553553
$this->assertSame(-1, $container->getParameter('debug.error_handler.throw_at'));
554554
}
@@ -568,7 +568,7 @@ public function testPhpErrorsWithLogLevel()
568568
$container = $this->createContainerFromFile('php_errors_log_level');
569569

570570
$definition = $container->getDefinition('debug.error_handler_configurator');
571-
$this->assertEquals(new Reference('monolog.logger.php', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(0));
571+
$this->assertEquals(new Reference('logger', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(0));
572572
$this->assertSame(8, $definition->getArgument(1));
573573
}
574574

@@ -577,7 +577,7 @@ public function testPhpErrorsWithLogLevels()
577577
$container = $this->createContainerFromFile('php_errors_log_levels');
578578

579579
$definition = $container->getDefinition('debug.error_handler_configurator');
580-
$this->assertEquals(new Reference('monolog.logger.php', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(0));
580+
$this->assertEquals(new Reference('logger', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(0));
581581
$this->assertSame([
582582
\E_NOTICE => \Psr\Log\LogLevel::ERROR,
583583
\E_WARNING => \Psr\Log\LogLevel::ERROR,

0 commit comments

Comments
 (0)