Moodle
  1. Moodle
  2. MDL-31664

If I delete a post (in Q and A Forum) with several answers to it, the answers remain in database and are not deleted

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.1
    • Fix Version/s: 2.1.6, 2.2.3
    • Component/s: Forum
    • Labels:
    • Database:
      Any
    • Testing Instructions:
      Hide

      1. Create a forum.
      2. Create a discussion (post A) as a user.
      3. Post a reply (post B) as another user.
      4. Post another reply (post C).

      As an admin, delete post B. Both B and C should be gone from the database.

      Show
      1. Create a forum. 2. Create a discussion (post A) as a user. 3. Post a reply (post B) as another user. 4. Post another reply (post C). As an admin, delete post B. Both B and C should be gone from the database.
    • Affected Branches:
      MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull from Repository:
    • Rank:
      38238

      Description

      In a Q and A Forum I have a post (discussion) and an answer to this post and an answer to this post:
      discussion
      -answer 1 < I want to delete this with subposts
      ----answer 2
      I delete answer1 but when I look at the first page of the forum there is the discussion with one answer. In database in table mdl_posts I see the answer 2 is still remaining.

        Issue Links

          Activity

          Hide
          Michael de Raadt added a comment -

          Hi, Katja.

          I'm having trouble understanding what you mean.

          What is removed and what remains?

          Perhaps you could include screenshots to show what is happening.

          It would be helpful if you could provide a set of steps that someone could follow to replicate this problem.

          Show
          Michael de Raadt added a comment - Hi, Katja. I'm having trouble understanding what you mean. What is removed and what remains? Perhaps you could include screenshots to show what is happening. It would be helpful if you could provide a set of steps that someone could follow to replicate this problem.
          Hide
          Charles Fulton added a comment -

          I can reproduce this in current 2.2.1+ and it's not limited to the Q&A forum type. Say you have discussion A and two replies, B and C (C replying to B and B replying to A). If you delete reply B, reply C remains in the database orphaned instead of getting deleted.

          Show
          Charles Fulton added a comment - I can reproduce this in current 2.2.1+ and it's not limited to the Q&A forum type. Say you have discussion A and two replies, B and C (C replying to B and B replying to A). If you delete reply B, reply C remains in the database orphaned instead of getting deleted.
          Hide
          Charles Fulton added a comment -

          I think I've gotten this to work correctly on my local instance. Part of the test for deleting child posts was "$children != 'ignore", but $children is often a boolean value, so that's not a valid comparison since 'ignore' will be cast as a boolean (cf http://php.net/manual/en/language.operators.comparison.php).

          Show
          Charles Fulton added a comment - I think I've gotten this to work correctly on my local instance. Part of the test for deleting child posts was "$children != 'ignore", but $children is often a boolean value, so that's not a valid comparison since 'ignore' will be cast as a boolean (cf http://php.net/manual/en/language.operators.comparison.php ).
          Hide
          Ankit Agarwal added a comment -

          Hi Charles,
          Thanks for the spot on patch. Looks perfect.
          +1 to integrate.
          Also its clean cherry pick to 21 and master.
          Thanks

          Show
          Ankit Agarwal added a comment - Hi Charles, Thanks for the spot on patch. Looks perfect. +1 to integrate. Also its clean cherry pick to 21 and master. Thanks
          Hide
          Ankit Agarwal added a comment -

          Sorry Charles,
          Didnt know you cannot push stuff to integration.
          Sent.
          Thanks

          Show
          Ankit Agarwal added a comment - Sorry Charles, Didnt know you cannot push stuff to integration. Sent. Thanks
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Some hours ago...

          the main moodle.git repository has been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

          TIA and ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Some hours ago... the main moodle.git repository has been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
          Hide
          Sam Hemelryk added a comment -

          Thanks Charles this has been integrated now

          Show
          Sam Hemelryk added a comment - Thanks Charles this has been integrated now
          Hide
          Petr Škoda added a comment -

          Deleting works for me now, but who deletes all the orphaned posts that may already be in the system?

          Show
          Petr Škoda added a comment - Deleting works for me now, but who deletes all the orphaned posts that may already be in the system?
          Hide
          Charles Fulton added a comment -

          @Petr: there's already an issue for that, MDL-13516. I'm thinking an addition to forum cron, but that should be solved independently of this issue.

          Show
          Charles Fulton added a comment - @Petr: there's already an issue for that, MDL-13516 . I'm thinking an addition to forum cron, but that should be solved independently of this issue.
          Hide
          Petr Škoda added a comment -

          ah, thanks for the link. I guess the right place is to do it in mod/forum/db/upgrade.php because cron needs to be as fast as possible.

          Show
          Petr Škoda added a comment - ah, thanks for the link. I guess the right place is to do it in mod/forum/db/upgrade.php because cron needs to be as fast as possible.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          FCT (fixed, closing, thanks). Ciao

          "I feel a very unusual sensation - if it is not indigestion, I think it must be gratitude!"
          ~ Benjamin Disraeli

          Show
          Eloy Lafuente (stronk7) added a comment - FCT (fixed, closing, thanks). Ciao "I feel a very unusual sensation - if it is not indigestion, I think it must be gratitude!" ~ Benjamin Disraeli

            People

            • Votes:
              7 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: