Unknown error with Moodle after PHP 8 update

Unknown error with Moodle after PHP 8 update

by michael douman -
Number of replies: 3

Hi there. 

I received the following error after the IT administrator in the company left. 

Fatal error: Uncaught Error: Call to undefined function current_language() in /usr/www/users/projehvusv/moodle/lib/setuplib.php:713 Stack trace: #0 /usr/www/users/projehvusv/moodle/lib/setuplib.php(572): get_docs_url() #1 /usr/www/users/projehvusv/moodle/lib/setuplib.php(363): get_exception_info(Object(ArgumentCountError)) #2 [internal function]: default_exception_handler(Object(ArgumentCountError)) #3 {main} thrown in /usr/www/users/projehvusv/moodle/lib/setuplib.php on line 713

It is a problem with our Moodle and I was hoping someone could assist me with this issue. 

Is there a way to resolve this? 

Currently running PHP 8.1 as we had to update it due to another system. Now we are receiving this error message when trying to access Moodle. 

Average of ratings: -
In reply to michael douman

Re: Unknown error with Moodle after PHP 8 update

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Yeh - Moodle is not (yet) compatible with PHP 8.1. The maximum is PHP 8.0
In reply to michael douman

Re: Unknown error with Moodle after PHP 8 update

by Mark Sharp -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
It looks to me that that is a bug no matter the version of PHP. It's calling current_language in setuplib.php, which shouldn't be calling functions that may not exist yet. The other reference to current_language() in setuplib is wrapped by function_exists('current_language'), but the one on line 713 isn't.

Doesn't detract from the general point that Moodle isn't ready for PHP 8.1. You don't mention the version of Moodle you're using.

This is likely to be the first of many errors you'll get. You'd benefit by running a deprecation detector across your code base. e.g. https://github.com/wapmorgan/PhpDeprecationDetector

Your problems might not just be core Moodle.

Ps. Bad form on your IT administrator leaving the company with broken sites.
Average of ratings: Useful (1)