Error in function htmlspecialchars while importing from other course

Error in function htmlspecialchars while importing from other course

by Karel Janssen -
Number of replies: 2
We recently upgraded to Moodle 4.1.4, php version is 8.1.20. The theme is adaptable.

The following error occures when trying to import course material from another course using the 'import' function:

Moodle import error

It's not specific to any course, it happens everywhere. I already set $THEME->haseditswitch to true in the adaptable theme config file, based on other topics from this forum, altough I'm not sure this is relevant in this case. any help would be much appreciated!
Karel
Average of ratings: -
In reply to Karel Janssen

Re: Error in function htmlspecialchars while importing from other course

by Renaat Debleu -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Moodle can work on PHP 8.1, but when you have extra plugins installed the errors start to popup because :
  • some plugins are not PHP 8.1 compatible
  • some plugins are badly written.
  • some parts of Moodle are not yet 100% PHP 8.1 compatible (especially non-nullable internal php function are everywhere but only modified in some locations).
And it is a big problem the errors sometimes are thrown only during the backup and restore procedure, nobody can live with a system that cannot be backed up or restored.
You can
  •  go back to PHP 8.0 until all your extra plugins are compatible.
  • OR start digging using Behat and PHPUnit testing to pinpoint the origin of the problem (at least when your plugins have Behat and PHPUnit tests).
  • OR create a backup from 1 standard Moodle module and try to restore, next 2 standard Moodle modules and the question bank, next 3 standard Moodle modules and 1 extra plugin, next 4 standard modules and 2 extra plugins and all users..... This way you will loose a lot of time, but at least be able to know more or less the origin of the problem.
But anyhow it is not a bad idea to create a new issue in the Moodle issue tracker. In the end, all functions in Moodle that call htmlspecialchars should be reviewed and rewritten.
Average of ratings: Useful (1)
In reply to Renaat Debleu

Re: Error in function htmlspecialchars while importing from other course

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Switching back to PHP 8.0 worked for me. Everything was looking good using Moodle 4.1 and PHP 8.1, until I went to create some new Ad-hoc reports and found that all my old ones were no longer working correctly. After the switch back to PHP 8.0, they all worked like they used to. Thanks for this reminder, Renaat.