Skip to content

Commit cde36a6

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [Filesystem] Workaround cannot dumpFile into "protected" folders on Windows Handle concurency in Csrf DoctrineTokenProvider Missing translations for Chinese (zh_CN) #41814 [VarDumper] improve support for AmpHttpClient update Italian translation Fix SessionTokenStorage reuse with Request added missing Arabic translations
2 parents 41fe6da + 19b71c8 commit cde36a6

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

Filesystem.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -651,10 +651,6 @@ public function dumpFile(string $filename, $content)
651651
$this->mkdir($dir);
652652
}
653653

654-
if (!is_writable($dir)) {
655-
throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
656-
}
657-
658654
// Will create a temp file with 0600 access rights
659655
// when the filesystem supports chmod.
660656
$tmpFile = $this->tempnam($dir, basename($filename));
@@ -693,10 +689,6 @@ public function appendToFile(string $filename, $content)
693689
$this->mkdir($dir);
694690
}
695691

696-
if (!is_writable($dir)) {
697-
throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
698-
}
699-
700692
if (false === self::box('file_put_contents', $filename, $content, \FILE_APPEND)) {
701693
throw new IOException(sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename);
702694
}

Tests/FilesystemTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1762,6 +1762,27 @@ public function testCopyShouldKeepExecutionPermission()
17621762
$this->assertFilePermissions(767, $targetFilePath);
17631763
}
17641764

1765+
public function testDumpToProtectedDirectory()
1766+
{
1767+
if (\DIRECTORY_SEPARATOR !== '\\') {
1768+
$this->markTestSkipped('This test is specific to Windows.');
1769+
}
1770+
1771+
if (($userProfilePath = getenv('USERPROFILE')) === false || !is_dir($userProfilePath)) {
1772+
throw new \RuntimeException('Failed to retrieve user profile path.');
1773+
}
1774+
1775+
$targetPath = implode(\DIRECTORY_SEPARATOR, [$userProfilePath, 'Downloads', '__test_file.ext']);
1776+
1777+
try {
1778+
$this->assertFileDoesNotExist($targetPath);
1779+
$this->filesystem->dumpFile($targetPath, 'foobar');
1780+
$this->assertFileExists($targetPath);
1781+
} finally {
1782+
$this->filesystem->remove($targetPath);
1783+
}
1784+
}
1785+
17651786
/**
17661787
* Normalize the given path (transform each forward slash into a real directory separator).
17671788
*/

0 commit comments

Comments
 (0)