diff --git a/Command/CacheWarmupCommand.php b/Command/CacheWarmupCommand.php index d094902c3..c40e39386 100644 --- a/Command/CacheWarmupCommand.php +++ b/Command/CacheWarmupCommand.php @@ -19,6 +19,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\DependencyInjection\Dumper\Preloader; use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate; +use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface; /** * Warmup the cache. @@ -65,8 +66,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (!$input->getOption('no-optional-warmers')) { $this->cacheWarmer->enableOptionalWarmers(); } + $cacheDir = $kernel->getContainer()->getParameter('kernel.cache_dir'); - $preload = $this->cacheWarmer->warmUp($cacheDir = $kernel->getContainer()->getParameter('kernel.cache_dir')); + if ($kernel instanceof WarmableInterface) { + $kernel->warmUp($cacheDir); + } + + $preload = $this->cacheWarmer->warmUp($cacheDir); if ($preload && file_exists($preloadFile = $cacheDir.'/'.$kernel->getContainer()->getParameter('kernel.container_class').'.preload.php')) { Preloader::append($preloadFile, $preload); diff --git a/DependencyInjection/Compiler/ErrorLoggerCompilerPass.php b/DependencyInjection/Compiler/ErrorLoggerCompilerPass.php new file mode 100644 index 000000000..09f2dba82 --- /dev/null +++ b/DependencyInjection/Compiler/ErrorLoggerCompilerPass.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; + +/** + * @internal + */ +class ErrorLoggerCompilerPass implements CompilerPassInterface +{ + public function process(ContainerBuilder $container): void + { + if (!$container->hasDefinition('debug.error_handler_configurator')) { + return; + } + + $definition = $container->getDefinition('debug.error_handler_configurator'); + if ($container->hasDefinition('monolog.logger.php')) { + $definition->replaceArgument(0, new Reference('monolog.logger.php')); + } + if ($container->hasDefinition('monolog.logger.deprecation')) { + $definition->replaceArgument(5, new Reference('monolog.logger.deprecation')); + } + } +} diff --git a/FrameworkBundle.php b/FrameworkBundle.php index 339b28e83..8a0021725 100644 --- a/FrameworkBundle.php +++ b/FrameworkBundle.php @@ -18,6 +18,7 @@ use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\EnableLoggerDebugModePass; +use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ErrorLoggerCompilerPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RemoveUnusedSessionMarshallingHandlerPass; @@ -181,6 +182,8 @@ public function build(ContainerBuilder $container) $container->addCompilerPass(new RegisterReverseContainerPass(true)); $container->addCompilerPass(new RegisterReverseContainerPass(false), PassConfig::TYPE_AFTER_REMOVING); $container->addCompilerPass(new RemoveUnusedSessionMarshallingHandlerPass()); + // must be registered after MonologBundle's LoggerChannelPass + $container->addCompilerPass(new ErrorLoggerCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32); if ($container->getParameter('kernel.debug')) { $container->addCompilerPass(new EnableLoggerDebugModePass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -33); diff --git a/Resources/config/debug_prod.php b/Resources/config/debug_prod.php index 7f71e2ee9..b4649182b 100644 --- a/Resources/config/debug_prod.php +++ b/Resources/config/debug_prod.php @@ -22,12 +22,12 @@ ->set('debug.error_handler_configurator', ErrorHandlerConfigurator::class) ->public() ->args([ - service('monolog.logger.php')->nullOnInvalid(), + service('logger')->nullOnInvalid(), null, // Log levels map for enabled error levels param('debug.error_handler.throw_at'), param('kernel.debug'), param('kernel.debug'), - service('monolog.logger.deprecation')->nullOnInvalid(), + service('logger')->nullOnInvalid(), ]) ->tag('monolog.logger', ['channel' => 'php']) diff --git a/Test/NotificationAssertionsTrait.php b/Test/NotificationAssertionsTrait.php index 30298ef04..5f2876c63 100644 --- a/Test/NotificationAssertionsTrait.php +++ b/Test/NotificationAssertionsTrait.php @@ -29,7 +29,7 @@ public static function assertNotificationCount(int $count, string $transportName public static function assertQueuedNotificationCount(int $count, string $transportName = null, string $message = ''): void { - self::assertThat(self::getMessageMailerEvents(), new NotifierConstraint\NotificationCount($count, $transportName, true), $message); + self::assertThat(self::getNotificationEvents(), new NotifierConstraint\NotificationCount($count, $transportName, true), $message); } public static function assertNotificationIsQueued(MessageEvent $event, string $message = ''): void diff --git a/Tests/DependencyInjection/FrameworkExtensionTestCase.php b/Tests/DependencyInjection/FrameworkExtensionTestCase.php index e86cc3975..aeb0885c9 100644 --- a/Tests/DependencyInjection/FrameworkExtensionTestCase.php +++ b/Tests/DependencyInjection/FrameworkExtensionTestCase.php @@ -548,7 +548,7 @@ public function testEnabledPhpErrorsConfig() $container = $this->createContainerFromFile('php_errors_enabled'); $definition = $container->getDefinition('debug.error_handler_configurator'); - $this->assertEquals(new Reference('monolog.logger.php', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(0)); + $this->assertEquals(new Reference('logger', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(0)); $this->assertNull($definition->getArgument(1)); $this->assertSame(-1, $container->getParameter('debug.error_handler.throw_at')); } @@ -568,7 +568,7 @@ public function testPhpErrorsWithLogLevel() $container = $this->createContainerFromFile('php_errors_log_level'); $definition = $container->getDefinition('debug.error_handler_configurator'); - $this->assertEquals(new Reference('monolog.logger.php', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(0)); + $this->assertEquals(new Reference('logger', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(0)); $this->assertSame(8, $definition->getArgument(1)); } @@ -577,7 +577,7 @@ public function testPhpErrorsWithLogLevels() $container = $this->createContainerFromFile('php_errors_log_levels'); $definition = $container->getDefinition('debug.error_handler_configurator'); - $this->assertEquals(new Reference('monolog.logger.php', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(0)); + $this->assertEquals(new Reference('logger', ContainerInterface::NULL_ON_INVALID_REFERENCE), $definition->getArgument(0)); $this->assertSame([ \E_NOTICE => \Psr\Log\LogLevel::ERROR, \E_WARNING => \Psr\Log\LogLevel::ERROR,