Moodle

Forum: Rating triggers undefined property error - cmidnumber

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.9
  • Fix Version/s: 1.9
  • Component/s: Forum
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

When posting a rating with debugging turned to ALL I received the following PHP notice

Notice: Undefined property: stdClass::$cmidnumber in /home/arborrow/Moodle/code/19stable/mod/forum/lib.php on line 1168

This is caused because the forum_grade_item_update function in /mod/forum/lib.php expects the $forum variable to have a field $cmidnumber ( * @param object $forum object with extra cmidnumber). I traced this back to /mod/forum/rate.php and found that the extra cmidnumber field was not being added on prior to passing the variable to the forum_grade_item_update function.

I'll attach one possible patch that I used to get around this.

Issue Links

Activity

Hide
Anthony Borrow added a comment -

Here's a suggested patch.

Show
Anthony Borrow added a comment - Here's a suggested patch.
Hide
Anthony Borrow added a comment -

The suggested patch simply adds the cmidnumber to $forum if it was able to find the course module. It seems like a logical place to put it. We may want to comment why we are adding it. Peace - Anthony

Show
Anthony Borrow added a comment - The suggested patch simply adds the cmidnumber to $forum if it was able to find the course module. It seems like a logical place to put it. We may want to comment why we are adding it. Peace - Anthony
Hide
Petr Škoda (skodak) added a comment -

already committed some time ago, thanks for the patch and report!

Show
Petr Škoda (skodak) added a comment - already committed some time ago, thanks for the patch and report!

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: