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

Reset forums not working with multiple forum types

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.5.4, 2.6.1, 2.8.7, 2.9.1
    • Fix Version/s: 2.8.8, 2.9.2
    • Component/s: Forum
    • Labels:
    • Testing Instructions:
      Hide

      In a course with posts in a forum:

      • In Course administration go to "Reset course"
      • Go to "Forums", "Show more..."
      • In "Delete posts from" choose 2 or more forum types
      • Click "Reset course"
      • Check if this actually reset the relevant forums
      • Test again, ensuring that it resets the relevant forums if only one type is selected
      • Test again, ensuring that it resets all forums if the "delete all posts" box is checked
      Show
      In a course with posts in a forum: In Course administration go to "Reset course" Go to "Forums", "Show more..." In "Delete posts from" choose 2 or more forum types Click "Reset course" Check if this actually reset the relevant forums Test again, ensuring that it resets the relevant forums if only one type is selected Test again, ensuring that it resets all forums if the "delete all posts" box is checked
    • Workaround:
      Hide

      Select forum types one by one to delete posts from.

      Show
      Select forum types one by one to delete posts from.
    • Affected Branches:
      MOODLE_25_STABLE, MOODLE_26_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_28_STABLE, MOODLE_29_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-43709-master

      Description

      Resetting forums in course/reset.php doesn't work when multiple forum types are selected on the "Delete posts from" list.

      This seems to be the same as in MDL-20052, so probably quite an old bug affecting all Moodle versions.

      Steps to reproduce:
      In a course with posts in a forum

      • In Course administration go to "Reset course"
      • Go to "Forums", "Show more..."
      • In "Delete posts from" choose 2 or more forum types
      • Click "Reset course"
      • Check if this actually reset the forums

      Resetting forums works as expected when only one type is selected, but with multiple types selected it produces queries like:
      SELECT f.id FROM mdl_forum f WHERE f.course='123' AND f.type='news' AND f.type='social' AND f.type='general';

      The queries match nothing in the database since f.type can only be of one type.
      A query with "OR" would serve the purpose better:
      SELECT f.id FROM mdl_forum f WHERE f.course='123' AND (f.type='news' OR f.type='social' OR f.type='general');

      The SQL query is composed using "AND" when there should be an "OR" to concatenate different types in the foreach loop in forum_reset_userdata($data), mod/forum/lib.php lines 7208 - 7215:
      http://git.moodle.org/gw?p=moodle.git;a=blob;f=mod/forum/lib.php;h=a6f8a30ce50f3e2790cd0452ee369cc9e08edbcf;hb=refs/heads/master#l7212

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                14/Sep/15