Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-9167

Remove shadow topics from remaining forums when deleting a forum including posts

    Details

    • Type: Bug
    • Status: Unverified Fix
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0.6
    • Fix Version/s: 3.0.8-RC1
    • Component/s: Other
    • Labels:
      None

      Activity

      Hide
      A_Jelly_Doughnut A_Jelly_Doughnut added a comment -

      I would write two queries in the acp_forums::delete_forum routine. The first would select all shadow topics pointing at the deleted forum (via a join to the topics table), and the second would actually do the deletion.

      Something like this:

      SELECT t2.topic_id, t.topic_id as Source FROM phpbb_topics t, phpbb_topics t2
      WHERE t2.topic_moved_id = t.topic_id
        AND t.forum_id = 2

      (Where, for PHP purposes, the 2 is replaced by a variable)

      Show
      A_Jelly_Doughnut A_Jelly_Doughnut added a comment - I would write two queries in the acp_forums::delete_forum routine. The first would select all shadow topics pointing at the deleted forum (via a join to the topics table), and the second would actually do the deletion. Something like this: SELECT t2.topic_id, t.topic_id as Source FROM phpbb_topics t, phpbb_topics t2 WHERE t2.topic_moved_id = t.topic_id AND t.forum_id = 2 (Where, for PHP purposes, the 2 is replaced by a variable)
      Hide
      bantu Andreas Fischer added a comment - - edited

      This should be fixable.

      I wrote a small script for something similar some time ago.

      $sql = 'SELECT t1.topic_id
      	FROM ' . TOPICS_TABLE . ' t1
      	LEFT JOIN ' . TOPICS_TABLE . ' t2
      		ON (t2.topic_id = t1.topic_moved_id)
      	WHERE ' . $db->sql_in_set('t2.forum_id', $trash_forum_ids);
      $db->sql_query($sql);
       
      $topic_ids_delete = array();
      while ($topic_ids_delete[] = (int) $db->sql_fetchfield('topic_id'));
      $db->sql_freeresult($result);
       
      if (!empty($topic_ids_delete))
      {
      	delete_topics('topic_id', $topic_ids_delete);
      }

      Show
      bantu Andreas Fischer added a comment - - edited This should be fixable. I wrote a small script for something similar some time ago. $sql = 'SELECT t1.topic_id FROM ' . TOPICS_TABLE . ' t1 LEFT JOIN ' . TOPICS_TABLE . ' t2 ON (t2.topic_id = t1.topic_moved_id) WHERE ' . $db->sql_in_set('t2.forum_id', $trash_forum_ids); $db->sql_query($sql);   $topic_ids_delete = array(); while ($topic_ids_delete[] = (int) $db->sql_fetchfield('topic_id')); $db->sql_freeresult($result);   if (!empty($topic_ids_delete)) { delete_topics('topic_id', $topic_ids_delete); }
      Hide
      bantu Andreas Fischer added a comment -

      delete_topic_shadows() from functions_admin.php seems to do the job

      Show
      bantu Andreas Fischer added a comment - delete_topic_shadows() from functions_admin.php seems to do the job
      Hide
      bantu Andreas Fischer added a comment -

      I have to review this again.

      Show
      bantu Andreas Fischer added a comment - I have to review this again.
      Hide
      bantu Andreas Fischer added a comment -

      Rebased commits to resolve conflicts, removed changelog entry and corrected commit messages.

      Show
      bantu Andreas Fischer added a comment - Rebased commits to resolve conflicts, removed changelog entry and corrected commit messages.

        People

        • Assignee:
          bantu Andreas Fischer
          Reporter:
          gs2088c gs2088c [X] (Inactive)
        • Votes:
          0 Vote for this issue
          Watchers:
          1 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved:

            Development