Skip to content

Commit

Permalink
MDL-70901 core_files: @ does no mask errors in php8 anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Feb 22, 2021
1 parent 3e076d8 commit a1a72f7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/filestorage/file_system_filedir.php
Expand Up @@ -378,7 +378,9 @@ public function add_file_from_path($pathname, $contenthash = null) {
// 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');
Expand Down Expand Up @@ -467,7 +469,10 @@ public function add_file_from_string($content) {
}
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);
Expand Down

0 comments on commit a1a72f7

Please sign in to comment.