Skip to content

Commit f810e3c

Browse files
committedSep 16, 2024
Merge branch '5.4' into 6.4
* 5.4: [HttpClient] Fix setting CURLMOPT_MAXCONNECTS throw a meaningful exception when parsing dotenv files with BOM [Cache] Fix RedisSentinel params types [FrameworkBundle] Fix service reset between tests [Uid][Serializer][Validator] Mention RFC 9562 make sure temp files can be cleaned up on Windows
2 parents 8476ad8 + 76c3818 commit f810e3c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
 

‎Filesystem.php

+4
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,10 @@ public function dumpFile(string $filename, $content)
697697
$this->rename($tmpFile, $filename, true);
698698
} finally {
699699
if (file_exists($tmpFile)) {
700+
if ('\\' === \DIRECTORY_SEPARATOR && !is_writable($tmpFile)) {
701+
self::box('chmod', $tmpFile, self::box('fileperms', $tmpFile) | 0200);
702+
}
703+
700704
self::box('unlink', $tmpFile);
701705
}
702706
}

‎Tests/FilesystemTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -1813,6 +1813,22 @@ public function testDumpKeepsExistingPermissionsWhenOverwritingAnExistingFile()
18131813
$this->assertFilePermissions(745, $filename);
18141814
}
18151815

1816+
public function testDumpFileCleansUpAfterFailure()
1817+
{
1818+
$targetFile = $this->workspace.'/dump-file';
1819+
$this->filesystem->touch($targetFile);
1820+
$this->filesystem->chmod($targetFile, 0444);
1821+
1822+
try {
1823+
$this->filesystem->dumpFile($targetFile, 'any content');
1824+
} catch (IOException $e) {
1825+
} finally {
1826+
$this->filesystem->chmod($targetFile, 0666);
1827+
}
1828+
1829+
$this->assertSame([$targetFile], glob($this->workspace.'/*'));
1830+
}
1831+
18161832
public function testCopyShouldKeepExecutionPermission()
18171833
{
18181834
$this->markAsSkippedIfChmodIsMissing();

0 commit comments

Comments
 (0)
Failed to load comments.