Skip to content

Commit

Permalink
feature #22314 [HttpKernel][FrameworkBundle] Dump container logs in K…
Browse files Browse the repository at this point in the history
…ernel, 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
  • Loading branch information
fabpot committed Apr 7, 2017
2 parents abb8d2b + a8b8334 commit 3f07e10
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
4 changes: 3 additions & 1 deletion UPGRADE-3.3.md
Expand Up @@ -168,8 +168,10 @@ FrameworkBundle

* 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.

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

* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConsoleCommandPass` has been deprecated. Use `Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass` instead.
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConsoleCommandPass` has been deprecated.
Use `Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass` instead.

* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\SerializerPass` class has been
deprecated and will be removed in 4.0.
Expand Down
5 changes: 4 additions & 1 deletion UPGRADE-4.0.md
Expand Up @@ -267,7 +267,10 @@ FrameworkBundle
`serializer.mapping.cache.apc` and `serializer.mapping.cache.doctrine.apc`
have been removed. APCu should now be automatically used when available.

* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConsoleCommandPass` has been removed. Use `Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass` instead.
* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CompilerDebugDumpPass` has been removed.

* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddConsoleCommandPass` has been removed.
Use `Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass` instead.

* The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\SerializerPass` class has been removed.
Use the `Symfony\Component\Serializer\DependencyInjection\SerializerPass` class instead.
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Expand Up @@ -4,6 +4,7 @@ CHANGELOG
3.3.0
-----

* Deprecated the `CompilerDebugDumpPass` class
* [BC BREAK] Removed the "framework.trusted_proxies" configuration option and the corresponding "kernel.trusted_proxies" parameter
* Added a new new version strategy option called json_manifest_path
that allows you to use the `JsonManifestVersionStrategy`.
Expand Down
Expand Up @@ -11,12 +11,17 @@

namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;

@trigger_error(sprintf('The %s class is deprecated since version 3.3 and will be removed in 4.0.', CompilerDebugDumpPass::class), E_USER_DEPRECATED);

use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Filesystem;

/**
* @deprecated since version 3.3, to be removed in 4.0.
*/
class CompilerDebugDumpPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
Expand Down
2 changes: 0 additions & 2 deletions src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
Expand Up @@ -25,7 +25,6 @@
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddCacheClearerPass;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddExpressionLanguageProvidersPass;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ContainerBuilderDebugDumpPass;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CompilerDebugDumpPass;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationExtractorPass;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslationDumperPass;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\UnusedTagsPass;
Expand Down Expand Up @@ -115,7 +114,6 @@ public function build(ContainerBuilder $container)
$container->addCompilerPass(new AddDebugLogProcessorPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -32);
$container->addCompilerPass(new UnusedTagsPass(), PassConfig::TYPE_AFTER_REMOVING);
$container->addCompilerPass(new ContainerBuilderDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING);
$container->addCompilerPass(new CompilerDebugDumpPass(), PassConfig::TYPE_AFTER_REMOVING, -32);
$this->addCompilerPassIfExists($container, ConfigCachePass::class);
$container->addCompilerPass(new CacheCollectorPass());
}
Expand Down
8 changes: 7 additions & 1 deletion src/Symfony/Component/HttpKernel/Kernel.php
Expand Up @@ -515,7 +515,13 @@ protected function initializeContainer()
$fresh = true;
if (!$cache->isFresh()) {
$container = $this->buildContainer();
$container->compile();
try {
$container->compile();
} finally {
if ($this->debug) {
file_put_contents($this->getCacheDir().'/'.$class.'Compiler.log', implode("\n", $container->getCompiler()->getLog()));
}
}
$this->dumpContainer($cache, $container, $class, $this->getContainerBaseClass());

$fresh = false;
Expand Down

0 comments on commit 3f07e10

Please sign in to comment.