Skip to content

Commit

Permalink
MDL-70901 core: @ no longer masks errors in PHP 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
marinaglancy committed Feb 22, 2021
1 parent 2d059d1 commit b88f1a8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backup/util/loggers/file_logger.class.php
Expand Up @@ -97,7 +97,7 @@ protected function action($message, $level, $options = null) {
} else {
$content = $prefix . str_repeat('&nbsp;&nbsp;', $depth) . htmlentities($message, ENT_QUOTES, 'UTF-8') . '<br/>' . PHP_EOL;
}
if (false === fwrite($this->fhandle, $content)) {
if (!is_resource($this->fhandle) || (false === fwrite($this->fhandle, $content))) {
throw new base_logger_exception('error_writing_file', $this->fullpath);
}
return true;
Expand Down
6 changes: 5 additions & 1 deletion lib/classes/task/file_temp_cleanup_task.php
Expand Up @@ -90,7 +90,11 @@ protected function execute_on($tmpdir) {
} else {
// Return the time modified to the original date only for real files.
if ($iter->isDir() && !$iter->isDot()) {
touch($node, $modifieddateobject[$node]);
try {
@touch($node, $modifieddateobject[$node]);
} catch (\Throwable $t) {
null;
}
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion lib/filestorage/file_system_filedir.php
Expand Up @@ -395,7 +395,10 @@ public function add_file_from_path($pathname, $contenthash = null) {
}
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 b88f1a8

Please sign in to comment.