8000 Keep existing behaviour when loading a config and the glob doesn't match · symfony/symfony@1c86fb4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1c86fb4

Browse files
committed
Keep existing behaviour when loading a config and the glob doesn't match
1 parent 429163f commit 1c86fb4

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

src/Symfony/Component/Config/FileLocator.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,15 @@ public function locate($name, $currentPath = null, $first = true)
4242
}
4343

4444
if ($this->isAbsolutePath($name)) {
45-
if (array() === $files = glob($name, GLOB_BRACE)) {
45+
if (file_exists($name)) {
46+
return $name;
47+
}
48+
49+
if (array() === $files = glob($name, defined('GLOB_BRACE') ? GLOB_BRACE : 0)) {
4650
throw new FileLocatorFileNotFoundException(sprintf('The file "%s" does not exist.', $name));
4751
}
4852

49-
if ($first) {
53+
if (true === $first) {
5054
return array_shift($files);
5155
}
5256

@@ -62,18 +66,8 @@ public function locate($name, $currentPath = null, $first = true)
6266
$paths = array_unique($paths);
6367
$filepaths = array();
6468

65-
$load = function ($file) use (&$filepaths) {
66-
if (@file_exists($file)) {
67-
$filepaths[] = $file;
68-
}
69-
};
70-
7169
foreach ($paths as $path) {
72-
if (array() !== $files = glob($path.DIRECTORY_SEPARATOR.$name)) {
73-
array_walk($files, $load);
74-
} else {
75-
$load($path.DIRECTORY_SEPARATOR.$name);
76-
}
70+
$filepaths = array_merge($filepaths, glob($path.DIRECTORY_SEPARATOR.$name, defined('GLOB_BRACE') ? GLOB_BRACE : 0));
7771
}
7872

7973
if (!$filepaths) {

src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,12 @@ private function parseImports(\DOMDocument $xml, $file)
112112
$resourceFile = $defaultDirectory.DIRECTORY_SEPARATOR.$resourceFile;
113113
}
114114

115-
$files = glob($resourceFile, GLOB_BRACE);
116-
117-
foreach ($files as $resource) {
118-
$this->import($resource, XmlUtils::phpize($import->getAttribute('type')) ?: null, (bool) XmlUtils::phpize($import->getAttribute('ignore-errors')), $file);
115+
if (array() !== $files = glob($resourceFile, defined('GLOB_BRACE') ? GLOB_BRACE : 0)) {
116+
foreach ($files as $resource) {
117+
$this->import($resource, XmlUtils::phpize($import->getAttribute('type')) ?: null, (bool) XmlUtils::phpize($import->getAttribute('ignore-errors')), $file);
118+
}
119+
} else {
120+
$this->import($resourceFile, XmlUtils::phpize($import->getAttribute('type')) ?: null, (bool) XmlUtils::phpize($import->getAttribute('ignore-errors')), $file);
119121
}
120122
}
121123
}

src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,12 @@ private function parseImports($content, $file)
143143
$import['resource'] = $defaultDirectory.DIRECTORY_SEPARATOR.$import['resource'];
144144
}
145145

146-
$files = glob($import['resource'], GLOB_BRACE);
147-
148-
foreach ($files as $resource) {
149-
$this->import($resource, isset($import['type']) ? $import['type'] : null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false, $file);
146+
if (array() !== $files = glob($import['resource'], defined('GLOB_BRACE') ? GLOB_BRACE : 0)) {
147+
foreach ($files as $resource) {
148+
$this->import($resource, isset($import['type']) ? $import['type'] : null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false, $file);
149+
}
150+
} else {
151+
$this->import($import['resource'], isset($import['type']) ? $import['type'] : null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false, $file);
150152
}
151153
}
152154
}

0 commit comments

Comments
 (0)
0