MDL-70901 core_files: @ does no mask errors in php8 anymore

This commit is contained in:
Marina Glancy 2021-02-15 19:39:50 +01:00
parent 8b5bd4fb00
commit 03b198f45d

View file

@ -378,7 +378,9 @@ class file_system_filedir extends file_system {
// Let's try to prevent some race conditions.
$prev = ignore_user_abort(true);
@unlink($hashfile.'.tmp');
if (file_exists($hashfile.'.tmp')) {
@unlink($hashfile.'.tmp');
}
if (!copy($pathname, $hashfile.'.tmp')) {
// Borked permissions or out of disk space.
@unlink($hashfile.'.tmp');
@ -467,7 +469,10 @@ class file_system_filedir extends file_system {
}
rename($hashfile.'.tmp', $hashfile);
chmod($hashfile, $this->filepermissions); // Fix permissions if needed.
@unlink($hashfile.'.tmp'); // Just in case anything fails in a weird way.
if (file_exists($hashfile.'.tmp')) {
// Just in case anything fails in a weird way.
@unlink($hashfile.'.tmp');
}
ignore_user_abort($prev);
return array($contenthash, $filesize, $newfile);