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

PHP8.0 error in mod_resource if legacy instances are present

XMLWordPrintable

    • MOODLE_311_STABLE, MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
    • MOODLE_401_STABLE, MOODLE_402_STABLE, MOODLE_403_STABLE
    • MDL-76555-401
    • MDL-76555-403
    • MDL-76555-master
    • Hide

      Test using PHP8.0

      1. Create a course
      2. Add an instance of mod_resource (uploading e.g. a zip file) and save.
      3. Confirm that you can view the activity (mod/resource/view.php?id=xxx)
      4. Confirm that the main course page works as expected (course/view.php?id=xxx)
      5. In the database update the table {resource} setting for the record corresponding to this activity the field tobemigrated to 1 (this is a way of reproducing the circumstances of a failed migration).
      6. Empty all caches (admin/purgecaches.php)
      7. Reload the main course page (course/view.php?id=xxx)
      8. Confirm that the page works as expected, no error occurs
      Show
      Test using 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 for the record corresponding to this activity the field tobemigrated to 1 (this is a way of reproducing the circumstances of a failed migration). Empty all caches (admin/purgecaches.php) Reload the main course page (course/view.php?id=xxx) Confirm that the page works as expected, no error occurs

      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
      

            ManeggiaP Paola Maneggia
            ManeggiaP Paola Maneggia
            Mathew May Mathew May
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            24 Vote for this issue
            Watchers:
            26 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 59 minutes
                1d 59m

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