Skip to content

Commit 3f07e10

Browse files
committed
feature #22314 [HttpKernel][FrameworkBundle] Dump container logs in Kernel, to have them also on errors (nicolas-grekas)
This PR was merged into the 3.3-dev branch. Discussion ---------- [HttpKernel][FrameworkBundle] Dump container logs in Kernel, to have them also on errors | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Inspecting container failures without the logs is hard, let's have them at hand. This should not be the responsibility of a compiler pass. Commits ------- a8b8334 [HttpKernel][FrameworkBundle] Dump container logs in Kernel, to have them also on errors
2 parents abb8d2b + a8b8334 commit 3f07e10

File tree

6 files changed

+20
-5
lines changed

6 files changed

+20
-5
lines changed

UPGRADE-3.3.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,10 @@ FrameworkBundle
168168

169169
* The "framework.trusted_proxies" configuration option and the corresponding "kernel.trusted_proxies" parameter have been deprecated and will be removed in 4.0. Use the Request::setTrustedProxies() method in your front controller instead.
170170

171+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CompilerDebugDumpPass` has been deprecated.
171172

172-
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConsoleCommandPass` has been deprecated. Use `Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass` instead.
173+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConsoleCommandPass` has been deprecated.
174+
Use `Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass` instead.
173175

174176
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\SerializerPass` class has been
175177
deprecated and will be removed in 4.0.

UPGRADE-4.0.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,10 @@ FrameworkBundle
267267
`serializer.mapping.cache.apc` and `serializer.mapping.cache.doctrine.apc`
268268
have been removed. APCu should now be automatically used when available.
269269

270-
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConsoleCommandPass` has been removed. Use `Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass` instead.
270+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CompilerDebugDumpPass` has been removed.
271+
272+
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConsoleCommandPass` has been removed.
273+
Use `Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass` instead.
271274

272275
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\SerializerPass` class has been removed.
273276
Use the `Symfony\Component\Serializer\DependencyInjection\SerializerPass` class instead.

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
3.3.0
55
-----
66

7+
* Deprecated the `CompilerDebugDumpPass` class
78
* [BC BREAK] Removed the "framework.trusted_proxies" configuration option and the corresponding "kernel.trusted_proxies" parameter
89
* Added a new new version strategy option called json_manifest_path
910
that allows you to use the `JsonManifestVersionStrategy`.

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CompilerDebugDumpPass.php

+5
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

14+
@trigger_error(sprintf('The %s class is deprecated since version 3.3 and will be removed in 4.0.', CompilerDebugDumpPass::class), E_USER_DEPRECATED);
15+
1416
use Symfony\Component\DependencyInjection\ContainerInterface;
1517
use Symfony\Component\DependencyInjection\ContainerBuilder;
1618
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1719
use Symfony\Component\Filesystem\Exception\IOException;
1820
use Symfony\Component\Filesystem\Filesystem;
1921

22+
/**
23+
* @deprecated since version 3.3, to be removed in 4.0.
24+
*/
2025
class CompilerDebugDumpPass implements CompilerPassInterface
2126
{
2227
public function process(ContainerBuilder $container)

src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheClearerPass;
2626
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddExpressionLanguageProvidersPass;
2727
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass;
28-
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CompilerDebugDumpPass;
2928
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationExtractorPass;
3029
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationDumperPass;
3130
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\UnusedTagsPass;
@@ -115,7 +114,6 @@ public function build(ContainerBuilder $container)
115114
$container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32);
116115
$container->addCompilerPass(new UnusedTagsPass(), PassConfig::TYPE_AFTER_REMOVING);
117116
$container->addCompilerPass(new ContainerBuilderDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING);
118-
$container->addCompilerPass(new CompilerDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING, -32);
119117
$this->addCompilerPassIfExists($container, ConfigCachePass::class);
120118
$container->addCompilerPass(new CacheCollectorPass());
121119
}

src/Symfony/Component/HttpKernel/Kernel.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,13 @@ protected function initializeContainer()
515515
$fresh = true;
516516
if (!$cache->isFresh()) {
517517
$container = $this->buildContainer();
518-
$container->compile();
518+
try {
519+
$container->compile();
520+
} finally {
521+
if ($this->debug) {
522+
file_put_contents($this->getCacheDir().'/'.$class.'Compiler.log', implode("\n", $container->getCompiler()->getLog()));
523+
}
524+
}
519525
$this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());
520526

521527
$fresh = false;

0 commit comments

Comments
 (0)