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

H5P corrupts USER object, causing forum error


    • MDL-69868-master
    • Hide
      1. Create a course with forum and h5pactivity
      2. enrol a student
      3. login as student
      4. post to a forum
      5. Complete h5pactivity
      6. Go to view my attempts report
      7. Return to your forum post
      8. Ensure there is no exception thrown and you can see your post
      Create a course with forum and h5pactivity enrol a student login as student post to a forum Complete h5pactivity Go to view my attempts report Return to your forum post Ensure there is no exception thrown and you can see your post
    • Moppies Kanban

      Due to a bug in H5P, you may see a forum error of

      Exception - Argument 2 passed to mod_forum\local\entities\author::__construct() must be of the type int, string given, called in [dirroot]/mod/forum/classes/local/factories/entity.php on line 184


      The error is that the $user->picture field being passed to mod_forum\local\entities\author is a string instead of a int, which causes a TypeError to be thrown.

      It took a while to trace down, but basically the attempts report in mod_h5pactivity modifies a local $user object, replacing the picture field with the rendered html picture field, so:

      $user->picture == '1';


      $user->picture == '<a href="https://moodle/user/view.php?id=123&amp;course=345" class="d-inline-block aabtn"><img src="https://moodle/theme/image.php/boost/core/1601249177/u/f2" class="userpicture defaultuserpic" width="35" height="35" alt="Picture of Some Student" title="Picture of Some Student" /></a>';

      To reproduce:

      1. As a student, make sure you have posted to a forum
      2. Complete a mod_h5pactivity attempt (or have an attempt already existing)
      3. Once you have an attempt, if you go to the activity, you will have 'View my attempts'
      4. Click 'View my attempts'
      5. Now navigate back to the forum discussion you have posted in previously
      6. See the error above

            ilyatregubov Ilya Tregubov
            emerrill Eric Merrill
            Amaia Anabitarte Amaia Anabitarte
            Andrew Lyons Andrew Lyons
            Janelle Barcega Janelle Barcega
            0 Vote for this issue
            6 Start watching this issue


                Original Estimate - Not Specified
                Not Specified
                Remaining Estimate - 0 minutes
                Time Spent - 4 hours, 50 minutes
                4h 50m

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