8000 Merge branch '2.3' into 2.7 · symfony/symfony@a1c95f7 · GitHub
[go: up one dir, main page]

Skip to content

Commit a1c95f7

Browse files
Merge branch '2.3' into 2.7
* 2.3: [Filesystem] Fix false positive in ->remove() [Validator] Fix the locale validator so it treats a locale alias as a valid locale Conflicts: src/Symfony/Component/Filesystem/Tests/FilesystemTest.php src/Symfony/Component/Validator/Constraints/LocaleValidator.php src/Symfony/Component/Validator/composer.json
2 parents 9d22b24 + 1bbcff0 commit a1c95f7

File tree

6 files changed

+21
-19
lines changed

6 files changed

+21
-19
lines changed

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,24 +158,23 @@ public function remove($files)
158158
$files = iterator_to_array($this->toIterator($files));
159159
$files = array_reverse($files);
160160
foreach ($files as $file) {
161+
if (@(unlink($file) || rmdir($file))) {
162+
continue;
163+
}
161164
if (is_link($file)) {
162-
// Workaround https://bugs.php.net/52176
163-
if (!@unlink($file) && !@rmdir($file)) {
164-
$error = error_get_last();
165-
throw new IOException(sprintf('Failed to remove symlink "%s": %s.', $file, $error['message']));
166-
}
165+
// See https://bugs.php.net/52176
166+
$error = error_get_last();
167+
throw new IOException(sprintf('Failed to remove symlink "%s": %s.', $file, $error['message']));
167168
} elseif (is_dir($file)) {
168169
$this->remove(new \FilesystemIterator($file));
169170

170171
if (!@rmdir($file)) {
171172
$error = error_get_last();
172173
throw new IOException(sprintf('Failed to remove directory "%s": %s.', $file, $error['message']));
173174
}
174-
} elseif ($this->exists($file)) {
175-
if (!@unlink($file)) {
176-
$error = error_get_last();
177-
throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, $error['message']));
178-
}
175+
} elseif (file_exists($file)) {
176+
$error = error_get_last();
177+
throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, $er 10000 ror['message']));
179178
}
180179
}
181180
}
@@ -435,7 +434,7 @@ public function mirror($originDir, $targetDir, \Traversable $iterator = null, $o
435434
$target = str_replace($originDir, $targetDir, $file->getPathname());
436435

437436
if ($copyOnWindows) {
438-
if (is_link($file) || is_file($file)) {
437+
if (is_file($file)) {
439438
$this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
440439
} elseif (is_dir($file)) {
441440
$this->mkdir($target);

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,8 @@ public function testRemoveSymlink()
744744
$this->filesystem->remove($link);
745745

746746
$this->assertTrue(!is_link($link));
747+
$this->assertTrue(!is_file($link));
748+
$this->assertTrue(!is_dir($link));
747749
}
748750

749751
public function testSymlinkIsOverwrittenIfPointsToDifferentTarget()
@@ -917,7 +919,7 @@ public function testMirrorCopiesLinks()
917919
$this->filesystem->mirror($sourcePath, $targetPath);
918920

919921
$this->assertTrue(is_dir($targetPath));
920-
$this->assertFileEquals($sourcePath.'file1', $targetPath.DIRECTORY_SEPARATOR.'link1');
922+
$this->assertFileEquals($sourcePath.'file1', $targetPath.'link1');
921923
$this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1'));
922924
}
923925

@@ -937,7 +939,7 @@ public function testMirrorCopiesLinkedDirectoryContents()
937939
$this->filesystem->mirror 57AE ($sourcePath, $targetPath);
938940

939941
$this->assertTrue(is_dir($targetPath));
940-
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.DIRECTORY_SEPARATOR.'link1/file1.txt');
942+
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.'link1/file1.txt');
941943
$this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1'));
942944
}
943945

@@ -961,7 +963,7 @@ public function testMirrorCopiesRelativeLinkedContents()
961963
$this->filesystem->mirror($sourcePath, $targetPath);
962964

963965
$this->assertTrue(is_dir($targetPath));
964-
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.DIRECTORY_SEPARATOR.'link1/file1.txt');
966+
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.'link1/file1.txt');
965967
$this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1'));
966968
$this->assertEquals('\\' === DIRECTORY_SEPARATOR ? realpath($sourcePath.'\nested') : 'nested', readlink($targetPath.DIRECTORY_SEPARATOR.'link1'));
967969
}

src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ public static function setUpBeforeClass()
3636
if ('\\' === DIRECTORY_SEPARATOR && null === self::$symlinkOnWindows) {
3737
$target = tempnam(sys_get_temp_dir(), 'sl');
3838
$link = sys_get_temp_dir().'/sl'.microtime(true).mt_rand();
39-
if (self::$symlinkOnWindows = @symlink($target, $link)) {
40-
unlink($link);
41-
}
39+
self::$symlinkOnWindows = @symlink($target, $link) && is_link($link);
40+
@unlink($link);
4241
unlink($target);
4342
}
4443
}

src/Symfony/Component/Validator/Constraints/LocaleValidator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ public function validate($value, Constraint $constraint)
4343

4444
$value = (string) $value;
4545
$locales = Intl::getLocaleBundle()->getLocaleNames();
46+
$aliases = Intl::getLocaleBundle()->getAliases();
4647

47-
if (!isset($locales[$value])) {
48+
if (!isset($locales[$value]) && !in_array($value, $aliases)) {
4849
if ($this->context instanceof ExecutionContextInterface) {
4950
$this->context->buildViolation($constraint->message)
5051
->setParameter('{{ value }}', $this->formatValue($value))

src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public function getValidLocales()
6767
array('pt'),
6868
array('pt_PT'),
6969
array('zh_Hans'),
70+
array('fil_PH'),
7071
);
7172
}
7273

src/Symfony/Component/Validator/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"require-dev": {
2323
"doctrine/common": "~2.3",
2424
"symfony/http-foundation": "~2.1",
25-
"symfony/intl": "~2.4",
25+
"symfony/intl": "~2.7.4",
2626
"symfony/yaml": "~2.0,>=2.0.5",
2727
"symfony/config": "~2.2",
2828
"symfony/property-access": "~2.3",

0 commit comments

Comments
 (0)
0