Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-8208

attachments arbitrarily deleted

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Blocker Blocker
    • 3.0.5
    • 3.0.4
    • Other
    • None
    • PHP Environment:
      Database:

      Attachments have mysteriously disappeared on our forum. Mysql log shows strange entries like:

      #090308 15:17:45 server id 1 end_log_pos 5796499 Query thread_id=12257 exec_time=0 error_code=0
      DELETE FROM phpbb3_attachments WHERE post_msg_id IN (4062, 4116)/!/;
      #090308 15:17:45 server id 1 end_log_pos 5796630 Query thread_id=12257 exec_time=0 error_code=0
      DELETE FROM phpbb3_privmsgs WHERE msg_id IN (4062, 4116)/!/;

      Here attachments in post with post_msg_id (4062, 4116) and attachments in primsg with msg_id (4062, 4116) are deleted at the same second. The posts and the primsgs do share the same ID, but they were supposed to be totally different? Now their attachments are deleted at the same time. And we see quite some "coincidences" in mysql logs.

      This is because the function delete_attachments deletes attachments in either posts or primsgs. It is called in different modes(parameters) to handle posts or primsgs. However, inside this function delete_attachments, the two modes are bundled to handle indifferently, and always treat the input id as post_msg_id. Here is the relevant portion in delete_attachments:

      • Delete Attachments
      • @param string $mode can be: post|message|topic|attach|user
        function delete_attachments($mode, $ids, $resync = true)
        switch ($mode)
        {
        case 'post':
        case 'message':
        $sql_id = 'post_msg_id';
        break;

      Therefore, when you delete a primsg with msg_id=1234, it will call delete_attachments to delete the attachment in the post with post_msg_id=1234.

      This is in 3.0.4

            Acyd Burn Meik Sievertsen [X] (Inactive)
            robert3999 robert3999
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: