mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 13:38:32 +01:00
Merge branch 'MDL-70901-master' of git://github.com/marinaglancy/moodle
This commit is contained in:
commit
e3a46964dc
@ -50,11 +50,18 @@ class file_logger extends base_logger {
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
@fclose($this->fhandle); // Blindy close the file handler (no exceptions in destruct)
|
||||
if (is_resource($this->fhandle)) {
|
||||
// Blindy close the file handler (no exceptions in destruct).
|
||||
@fclose($this->fhandle);
|
||||
}
|
||||
}
|
||||
|
||||
public function __sleep() {
|
||||
@fclose($this->fhandle); // Blindy close the file handler before serialization
|
||||
if (is_resource($this->fhandle)) {
|
||||
// Blindy close the file handler before serialization.
|
||||
@fclose($this->fhandle);
|
||||
$this->fhandle = null;
|
||||
}
|
||||
return array('level', 'showdate', 'showlevel', 'next', 'fullpath');
|
||||
}
|
||||
|
||||
@ -90,7 +97,7 @@ class file_logger extends base_logger {
|
||||
} else {
|
||||
$content = $prefix . str_repeat(' ', $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;
|
||||
|
2
cache/stores/file/lib.php
vendored
2
cache/stores/file/lib.php
vendored
@ -399,7 +399,7 @@ class cachestore_file extends cache_store implements cache_is_key_aware, cache_i
|
||||
public function delete($key) {
|
||||
$filename = $key.'.cache';
|
||||
$file = $this->file_path_for_key($key);
|
||||
if (@unlink($file)) {
|
||||
if (file_exists($file) && @unlink($file)) {
|
||||
unset($this->keys[$filename]);
|
||||
return true;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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');
|
||||
@ -393,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);
|
||||
@ -467,7 +472,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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user