Navigation Menu

Skip to content

Commit

Permalink
bug #23168 [Config] Fix ** GlobResource on Windows (nicolas-grekas)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.3 branch.

Discussion
----------

[Config] Fix ** GlobResource on Windows

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #23103
| License       | MIT
| Doc PR        | -

We cannot tell Finder to use RecursiveDirectoryIterator::UNIX_PATHS so we have to fix paths on Windows.

Commits
-------

44955be [Config] Fix ** GlobResource on Windows
  • Loading branch information
fabpot committed Jun 14, 2017
2 parents a63400a + 44955be commit 3278915
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Config/Resource/GlobResource.php
Expand Up @@ -134,7 +134,7 @@ function (\SplFileInfo $file) { return '.' !== $file->getBasename()[0]; }

$prefixLen = strlen($this->prefix);
foreach ($finder->followLinks()->sortByName()->in($this->prefix) as $path => $info) {
if (preg_match($regex, substr($path, $prefixLen)) && $info->isFile()) {
if (preg_match($regex, substr('\\' === \DIRECTORY_SEPARATOR ? str_replace('\\', '/', $path) : $path, $prefixLen)) && $info->isFile()) {
yield $path => $info;
}
}
Expand Down
Expand Up @@ -36,6 +36,15 @@ public function testIterator()
$this->assertEquals(array($file => new \SplFileInfo($file)), $paths);
$this->assertInstanceOf('SplFileInfo', current($paths));
$this->assertSame($dir, $resource->getPrefix());

$resource = new GlobResource($dir, '/**/Resource', true);

$paths = iterator_to_array($resource);

$file = $dir.DIRECTORY_SEPARATOR.'Resource'.DIRECTORY_SEPARATOR.'ConditionalClass.php';
$this->assertEquals(array($file => $file), $paths);
$this->assertInstanceOf('SplFileInfo', current($paths));
$this->assertSame($dir, $resource->getPrefix());
}

public function testIsFreshNonRecursiveDetectsNewFile()
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Config/composer.json
Expand Up @@ -20,10 +20,12 @@
"symfony/filesystem": "~2.8|~3.0"
},
"require-dev": {
"symfony/finder": "~3.3",
"symfony/yaml": "~3.0",
"symfony/dependency-injection": "~3.3"
},
"conflict": {
"symfony/finder": "<3.3",
"symfony/dependency-injection": "<3.3"
},
"suggest": {
Expand Down

0 comments on commit 3278915

Please sign in to comment.