Can't delete attachments

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Darksome
    New Member
    • Apr 2011
    • 9
    • 4.1.x

    [Forum] Can't delete attachments

    Hi!

    Here's a problem I've just noticed and would like some assistance with. I pruned some threads yesterday and when doing a routine site backup today expected to see the associated attachments with those threads also deleted, however this wasn't the case. They were still on the server in the file-system (where I'm storing attachments).

    I've tried manually deleting attachments through the AdminCP > Attachments > Search and then deleting them and this also fails to delete the attachments fully. I've also tried deleting them through the UserCP > Settings > Miscellaneous > Attachments this also fails to delete the attachments. They are removed from the thread and upon checking they're no longer in the attachments table in the database, but they remain on both the server and in the filedata table in the database.

    How the heck do I physically remove these attachments from vB and thus the file system? I'm basically trying to prune old threads and have any attachments associated with them also removed completely from vB and the file system!
  • Trevor Hannant
    vBulletin Support
    • Aug 2002
    • 24358
    • 5.7.X

    #2
    What version are you running?
    Vote for:

    - Admin Settable Paid Subscription Reminder Timeframe (vB6)
    - Add Admin ability to auto-subscribe users to specific channel(s) (vB6)

    Comment

    • Darksome
      New Member
      • Apr 2011
      • 9
      • 4.1.x

      #3
      I'm running 4.1.4 PL2

      Comment

      • Trevor Hannant
        vBulletin Support
        • Aug 2002
        • 24358
        • 5.7.X

        #4
        Is your Hourly Cleanup 2 Scheduled task running OK?
        Vote for:

        - Admin Settable Paid Subscription Reminder Timeframe (vB6)
        - Add Admin ability to auto-subscribe users to specific channel(s) (vB6)

        Comment

        • Darksome
          New Member
          • Apr 2011
          • 9
          • 4.1.x

          #5
          I've tried running it manually a few times already and checked the logs and it says completed.

          Comment

          • Trevor Hannant
            vBulletin Support
            • Aug 2002
            • 24358
            • 5.7.X

            #6
            D'oh. Sorry, I never picked up on this from your original post...

            The cleanup jobs only deletes the relevant database entries for the attachments, not the files themselves if you're storing in the filesystem (vBulletin has never done this). I believe there's a request in the Tracker to add this functionality however I can't find it at the moment.
            Vote for:

            - Admin Settable Paid Subscription Reminder Timeframe (vB6)
            - Add Admin ability to auto-subscribe users to specific channel(s) (vB6)

            Comment

            • Darksome
              New Member
              • Apr 2011
              • 9
              • 4.1.x

              #7
              Wow, really? So there's no way of deleting those, now orphaned, attachments through vB?

              Comment

              • AusPhotography
                Senior Member
                • Nov 2007
                • 1552

                #8
                Originally posted by Trevor Hannant
                D'oh. Sorry, I never picked up on this from your original post...

                The cleanup jobs only deletes the relevant database entries for the attachments, not the files themselves if you're storing in the filesystem (vBulletin has never done this). I believe there's a request in the Tracker to add this functionality however I can't find it at the moment.
                Incorrect. I've been conversing with Darksome and setup a test on our site, the files are deleted.

                Refer class_dm_attachment.php and vB_DataManager_Filedata public function delete

                Our site is forum only, whereas Darksome is running Suite.

                He ran this and got many records...

                Code:
                SELECT filedata.filedataid, filedata.userid
                  FROM filedata 
                  LEFT OUTER JOIN attachment ON attachment.filedataid = filedata.filedataid 
                  WHERE attachment.filedataid IS NULL
                So unless there is an issue in suite it should work.

                BTW: Darksome and I live in the same city and are friends.

                Kym
                environment: Centos 6.9, Apache v2.4.25, PHP 5.6.30/xCache, MariaDB 10.22 -- vB5 Connect Licensed

                AusPhotography - Australia's Premier Photographic Forum vB4.2.3
                Rick (site owner) and Kym (site tech) sharing this account

                Comment

                • Hawk2
                  Senior Member
                  • Apr 2008
                  • 862
                  • 4.1.x

                  #9
                  if the attachments are from your own profile then just go to your settings and delete them from there

                  Comment

                  • Darksome
                    New Member
                    • Apr 2011
                    • 9
                    • 4.1.x

                    #10
                    Originally posted by Hawk2
                    if the attachments are from your own profile then just go to your settings and delete them from there
                    That's not what I'm trying to do. In fact, doing that just results in the same problem. As I mentioned in the OP I'm pruning old threads and hopefully their associated attachments. These aren't being removed from the filedata table and as a result, not from the filesystem either. Even deleting my own attachments results in the same behaviour, the attachment is removed from the attachment table in the database but NOT the filedata table nor the file itself.

                    As per Kym's testing in the above post, I can confirm I've also tested this on a clean install (vB Suite 4.1.4 PL2) and it does delete the attachments from the filesystem! I haven't got any modified php files, I've tried disabling ALL plugins and products and have also created a new style with no parent style... it still won't delete attachments from the filedata table nor file system. I have noticed that there is an extra field in the filedata table for importedattachments as we migrated from phpBB3 into vB, I don't know if this is what's causing the problem?

                    I've tested a copy of our site at home for testing purposes and once again, the result is the same, it is only removed from the attachment table in the database. THIS REPORT sounds like the exact problem I'm experiencing.

                    Comment

                    • Hawk2
                      Senior Member
                      • Apr 2008
                      • 862
                      • 4.1.x

                      #11
                      And have you tired to delete them from inside the admin panel as this works for me or login to ftp and remove them from there

                      Comment

                      • Darksome
                        New Member
                        • Apr 2011
                        • 9
                        • 4.1.x

                        #12
                        Originally posted by Hawk2
                        And have you tired to delete them from inside the admin panel as this works for me or login to ftp and remove them from there
                        Originally posted by Darksome
                        I've tried manually deleting attachments through the AdminCP > Attachments > Search and then deleting them and this also fails to delete the attachments fully. I've also tried deleting them through the UserCP > Settings > Miscellaneous > Attachments this also fails to delete the attachments. They are removed from the thread and upon checking they're no longer in the attachments table in the database, but they remain on both the server and in the filedata table in the database.
                        Yes I have. Of course I can login to ftp and remove them, but this isn't how it should work. I've got 300+ orphaned attachments that have relevant entries in the filedata table that aren't present in the attachments table that should be being deleted by cleanup2.php each hour that aren't!

                        Finding those 300+ entries from the filedata table then manually matching them to files on the server and then manually deleting is just a little tiresome when it should be done automatically!

                        Comment

                        • Andy
                          Senior Member
                          • Jan 2002
                          • 5886
                          • 4.1.x

                          #13
                          Originally posted by Darksome
                          As per Kym's testing in the above post, I can confirm I've also tested this on a clean install (vB Suite 4.1.4 PL2) and it does delete the attachments from the filesystem! I haven't got any modified php files, I've tried disabling ALL plugins and products and have also created a new style with no parent style... it still won't delete attachments from the filedata table nor file system. I have noticed that there is an extra field in the filedata table for importedattachments as we migrated from phpBB3 into vB, I don't know if this is what's causing the problem?
                          Have you tried creating a clean install, then upgrading your database?

                          Comment

                          • AusPhotography
                            Senior Member
                            • Nov 2007
                            • 1552

                            #14
                            Try deleting the Impex import columns - they are not needed
                            environment: Centos 6.9, Apache v2.4.25, PHP 5.6.30/xCache, MariaDB 10.22 -- vB5 Connect Licensed

                            AusPhotography - Australia's Premier Photographic Forum vB4.2.3
                            Rick (site owner) and Kym (site tech) sharing this account

                            Comment

                            • AusPhotography
                              Senior Member
                              • Nov 2007
                              • 1552

                              #15
                              As I said above, this query shows the orphaned entries. (now enhanced)

                              Maybe dump the first 10 rows of data and post here, that way we can see what is happening.

                              I'm interested to see if the refcount is zero.

                              Code:
                              SELECT filedata.filedataid,
                                     filedata.userid,
                                     DATE_FORMAT(FROM_UNIXTIME(filedata.dateline), '%Y-%m-%d %H:%i:%s' ) AS DateLine,
                                     DATE_FORMAT(FROM_UNIXTIME(filedata.thumbnail_dateline), '%Y-%m-%d %H:%i:%s' ) AS Thumbnail_Dateline,
                                     filedata.filesize,
                                     filedata.filehash,
                                     filedata.thumbnail_filesize,
                                     filedata.extension,
                                     filedata.importattachmentid,
                                     filedata.width,
                                     filedata.height,
                                     filedata.thumbnail_width,
                                     filedata.thumbnail_height,
                                     filedata.refcount 
                                FROM filedata 
                                  LEFT OUTER JOIN attachment ON attachment.filedataid = filedata.filedataid 
                                WHERE attachment.filedataid IS NULL
                              environment: Centos 6.9, Apache v2.4.25, PHP 5.6.30/xCache, MariaDB 10.22 -- vB5 Connect Licensed

                              AusPhotography - Australia's Premier Photographic Forum vB4.2.3
                              Rick (site owner) and Kym (site tech) sharing this account

                              Comment

                              Related Topics

                              Collapse

                              Working...