mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-70901 backup: check handle before calling fclose()
@fclose no longer catches error in PHP 8.0 when handle is null
This commit is contained in:
parent
a93828a188
commit
3e076d8cff
1 changed files with 9 additions and 2 deletions
|
@ -50,11 +50,18 @@ class file_logger extends base_logger {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __destruct() {
|
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() {
|
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');
|
return array('level', 'showdate', 'showlevel', 'next', 'fullpath');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue