Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DI] Fix fatal error at ContainerBuilder::compile() if config is not installed #22240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2017

Conversation

chalasr
Copy link
Member

@chalasr chalasr commented Apr 2, 2017

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:

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

{
parent::__construct($parameterBag);

$this->trackResources = interface_exists('Symfony\Component\Config\Resource\ResourceInterface');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be simply interface_exists(ResourceInterface::class);? The class is already imported anyway

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This targets 2.7 which supports PHP 5.3+ :/

@nicolas-grekas nicolas-grekas added this to the 2.7 milestone Apr 3, 2017
@nicolas-grekas
Copy link
Member

Thank you @chalasr.

@nicolas-grekas nicolas-grekas merged commit 75d5cb1 into symfony:2.7 Apr 3, 2017
nicolas-grekas added a commit that referenced this pull request Apr 3, 2017
…fig 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
@chalasr chalasr deleted the tracking-disabled-if-no-config branch April 3, 2017 07:58
This was referenced Apr 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants