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

H5P corrupts USER object, causing forum error

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Waiting for integration review
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.9.2
    • Fix Version/s: None
    • Component/s: Forum, H5P
    • Sprint:
      Moppies Kanban

      Description

      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';
      

      becomes

      $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

        Attachments

          Activity

            People

            Assignee:
            ilyatregubov Ilya Tregubov
            Reporter:
            emerrill Eric Merrill
            Peer reviewer:
            Amaia Anabitarte
            Participants:
            Component watchers:
            Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 20 minutes
                3h 20m