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 80bd975

Browse filesBrowse files
committed
Keep existing behaviour when loading a config and the glob doesn't match
Keep existing load behavior with absolute paths
1 parent 429163f commit 80bd975
Copy full SHA for 80bd975

File tree

3 files changed

+19
-21
lines changed
Filter options

3 files changed

+19
-21
lines changed

‎src/Symfony/Component/Config/FileLocator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/FileLocator.php
+7-13Lines 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(glob($path.DIRECTORY_SEPARATOR.$name, defined('GLOB_BRACE') ? GLOB_BRACE : 0), $filepaths);
7771
}
7872

7973
if (!$filepaths) {

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
+6-4Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
+6-4Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.