This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/DependencyInjection/Tests
Fabien Potencier c927c481aa bug #25255 [Console][DI] Fail gracefully (nicolas-grekas)
This PR was merged into the 3.4 branch.

Discussion
----------

[Console][DI] Fail gracefully

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | https://github.com/symfony/flex/issues/212, #25280
| License       | MIT
| Doc PR        | -

I already experienced this issue a few times without spending time digging it:
sometimes, you call `cache:clear`, and the command quits without any output, and with 255 status code.

The reason is the `@include` in `Kernel`, which makes everything silent, especially fatal errors (thanks PHP...)
So if the to-be-removed container is broken for some fatal reason, the failure is really bad.

To fix that, here are two measures:
- use `include_once` instead of `require_once` in the dumped container: that's OK there to actually not immediately load the file, any hard failure will happen later anyway, and any soft failure will allow the `cache:clear` command to complete (like when you remove a package)
- register `Application::renderException()` as the main PHP exception handler, via `Debug::ErrorHandler` when it's available

End result when it fails:
![image](https://user-images.githubusercontent.com/243674/33494543-e1d07202-d6c3-11e7-9677-bc2ae72fbba9.png)

instead of a blank output.

Commits
-------

4a5a3f52ab [Console][DI] Fail gracefully
2017-12-02 15:04:03 -08:00
..
Argument [DI] Introduce "container.service_locator" tag, replaces ServiceLocatorArgument 2017-03-17 17:49:32 +01:00
Compiler Merge branch '3.3' into 3.4 2017-11-29 14:28:14 +01:00
Config [DI][Router][DX] Invalidate routing cache when container parameters changed 2017-03-05 20:24:24 +01:00
Dumper [DI] Fix false-positive circular exception 2017-12-01 14:16:38 +01:00
Extension Update to PHPUnit namespaces 2017-02-18 08:02:39 -08:00
Fixtures bug #25255 [Console][DI] Fail gracefully (nicolas-grekas) 2017-12-02 15:04:03 -08:00
LazyProxy [DI][ProxyManager] Pass the factory code to execute to DumperInterface::getProxyFactoryCode() 2017-07-27 19:12:50 +02:00
Loader Throw on service:method factory notation in PHP-based DI configuration 2017-11-17 12:52:23 +03:00
ParameterBag [DI] Case sensitive parameter names 2017-08-14 17:16:04 +02:00
ChildDefinitionTest.php [DependencyInjection] Fix named args support in ChildDefinition 2017-06-05 09:24:55 -07:00
ContainerBuilderTest.php bug #25244 [DI] Add missing deprecation when fetching private services from ContainerBuilder (nicolas-grekas) 2017-12-01 09:40:17 -08:00
ContainerTest.php [DI] Throw accurate failures when accessing removed services 2017-10-07 23:38:34 +02:00
CrossCheckTest.php Merge branch '3.2' 2017-02-18 18:35:19 +01:00
DefinitionDecoratorTest.php [DI] Replace wildcard-based methods autowiring by @required annotation 2017-02-28 10:00:46 +01:00
DefinitionTest.php Adding Definition::addError() and a compiler pass to throw errors as exceptions 2017-09-25 11:28:57 +02:00
ParameterTest.php Update to PHPUnit namespaces 2017-02-18 08:02:39 -08:00
ReferenceTest.php Merge branch '3.2' 2017-02-18 18:35:19 +01:00
ServiceLocatorTest.php Allow to get alternatives when ServiceNotFoundException occurs. 2017-08-17 15:22:42 +03:00