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
This commit is contained in:
commit
a1c95f79d6
@ -158,12 +158,13 @@ class Filesystem
|
|||||||
$files = iterator_to_array($this->toIterator($files));
|
$files = iterator_to_array($this->toIterator($files));
|
||||||
$files = array_reverse($files);
|
$files = array_reverse($files);
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
|
if (@(unlink($file) || rmdir($file))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (is_link($file)) {
|
if (is_link($file)) {
|
||||||
// Workaround https://bugs.php.net/52176
|
// See https://bugs.php.net/52176
|
||||||
if (!@unlink($file) && !@rmdir($file)) {
|
|
||||||
$error = error_get_last();
|
$error = error_get_last();
|
||||||
throw new IOException(sprintf('Failed to remove symlink "%s": %s.', $file, $error['message']));
|
throw new IOException(sprintf('Failed to remove symlink "%s": %s.', $file, $error['message']));
|
||||||
}
|
|
||||||
} elseif (is_dir($file)) {
|
} elseif (is_dir($file)) {
|
||||||
$this->remove(new \FilesystemIterator($file));
|
$this->remove(new \FilesystemIterator($file));
|
||||||
|
|
||||||
@ -171,14 +172,12 @@ class Filesystem
|
|||||||
$error = error_get_last();
|
$error = error_get_last();
|
||||||
throw new IOException(sprintf('Failed to remove directory "%s": %s.', $file, $error['message']));
|
throw new IOException(sprintf('Failed to remove directory "%s": %s.', $file, $error['message']));
|
||||||
}
|
}
|
||||||
} elseif ($this->exists($file)) {
|
} elseif (file_exists($file)) {
|
||||||
if (!@unlink($file)) {
|
|
||||||
$error = error_get_last();
|
$error = error_get_last();
|
||||||
throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, $error['message']));
|
throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, $error['message']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change mode for an array of files or directories.
|
* Change mode for an array of files or directories.
|
||||||
@ -435,7 +434,7 @@ class Filesystem
|
|||||||
$target = str_replace($originDir, $targetDir, $file->getPathname());
|
$target = str_replace($originDir, $targetDir, $file->getPathname());
|
||||||
|
|
||||||
if ($copyOnWindows) {
|
if ($copyOnWindows) {
|
||||||
if (is_link($file) || is_file($file)) {
|
if (is_file($file)) {
|
||||||
$this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
|
$this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
|
||||||
} elseif (is_dir($file)) {
|
} elseif (is_dir($file)) {
|
||||||
$this->mkdir($target);
|
$this->mkdir($target);
|
||||||
|
@ -744,6 +744,8 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
$this->filesystem->remove($link);
|
$this->filesystem->remove($link);
|
||||||
|
|
||||||
$this->assertTrue(!is_link($link));
|
$this->assertTrue(!is_link($link));
|
||||||
|
$this->assertTrue(!is_file($link));
|
||||||
|
$this->assertTrue(!is_dir($link));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSymlinkIsOverwrittenIfPointsToDifferentTarget()
|
public function testSymlinkIsOverwrittenIfPointsToDifferentTarget()
|
||||||
@ -917,7 +919,7 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
$this->filesystem->mirror($sourcePath, $targetPath);
|
$this->filesystem->mirror($sourcePath, $targetPath);
|
||||||
|
|
||||||
$this->assertTrue(is_dir($targetPath));
|
$this->assertTrue(is_dir($targetPath));
|
||||||
$this->assertFileEquals($sourcePath.'file1', $targetPath.DIRECTORY_SEPARATOR.'link1');
|
$this->assertFileEquals($sourcePath.'file1', $targetPath.'link1');
|
||||||
$this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1'));
|
$this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -937,7 +939,7 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
$this->filesystem->mirror($sourcePath, $targetPath);
|
$this->filesystem->mirror($sourcePath, $targetPath);
|
||||||
|
|
||||||
$this->assertTrue(is_dir($targetPath));
|
$this->assertTrue(is_dir($targetPath));
|
||||||
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.DIRECTORY_SEPARATOR.'link1/file1.txt');
|
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.'link1/file1.txt');
|
||||||
$this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1'));
|
$this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -961,7 +963,7 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
$this->filesystem->mirror($sourcePath, $targetPath);
|
$this->filesystem->mirror($sourcePath, $targetPath);
|
||||||
|
|
||||||
$this->assertTrue(is_dir($targetPath));
|
$this->assertTrue(is_dir($targetPath));
|
||||||
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.DIRECTORY_SEPARATOR.'link1/file1.txt');
|
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.'link1/file1.txt');
|
||||||
$this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1'));
|
$this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1'));
|
||||||
$this->assertEquals('\\' === DIRECTORY_SEPARATOR ? realpath($sourcePath.'\nested') : 'nested', readlink($targetPath.DIRECTORY_SEPARATOR.'link1'));
|
$this->assertEquals('\\' === DIRECTORY_SEPARATOR ? realpath($sourcePath.'\nested') : 'nested', readlink($targetPath.DIRECTORY_SEPARATOR.'link1'));
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,8 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
|
|||||||
if ('\\' === DIRECTORY_SEPARATOR && null === self::$symlinkOnWindows) {
|
if ('\\' === DIRECTORY_SEPARATOR && null === self::$symlinkOnWindows) {
|
||||||
$target = tempnam(sys_get_temp_dir(), 'sl');
|
$target = tempnam(sys_get_temp_dir(), 'sl');
|
||||||
$link = sys_get_temp_dir().'/sl'.microtime(true).mt_rand();
|
$link = sys_get_temp_dir().'/sl'.microtime(true).mt_rand();
|
||||||
if (self::$symlinkOnWindows = @symlink($target, $link)) {
|
self::$symlinkOnWindows = @symlink($target, $link) && is_link($link);
|
||||||
unlink($link);
|
@unlink($link);
|
||||||
}
|
|
||||||
unlink($target);
|
unlink($target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,9 @@ class LocaleValidator extends ConstraintValidator
|
|||||||
|
|
||||||
$value = (string) $value;
|
$value = (string) $value;
|
||||||
$locales = Intl::getLocaleBundle()->getLocaleNames();
|
$locales = Intl::getLocaleBundle()->getLocaleNames();
|
||||||
|
$aliases = Intl::getLocaleBundle()->getAliases();
|
||||||
|
|
||||||
if (!isset($locales[$value])) {
|
if (!isset($locales[$value]) && !in_array($value, $aliases)) {
|
||||||
if ($this->context instanceof ExecutionContextInterface) {
|
if ($this->context instanceof ExecutionContextInterface) {
|
||||||
$this->context->buildViolation($constraint->message)
|
$this->context->buildViolation($constraint->message)
|
||||||
->setParameter('{{ value }}', $this->formatValue($value))
|
->setParameter('{{ value }}', $this->formatValue($value))
|
||||||
|
@ -67,6 +67,7 @@ class LocaleValidatorTest extends AbstractConstraintValidatorTest
|
|||||||
array('pt'),
|
array('pt'),
|
||||||
array('pt_PT'),
|
array('pt_PT'),
|
||||||
array('zh_Hans'),
|
array('zh_Hans'),
|
||||||
|
array('fil_PH'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
"require-dev": {
|
"require-dev": {
|
||||||
"doctrine/common": "~2.3",
|
"doctrine/common": "~2.3",
|
||||||
"symfony/http-foundation": "~2.1",
|
"symfony/http-foundation": "~2.1",
|
||||||
"symfony/intl": "~2.4",
|
"symfony/intl": "~2.7.4",
|
||||||
"symfony/yaml": "~2.0,>=2.0.5",
|
"symfony/yaml": "~2.0,>=2.0.5",
|
||||||
"symfony/config": "~2.2",
|
"symfony/config": "~2.2",
|
||||||
"symfony/property-access": "~2.3",
|
"symfony/property-access": "~2.3",
|
||||||
|
Reference in New Issue
Block a user