Skip to content

Commit 19b71c8

Browse files
committed
Merge branch '5.2' into 5.3
* 5.2: [Filesystem] Workaround cannot dumpFile into "protected" folders on Windows Missing translations for Chinese (zh_CN) #41814 update Italian translation added missing Arabic translations
2 parents 3481163 + 8318cbf commit 19b71c8

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
@@ -669,10 +669,6 @@ public function dumpFile(string $filename, $content)
669669
$this->mkdir($dir);
670670
}
671671

672-
if (!is_writable($dir)) {
673-
throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
674-
}
675-
676672
// Will create a temp file with 0600 access rights
677673
// when the filesystem supports chmod.
678674
$tmpFile = $this->tempnam($dir, basename($filename));
@@ -711,10 +707,6 @@ public function appendToFile(string $filename, $content)
711707
$this->mkdir($dir);
712708
}
713709

714-
if (!is_writable($dir)) {
715-
throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
716-
}
717-
718710
if (false === self::box('file_put_contents', $filename, $content, \FILE_APPEND)) {
719711
throw new IOException(sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename);
720712
}

Tests/FilesystemTest.php

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

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

0 commit comments

Comments
 (0)