Skip to content

Commit

Permalink
MDL-77185 session: Fix undefined disk_free_space
Browse files Browse the repository at this point in the history
Fix PHP fatal error "Call to undefined function
core\session\disk_free_space()" when disable_functions=disk_free_space.
Prior to PHP 8.0 this error was suppressed by '@'.

Co-authored-by: Federico Alvarez <[email protected]>
  • Loading branch information
leonstr and fedealvz committed Dec 31, 2024
1 parent 04cb431 commit ae3acab
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/classes/session/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public function init() {
}
// Need to disable debugging since disk_free_space()
// will fail on very large partitions (see MDL-19222).
$freespace = @disk_free_space($this->sessiondir);
// MDL-43039: disk_free_space() returns null if disabled.
if (!($freespace > 2048) and ($freespace !== false) and ($freespace !== null)) {
// Moodle supports disable_functions = disk_free_space (MDL-43039).
$freespace = function_exists('disk_free_space') ? disk_free_space($this->sessiondir) : false;
if (!($freespace > 2048) and ($freespace !== false)) {
throw new exception('sessiondiskfull', 'error');
}

Expand Down

0 comments on commit ae3acab

Please sign in to comment.