Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-77185

PHP 8 error when disk_free_space function is disabled

XMLWordPrintable

      Description

      When using PHP 8+ with the function "disk_free_space" disabled, this throws the following error:

      Exception - Call to undefined function core\session\disk_free_space()

      Cause

      The error handling of the "@" character has changed with PHP 8 and PHP 8.1. If functions are addressed that are deactivated on the server side, a fatal error occurs even if this function is provided with an "@".
       
      In this case, it happens in the following file:

      /lib/classes/session/file.php:67

      $freespace = @disk_free_space($this->sessiondir);

       

      Solution

      in PHP 8+ we must check the function with "function_exists" implicit and not use "@", because in shared hosting some php functions could be disabled.

      Change the mentioned line code with:

      $freespace = function_exists('disk_free_space') ? disk_free_space($this->sessiondir) : false;

      Github Compare for pull-request: https://github.com/moodle/moodle/compare/main...fedealvz:moodle:main

       

       

            leonstr Leon Stringer
            fedealvz Federico Alvarez
            Meirza Meirza
            Huong Nguyen Huong Nguyen
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            2 Vote for this issue
            Watchers:
            18 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 41 minutes
                41m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.