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

forum cron problem with digests and plagiarism integration

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.6.6, 2.8.1
    • Fix Version/s: 2.7.8, 2.8.6
    • Component/s: Forum, Plagiarism
    • Labels:
    • Testing Instructions:
      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.)
    • Affected Branches:
      MOODLE_26_STABLE, MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-48723_master_forum-plagiarism_errors

      Description

      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.

        Attachments

          Activity

            People

            • Assignee:
              colin Colin Campbell
              Reporter:
              colin Colin Campbell
              Peer reviewer:
              Dan Marsden
              Integrator:
              David Monllaó
              Tester:
              John Okely
              Participants:
              Component watchers:
              Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Dan Marsden, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/May/15