Skip to content

Commit 8318cbf

Browse files
committed
Merge branch '4.4' into 5.2
* 4.4: [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 9aa1587 + a501126 commit 8318cbf

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
@@ -650,10 +650,6 @@ public function dumpFile(string $filename, $content)
650650
$this->mkdir($dir);
651651
}
652652

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

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

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)