Update v1.0.6.5
This commit is contained in:
24
vendor/symfony/filesystem/Filesystem.php
vendored
24
vendor/symfony/filesystem/Filesystem.php
vendored
@@ -115,6 +115,10 @@ class Filesystem
|
||||
public function exists($files)
|
||||
{
|
||||
foreach ($this->toIterator($files) as $file) {
|
||||
if ('\\' === DIRECTORY_SEPARATOR && strlen($file) > 258) {
|
||||
throw new IOException('Could not check if file exist because path length exceeds 258 characters.', 0, null, $file);
|
||||
}
|
||||
|
||||
if (!file_exists($file)) {
|
||||
return false;
|
||||
}
|
||||
@@ -154,7 +158,7 @@ class Filesystem
|
||||
$files = iterator_to_array($this->toIterator($files));
|
||||
$files = array_reverse($files);
|
||||
foreach ($files as $file) {
|
||||
if (!file_exists($file) && !is_link($file)) {
|
||||
if (!$this->exists($file) && !is_link($file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -268,7 +272,7 @@ class Filesystem
|
||||
public function rename($origin, $target, $overwrite = false)
|
||||
{
|
||||
// we check that target does not exist
|
||||
if (!$overwrite && is_readable($target)) {
|
||||
if (!$overwrite && $this->isReadable($target)) {
|
||||
throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target);
|
||||
}
|
||||
|
||||
@@ -277,6 +281,22 @@ class Filesystem
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether a file exists and is readable.
|
||||
*
|
||||
* @param string $filename Path to the file.
|
||||
*
|
||||
* @throws IOException When windows path is longer than 258 characters
|
||||
*/
|
||||
private function isReadable($filename)
|
||||
{
|
||||
if ('\\' === DIRECTORY_SEPARATOR && strlen($filename) > 258) {
|
||||
throw new IOException('Could not check if file is readable because path length exceeds 258 characters.', 0, null, $filename);
|
||||
}
|
||||
|
||||
return is_readable($filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a symbolic link or copy a directory.
|
||||
*
|
||||
|
2
vendor/symfony/filesystem/LockHandler.php
vendored
2
vendor/symfony/filesystem/LockHandler.php
vendored
@@ -69,7 +69,7 @@ class LockHandler
|
||||
}
|
||||
|
||||
// Silence error reporting
|
||||
set_error_handler(function() {});
|
||||
set_error_handler(function () {});
|
||||
|
||||
if (!$this->handle = fopen($this->file, 'r')) {
|
||||
if ($this->handle = fopen($this->file, 'x')) {
|
||||
|
@@ -358,6 +358,28 @@ class FilesystemTest extends FilesystemTestCase
|
||||
$this->assertTrue($this->filesystem->exists($basePath.'folder'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Filesystem\Exception\IOException
|
||||
*/
|
||||
public function testFilesExistsFails()
|
||||
{
|
||||
if ('\\' !== DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('Test covers edge case on Windows only.');
|
||||
}
|
||||
|
||||
$basePath = $this->workspace.'\\directory\\';
|
||||
|
||||
$oldPath = getcwd();
|
||||
mkdir($basePath);
|
||||
chdir($basePath);
|
||||
$file = str_repeat('T', 259 - strlen($basePath));
|
||||
$path = $basePath.$file;
|
||||
exec('TYPE NUL >>'.$file); // equivalent of touch, we can not use the php touch() here because it suffers from the same limitation
|
||||
self::$longPathNamesWindows[] = $path; // save this so we can clean up later
|
||||
chdir($oldPath);
|
||||
$this->filesystem->exists($path);
|
||||
}
|
||||
|
||||
public function testFilesExistsTraversableObjectOfFilesAndDirectories()
|
||||
{
|
||||
$basePath = $this->workspace.DIRECTORY_SEPARATOR;
|
||||
@@ -893,7 +915,7 @@ class FilesystemTest extends FilesystemTestCase
|
||||
|
||||
public function testMirrorCopiesLinkedDirectoryContents()
|
||||
{
|
||||
$this->markAsSkippedIfSymlinkIsMissing();
|
||||
$this->markAsSkippedIfSymlinkIsMissing(true);
|
||||
|
||||
$sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR;
|
||||
|
||||
@@ -913,7 +935,7 @@ class FilesystemTest extends FilesystemTestCase
|
||||
|
||||
public function testMirrorCopiesRelativeLinkedContents()
|
||||
{
|
||||
$this->markAsSkippedIfSymlinkIsMissing();
|
||||
$this->markAsSkippedIfSymlinkIsMissing(true);
|
||||
|
||||
$sourcePath = $this->workspace.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR;
|
||||
$oldPath = getcwd();
|
||||
@@ -1005,7 +1027,6 @@ class FilesystemTest extends FilesystemTestCase
|
||||
|
||||
// The compress.zlib:// stream does not support mode x: creates the file, errors "failed to open stream: operation failed" and returns false
|
||||
$this->filesystem->tempnam($dirname, 'bar');
|
||||
|
||||
}
|
||||
|
||||
public function testTempnamWithPHPTempSchemeFails()
|
||||
@@ -1151,8 +1172,8 @@ class FilesystemTest extends FilesystemTestCase
|
||||
{
|
||||
$this->markAsSkippedIfChmodIsMissing();
|
||||
|
||||
$sourceFilePath = $this->workspace.DIRECTORY_SEPARATOR.'copy_source_file';
|
||||
$targetFilePath = $this->workspace.DIRECTORY_SEPARATOR.'copy_target_file';
|
||||
$sourceFilePath = $this->workspace . DIRECTORY_SEPARATOR . 'copy_source_file';
|
||||
$targetFilePath = $this->workspace . DIRECTORY_SEPARATOR . 'copy_target_file';
|
||||
|
||||
file_put_contents($sourceFilePath, 'SOURCE FILE');
|
||||
chmod($sourceFilePath, 0745);
|
||||
|
@@ -17,6 +17,8 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $umask;
|
||||
|
||||
static protected $longPathNamesWindows = array();
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\Filesystem\Filesystem
|
||||
*/
|
||||
@@ -31,6 +33,12 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
if (!empty(self::$longPathNamesWindows)) {
|
||||
foreach (self::$longPathNamesWindows as $path) {
|
||||
exec('DEL '.$path);
|
||||
}
|
||||
}
|
||||
|
||||
if ('\\' === DIRECTORY_SEPARATOR && null === self::$symlinkOnWindows) {
|
||||
$target = tempnam(sys_get_temp_dir(), 'sl');
|
||||
$link = sys_get_temp_dir().'/sl'.microtime(true).mt_rand();
|
||||
@@ -92,7 +100,7 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
|
||||
$this->markTestSkipped('Unable to retrieve file group name');
|
||||
}
|
||||
|
||||
protected function markAsSkippedIfSymlinkIsMissing()
|
||||
protected function markAsSkippedIfSymlinkIsMissing($relative = false)
|
||||
{
|
||||
if (!function_exists('symlink')) {
|
||||
$this->markTestSkipped('Function symlink is required.');
|
||||
@@ -101,6 +109,11 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase
|
||||
if ('\\' === DIRECTORY_SEPARATOR && false === self::$symlinkOnWindows) {
|
||||
$this->markTestSkipped('symlink requires "Create symbolic links" privilege on Windows');
|
||||
}
|
||||
|
||||
// https://bugs.php.net/bug.php?id=69473
|
||||
if ($relative && '\\' === DIRECTORY_SEPARATOR && 1 === PHP_ZTS) {
|
||||
$this->markTestSkipped('symlink does not support relative paths on thread safe Windows PHP versions');
|
||||
}
|
||||
}
|
||||
|
||||
protected function markAsSkippedIfChmodIsMissing()
|
||||
|
Reference in New Issue
Block a user