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

forum cron problem with digests and plagiarism integration

XMLWordPrintable

    • MOODLE_26_STABLE, MOODLE_28_STABLE
    • MOODLE_27_STABLE, MOODLE_28_STABLE
    • MDL-48723_master_forum-plagiarism_errors
    • Hide
      1. Enable plagiarism in the Moodle instance. (You do not actually need to have a plagiarism plugin installed to test this.)
      2. Enable debug
      3. Select a forum (if necessary, create a simple course and use the News forum).
      4. Enrol a user and set the user's profile to receive email digests.
      5. Create a forum post with an attachment. This can be a trivial .txt file.
      6. Execute the cron at least once before digests are scheduled to go out.
      7. Execute again after digests are scheduled to go out.
      8. Confirm that the cron produces no php notices regarding undefined course and forum properties. (Prior to the fix, it does produce such notices.)
      Show
      Enable plagiarism in the Moodle instance. (You do not actually need to have a plagiarism plugin installed to test this.) Enable debug Select a forum (if necessary, create a simple course and use the News forum). Enrol a user and set the user's profile to receive email digests. Create a forum post with an attachment. This can be a trivial .txt file. Execute the cron at least once before digests are scheduled to go out. Execute again after digests are scheduled to go out. Confirm that the cron produces no php notices regarding undefined course and forum properties. (Prior to the fix, it does produce such notices.)

      function forum_print_attachments is throwing php notices in the cron due to this code in that function:

                  if (!empty($CFG->enableplagiarism)) {
                      require_once($CFG->libdir.'/plagiarismlib.php');
                      $output .= plagiarism_get_links(array('userid' => $post->userid,
                          'file' => $file,
                          'cmid' => $cm->id,
                          'course' => $post->course,
                          'forum' => $post->forum));
                      $output .= '<br />';
                  }    
      

      The notices look like this:

      PHP Notice:  Undefined property: stdClass::$course in /home/moodle/2.6/docs/mod/forum/lib.php on line 4193
      PHP Notice:  Undefined property: stdClass::$forum in /home/moodle/2.6/docs/mod/forum/lib.php on line 4194
      

      They occur when forum_print_attachments gets called (through forum_make_mail_text and forum_make_mail_post) from forum_cron while processing the digest mailings. The problem occurs because, for digests, the post object gets created in this line and so does not have the course and forum properties on it:

      if ($post = $DB->get_record('forum_posts', array('id' => $digestpost->postid))) {
      

      For the non-digest case, the posts come from forum_get_unmailed_posts, which joins with mdl_forum_discussions to bring in the course and forum properties.

      We experience the problem in 2.6, but the problem also appears to be present in 2.8, which we will put into production shortly.

            colin Colin Campbell (Inactive)
            colin Colin Campbell (Inactive)
            Dan Marsden Dan Marsden
            David Monllaó David Monllaó
            John Okely John Okely
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

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