MDL-70901 core: @ no longer masks errors in PHP 8.0

This commit is contained in:
Marina Glancy 2021-02-22 16:17:21 +01:00
parent 2d059d1657
commit b88f1a84bf
3 changed files with 10 additions and 3 deletions

View File

@ -97,7 +97,7 @@ class file_logger extends base_logger {
} 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;

View File

@ -90,7 +90,11 @@ class file_temp_cleanup_task extends scheduled_task {
} 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;
}
}
}
}

View File

@ -395,7 +395,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);