Skip to content
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

[DependencyInjection] Added option ignore_errors: not_found for imported config files #31310

Merged
merged 1 commit into from
Nov 8, 2019

Conversation

pulzarraider
Copy link
Contributor

@pulzarraider pulzarraider commented Apr 28, 2019

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? yes
Tests pass? yes
Fixed tickets -
License MIT
Doc PR symfony/symfony-docs#11647

If someone want to add optional config file. The only available choice was to add ignore_errors: true option

e.g.

imports:
    - { resource: parameters.yml, ignore_errors: true }

But this will hide all errors in imported file. We ran in many situations that broke our Symfony applications because we had a typo in this imported files.

This PR introduce new possible value not_found for ignore_errors option. It can be used for optional config files like the ignore_errors: true, but it will ignore only the file non-existence, not the possible syntax errors inside.

Usage:

imports:
    - { resource: parameters.yml, ignore_errors: not_found}

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Hi, thanks for the PR, it looks like a good idea to me.
About the implementation, I made my review into a patch, see pulzarraider#1

@pulzarraider pulzarraider changed the title [Config] [DependencyInjection] [Routing] Added option ignore_not_found for imported config files WIP [Config] [DependencyInjection] [Routing] Added option ignore_not_found for imported config files Apr 30, 2019
@pulzarraider pulzarraider changed the title WIP [Config] [DependencyInjection] [Routing] Added option ignore_not_found for imported config files [WIP] [Config] [DependencyInjection] [Routing] Added option ignore_not_found for imported config files Apr 30, 2019
@pulzarraider pulzarraider force-pushed the config_ignore_not_found branch 6 times, most recently from c7916cf to 9c7fc7b Compare May 4, 2019 06:18
@pulzarraider pulzarraider force-pushed the config_ignore_not_found branch 3 times, most recently from 6632ba8 to 8ecb133 Compare June 3, 2019 02:01
@pulzarraider pulzarraider changed the base branch from master to 4.4 June 3, 2019 02:06
@pulzarraider pulzarraider changed the base branch from 4.4 to master June 3, 2019 02:06
@pulzarraider pulzarraider changed the title [WIP] [Config] [DependencyInjection] [Routing] Added option ignore_not_found for imported config files [Config] [DependencyInjection] [Routing] Added option ignore_not_found for imported config files Jun 3, 2019
@pulzarraider
Copy link
Contributor Author

Thank you @nicolas-grekas, I've merged your MR and did some more small improvements.

@OskarStark
Copy link
Contributor

@pulzarraider If I am correct, this must now go into 4.4 branch, could you please switch the target branch for this PR?

I already did this for the corresponding Docs-PR symfony/symfony-docs#11647

@pulzarraider pulzarraider changed the base branch from master to 4.4 September 27, 2019 21:02
@pulzarraider pulzarraider force-pushed the config_ignore_not_found branch 5 times, most recently from dee7d76 to cddf68c Compare September 28, 2019 20:13
@pulzarraider
Copy link
Contributor Author

I think this feature is finished. @nicolas-grekas @stof @sstok please review it again.
I hope it will be added in sf 4.4.

@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
@nicolas-grekas nicolas-grekas changed the title [Config] [DependencyInjection] [Routing] Added option ignore_not_found for imported config files [DependencyInjection] Added option ignore_errors: not_found for imported config files Nov 7, 2019
@nicolas-grekas nicolas-grekas force-pushed the config_ignore_not_found branch 3 times, most recently from 18c039e to 419a9b5 Compare November 7, 2019 10:58
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

I've rebased the PR and changed the logic to make it local to the DI component only.

(fabbot failure is unrelated - patch to be applied globally starting from 3.4)

@pulzarraider
Copy link
Contributor Author

Thank you @nicolas-grekas for your changes.

@nicolas-grekas
Copy link
Member

Thank you @pulzarraider.

nicolas-grekas added a commit that referenced this pull request Nov 8, 2019
…_found` for imported config files (pulzarraider)

This PR was merged into the 4.4 branch.

Discussion
----------

[DependencyInjection] Added option `ignore_errors: not_found` for imported config files

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | yes
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | symfony/symfony-docs#11647

If someone want to add optional config file. The only available choice was to add `ignore_errors: true` option

e.g.
```
imports:
    - { resource: parameters.yml, ignore_errors: true }
```

But this will hide all errors in imported file. We ran in many situations that broke our Symfony applications because we had a typo in this imported files.

This PR introduce new possible value `not_found` for `ignore_errors` option. It can be used for optional config files like the `ignore_errors: true`, but it will ignore only the file non-existence, not the possible syntax errors inside.

Usage:
```
imports:
    - { resource: parameters.yml, ignore_errors: not_found}
```

Commits
-------

e0ee01c [DependencyInjection] Added option `ignore_errors: not_found` while importing config files
@nicolas-grekas nicolas-grekas merged commit e0ee01c into symfony:4.4 Nov 8, 2019
@pulzarraider pulzarraider deleted the config_ignore_not_found branch November 8, 2019 10:59
This was referenced Nov 12, 2019
wouterj added a commit to symfony/symfony-docs that referenced this pull request Oct 4, 2020
…_found` for imported config files (pulzarraider)

This PR was merged into the 4.4 branch.

Discussion
----------

[DependencyInjection] Added option `ignore_errors: not_found` for imported config files

<!--

If your pull request fixes a BUG, use the oldest maintained branch that contains
the bug (see https://symfony.com/roadmap for the list of maintained branches).

If your pull request documents a NEW FEATURE, use the same Symfony branch where
the feature was introduced (and `master` for features of unreleased versions).

-->
Related merge request: symfony/symfony#31310

Commits
-------

0a6873d [Configuration] Add documentation about `ignore_errors: not_found` option.
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.

None yet

7 participants