-
Bug
-
Resolution: Fixed
-
Minor
-
3.11.12, 4.0.6, 4.1, 4.1.4, 4.2.1
After updating to PHP8.0 some teachers reported a major error in some course.
The cause is the presence of very old non migrated instances of mod_resource in the course together with PHP8.0
Steps to reproduce:
- In a vanilla Moodle (I used 4.2dev (Build: 20221201), the first test was with 4.0.1) with PHP8.0
- create a course
- add an instance of mod_resource (uploading e.g. a zip file) and save
- confirm that you can view the activity (mod/resource/view.php?id=xxx)
- confirm that the main course page works as expected (course/view.php?id=xxx)
- in the database update the table {resource}setting the field tobemigrated to 1
- empty all caches (admin/purgecaches.php)
- reload the main course page (course/view.php?id=xxx)
- confirm that now it contains Error: Cannot access offset of type string on string, with debugging on:
Exception - Cannot access offset of type string on string
|
|
More information about this error
|
|
Debug info:
|
Error code: generalexceptionmessageĂ—Dismiss this notification
|
Stack trace:
|
line 273 of /mod/resource/lib.php: TypeError thrown
|
line 2458 of /lib/modinfolib.php: call to resource_cm_info_view()
|
line 2486 of /lib/modinfolib.php: call to cm_info->call_mod_function()
|
line 1721 of /lib/modinfolib.php: call to cm_info->obtain_view_data()
|
line 1534 of /lib/modinfolib.php: call to cm_info->get_extra_classes()
|
line 106 of /course/format/classes/output/local/content/section/cmitem.php: call to cm_info->__get()
|
line 122 of /course/format/classes/output/local/content/section/cmlist.php: call to core_courseformat\output\local\content\section\cmitem->export_for_template()
|
line 225 of /course/format/classes/output/local/content/section.php: call to core_courseformat\output\local\content\section\cmlist->export_for_template()
|
line 156 of /course/format/classes/output/local/content/section.php: call to core_courseformat\output\local\content\section->add_cm_data()
|
line 46 of /course/format/topics/classes/output/courseformat/content/section.php: call to core_courseformat\output\local\content\section->export_for_template()
|
line 161 of /course/format/classes/output/local/content.php: call to format_topics\output\courseformat\content\section->export_for_template()
|
line 86 of /course/format/classes/output/local/content.php: call to core_courseformat\output\local\content->export_sections()
|
line 500 of /lib/outputrenderers.php: call to core_courseformat\output\local\content->export_for_template()
|
line 108 of /course/format/classes/output/section_renderer.php: call to plugin_renderer_base->render()
|
line 60 of /course/format/topics/format.php: call to core_courseformat\output\section_renderer->render()
|
line 272 of /course/view.php: call to require()
|
With PHP7.4 this was merely generating a warning:
Warning: Illegal string offset 'displayoptions' in /var/www/html/mod/resource/lib.php on line 273
|
Notice: Uninitialized string offset: 0 in /var/www/html/mod/resource/lib.php on line 273
|