Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c7163e2

Browse filesBrowse files
bug #22240 [DI] Fix fatal error at ContainerBuilder::compile() if config is not installed (chalasr)
This PR was merged into the 2.7 branch. Discussion ---------- [DI] Fix fatal error at ContainerBuilder::compile() if config is not installed | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Using the DI component independently, running the following code: ```php (new ContainerBuilder())->compile(); ``` gives > Fatal error: Uncaught Error: Class 'Symfony\Component\Config\Resource\FileResource' not found Considering that using the container without ever compiling it doesn't really make sense, I think this currently makes the config component an hard requirement. I propose to make it softer as a bug fix, enabling resource tracking by default only if the config component is installed. Commits ------- 75d5cb1 Disable resource tracking if the config component is missing
2 parents 6008489 + 75d5cb1 commit c7163e2
Copy full SHA for c7163e2

File tree

1 file changed

+9
-1
lines changed
Filter options

1 file changed

+9
-1
lines changed

‎src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/ContainerBuilder.php
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use Symfony\Component\Config\Resource\ResourceInterface;
2727
use Symfony\Component\DependencyInjection\LazyProxy\Instantiator\InstantiatorInterface;
2828
use Symfony\Component\DependencyInjection\LazyProxy\Instantiator\RealServiceInstantiator;
29+
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
2930
use Symfony\Component\ExpressionLanguage\Expression;
3031
use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
3132

@@ -73,7 +74,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
7374
*/
7475
private $compiler;
7576

76-
private $trackResources = true;
77+
private $trackResources;
7778

7879
/**
7980
* @var InstantiatorInterface|null
@@ -90,6 +91,13 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
9091
*/
9192
private $expressionLanguageProviders = array();
9293

94+
public function __construct(ParameterBagInterface $parameterBag = null)
95+
{
96+
parent::__construct($parameterBag);
97+
98+
$this->trackResources = interface_exists('Symfony\Component\Config\Resource\ResourceInterface');
99+
}
100+
93101
/**
94102
* Sets the track resources flag.
95103
*

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.