diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 2afcabc5470..87630217498 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -8322,8 +8322,14 @@ function forum_get_posts_by_user($user, array $courses, $musthaveaccess = false, } // Get the forum in question $forum = $forums[$forumid]; - // This is needed for functionality later on in the forum code.... - $forum->cm = $cm; + + // This is needed for functionality later on in the forum code. It is converted to an object + // because the cm_info is readonly from 2.6. This is a dirty hack because some other parts of the + // code were expecting an writeable object. See {@link forum_print_post()}. + $forum->cm = new stdClass(); + foreach ($cm as $key => $value) { + $forum->cm->$key = $value; + } // Check that either the current user can view the forum, or that the // current user has capabilities over the requested user and the requested