-
Bug
-
Resolution: Fixed
-
Minor
-
3.11.11, 4.0.5, 4.0.7, 4.1, 4.1.2
-
MOODLE_311_STABLE, MOODLE_400_STABLE, MOODLE_401_STABLE
-
MOODLE_400_STABLE, MOODLE_401_STABLE
-
MDL-76376_m41 -
We are on MOODLE version 3.11. After loading PHP 8.0 we started getting the error below when trying to open any of our SCORM packages.
Exception - count(): Argument #1 ($value) must be of type Countable|array, null given
Turning on debugging revealed the additional detail below:
Debug info:
Error code: generalexceptionmessage Stack trace:
line 571 of /mod/scorm/datamodels/scormlib.php: TypeError thrown
I had to change the /mnt/data/moodle/htdocs/mod/scorm/datamodels/scormlib.php file. I found a forum where someone else was mentioning this error in PHP8 and the fix was to modify the line:
if (count($scoes->elements) > 0) {
to:
if (!empty($scoes->elements)) {
Apparently since elements wasn't an array, it couldn't do a 'count' of it. But just checking to see if it's empty provides the same functionality while keeping elements as undeclared