Skip to content

Commit b7ea899

Browse files
Merge branch '7.1' into 7.2
* 7.1: [Process] minor fix [Process] Fix finding executables independently of open_basedir [HttpKernel] Skip logging uncaught exceptions in ErrorHandler, assume $kernel->terminateWithException() will do it [Serializer] Fix for method named `get()` [Notifier][TurboSMS] Process partial accepted response from transport parse empty sequence elements as null [HttpClient] Fix setting CURLMOPT_MAXCONNECTS throw a meaningful exception when parsing dotenv files with BOM [FrameworkBundle] Fix schema & finish incomplete tests for lock & semaphore config [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 810b534 + 61fe056 commit b7ea899

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
@@ -673,6 +673,10 @@ public function dumpFile(string $filename, $content): void
673673
$this->rename($tmpFile, $filename, true);
674674
} finally {
675675
if (file_exists($tmpFile)) {
676+
if ('\\' === \DIRECTORY_SEPARATOR && !is_writable($tmpFile)) {
677+
self::box('chmod', $tmpFile, self::box('fileperms', $tmpFile) | 0200);
678+
}
679+
676680
self::box('unlink', $tmpFile);
677681
}
678682
}

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 testReadFile()
18171833
{
18181834
$licenseFile = \dirname(__DIR__).'/LICENSE';

0 commit comments

Comments
 (0)