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

Coding error when Feedback activity is in Recent Activity - User id is required when printing user avatar image.

    Details

    • Testing Instructions:
      Hide
      1. Activate feedback module at the admin settings
      2. Add a feedback instance to a course.
      3. Make sure the course has the Recent Activity block.
      4. Complete the feedback activity. It isn't important what user you use.
      5. In the recent activity block, click "Full report of recent activity."
      6. No error raises
      Show
      Activate feedback module at the admin settings Add a feedback instance to a course. Make sure the course has the Recent Activity block. Complete the feedback activity. It isn't important what user you use. In the recent activity block, click "Full report of recent activity." No error raises
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-37628-master

      Description

      After a student submits a Feedback activity, it causes a coding error in the Recent Activity block.

      Coding error detected, it must be fixed by a programmer: User id is required when printing user avatar image.

      More information about this error

      Debug info:
      Error code: codingerror
      Stack trace:
      line 186 of /lib/outputcomponents.php: coding_exception thrown
      line 1897 of /lib/outputrenderers.php: call to user_picture->__construct()
      line 487 of /mod/feedback/lib.php: call to core_renderer->user_picture()
      line 263 of /course/recent.php: call to feedback_print_recent_mod_activity()

      Steps to reproduce:
      1. Add a feedback activity to a course.
      2. Make sure the course has the Recent Activity block.
      3. Complete the feedback activity. (Normally a student does this, but it breaks as admin too)
      4. In the recent activity block, click "Full report of recent activity."
      5. Receive error.

      We have used these steps to reproduce this on a pure Moodle 2.3.3 site with no non-standard plugins, themes, or customizations.

      feedback_print_recent_mod_activity() calls user_picture() to display the user's avatar. user_picture() expects the user object to have an "id" field but its id field is called "userid" instead.

      Because this is causing a critical problem with a plugin for many of our clients, we are implementing a quick fix at the top of feedback_print_recent_mod_activity():

          if (is_object($activity->user)) {
              //Simple fix: user_picture expects user->id.
              $activity->user->id = $activity->user->userid;
          }
      

      Anyone who needs a quick fix may feel free to use this but I'm not sure if this is the best way to fix it permanently.

        Gliffy Diagrams

          Activity

          Hide
          cfollin Chris Follin added a comment -

          I'm adding the patch label to this ticket since we did provide a fix. However, as I said in the description, we're not sure this is the best permanent solution. Therefore the patch is put up for consideration but it's fine if the integrated fix is ultimately something else.

          Show
          cfollin Chris Follin added a comment - I'm adding the patch label to this ticket since we did provide a fix. However, as I said in the description, we're not sure this is the best permanent solution. Therefore the patch is put up for consideration but it's fine if the integrated fix is ultimately something else.
          Hide
          grabs Andreas Grabs added a comment -

          Hi Chris,

          thank you for finding out this.

          Andreas

          Show
          grabs Andreas Grabs added a comment - Hi Chris, thank you for finding out this. Andreas
          Hide
          grabs Andreas Grabs added a comment -

          Hi,
          the function "feedback_get_recent_mod_activity" did not deliver the correct data. I changed it now.
          By the way I fixed a strict warning in this function.
          Best regards
          Andreas

          Show
          grabs Andreas Grabs added a comment - Hi, the function "feedback_get_recent_mod_activity" did not deliver the correct data. I changed it now. By the way I fixed a strict warning in this function. Best regards Andreas
          Hide
          stronk7 Eloy Lafuente (stronk7) added a comment -

          The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

          TIA and ciao

          Show
          stronk7 Eloy Lafuente (stronk7) added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
          Hide
          samhemelryk Sam Hemelryk added a comment -

          Thanks guys, this has been integrated now.

          Show
          samhemelryk Sam Hemelryk added a comment - Thanks guys, this has been integrated now.
          Hide
          damyon Damyon Wiese added a comment -

          Test passed in all branches. Thanks Andreas!

          Show
          damyon Damyon Wiese added a comment - Test passed in all branches. Thanks Andreas!
          Hide
          stronk7 Eloy Lafuente (stronk7) added a comment -

          A brilliant future is awaiting us out there, better with your code. Let's look towards the future together, this is now closed.

          (and won't be revisiting it unless some regression is found)

          Thanks and ciao

          Show
          stronk7 Eloy Lafuente (stronk7) added a comment - A brilliant future is awaiting us out there, better with your code. Let's look towards the future together, this is now closed. (and won't be revisiting it unless some regression is found) Thanks and ciao

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/Mar/13