Skip to content

Commit

Permalink
bug #36041 fix import from config file using type: glob (Tobion)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.4 branch.

Discussion
----------

fix import from config file using type: glob

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       |
| License       | MIT
| Doc PR        |

If you try to import configs with glob using
```
imports:
    - { resource: '../dev/*.{php,xml,yaml,yml}', type: 'glob' }
```
it didn't work because the FileLoader resolves the glob pattern but forwards the glob type. This meant the resolver then choses the GlobFilerLoader again for each already resolved file which does not find the files. So in the end the glob was resolved but the files never imported.
The workaround is to remove the `type: glob` from the import above. But the real fix should be to not forward the glob type when it's already resolved.

Commits
-------

6b70511 fix import from config file using type: glob
  • Loading branch information
nicolas-grekas committed Mar 13, 2020
2 parents f020876 + 6b70511 commit 148b13c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Config/Loader/FileLoader.php
Expand Up @@ -76,7 +76,7 @@ public function import($resource, $type = null, $ignoreErrors = false, $sourceRe
$ret = [];
$isSubpath = 0 !== $i && false !== strpos(substr($resource, 0, $i), '/');
foreach ($this->glob($resource, false, $_, $ignoreErrors || !$isSubpath) as $path => $info) {
if (null !== $res = $this->doImport($path, $type, $ignoreErrors, $sourceResource)) {
if (null !== $res = $this->doImport($path, 'glob' === $type ? null : $type, $ignoreErrors, $sourceResource)) {
$ret[] = $res;
}
$isSubpath = true;
Expand Down

0 comments on commit 148b13c

Please sign in to comment.