View Full Version : Attachments have been deleted vb 4.2.3
dariyos
09-14-2015, 05:58 AM
Hello,
wrong uploaded attachments have been deleted and will delete in future and I don't know why.
Over 12.000 Files in Filesystem and Database deleted already!
An attachment from friday is also deleted.
you can see here in post #3:
http://www.sps-forum.de/codesys-und-iec61131/78790-verstaendnisfrage-schrittkette-verschachtelt-schrittkette.html
It shows only the text:
Attachment (ID)
I know, that the attachments will be delete automatically (after upgrading to vb 4.2.3), when the refcount value of filedata entry is null - but I don't know why so many files had the refcount value 0, and why I get more "wrong uploaded attachments".
maybe there are problems with the filemanager since the upgrade?
today I will correct the values from an older Database, and copy the entrys to the actual database and upload the attachments from an backup, again.
I don't want that they will be delete in the future and get the wrong refcount value.
How is it possible to upload an attachment WRONG, that it get the value 0 and be deleted?
I don't have any Image/Attachment-Upload Plugins installed ...
What can be the issue?
PHP 5.4.42-nmm1
Mysql Version 5.6.24-nmm1-log
vb 4.2.3
squidsk
09-14-2015, 01:28 PM
See my posts in https://vborg.vbsupport.ru/showthread.php?t=319394
Basically, it is or was possible to incorrectly attach attachments, but due to a bug in vb they weren't deleted. That bug was fixed in vb4.2.3 and following that all the incorrectly attached attachments started getting deleted.
dariyos
09-14-2015, 11:15 PM
I dont think that I had 12,000 incorrect attached attachments from 22,000 total attachments...
RichieBoy67
09-15-2015, 01:49 AM
I just noticed the same issue on my site though I am not sure if related to that. I know that when I ran an update counter I saw attachments being removed so I stopped it. I am not sure how many attachments I lost but mostly very, very old ones.
I can still see the attachments in the database though the id is missing. I replace the id from a back up and the attachment still does not show so I am assuming the files were deleted as well. Is this possible? Would the counter delete the attachment file or is there another reason the attachment would not show when all the data is there in the attachment table?
dariyos
09-15-2015, 01:59 AM
I think it is a big bug!
Can't resore the attachments, most of the attachments were online, 1 month ago.
this update deletes all attachments when the refcount value is 0 from the file system and the entries in the database. (I don't know how 12,000 files can get this value)
I stopped the cleanup2.php script now, but its to late.
It is not possible to restore the files, you need all files and entries from database, too.
you have informations about attachments in the tables
- post
- thread
- attachment
- filedata
Ich have backups from all, database and filesystem, but for me it is not possible to restore all attachments.
RichieBoy67
09-15-2015, 06:38 AM
Yes, in my case I think I may just be missing the filedata data.
Zachery
09-15-2015, 10:58 PM
If refcount is 0, the attachment is not being used, and should be removed.
TheLastSuperman
09-15-2015, 11:33 PM
^ What Zachery is trying to convey is that, if the refcount is zero it means that the attachment is not being referenced i.e. used in any posts therefor it deletes them due to that fact alone. Why retain an old attachment (especially if storing attachments in filesystem which takes up more disk space) if its not being called by a page/post? It's basically like leaving tons of old recipes in your cook book despite having a new version on your tablet at a touch of a finger... in a sense if you followed my odd analogy lol! The script (update counter) is doing what it needs to do, if however something is in fact very odd about your attachments this might be something unrelated entirely or if related perhaps an issue with your single site alone, that we're unsure of so we cannot comment regarding that only what we know it should be doing.
dariyos
09-18-2015, 05:39 AM
I know what refcount 0 is, but I don't think I had 50 % of attachments that are not used in posts.
5 % is okay, but not 50 %, it is not impossible!
I had restored all my attachments, I correct the value of refcount and set the value to 1 where attachments used in posts...
It was definitly a WRONG that they had the refcount value 0. And I still don't know why they got this value.
RichieBoy67
09-18-2015, 08:01 AM
I know what refcount 0 is, but I don't think I had 50 % of attachments that are not used in posts.
5 % is okay, but not 50 %, it is not impossible!
I had restored all my attachments, I correct the value of refcount and set the value to 1 where attachments used in posts...
It was definitly a WRONG that they had the refcount value 0. And I still don't know why they got this value.How did you fix this?
puertoblack2003
09-19-2015, 02:30 AM
I know what refcount 0 is, but I don't think I had 50 % of attachments that are not used in posts.
5 % is okay, but not 50 %, it is not impossible!
I had restored all my attachments, I correct the value of refcount and set the value to 1 where attachments used in posts...
It was definitly a WRONG that they had the refcount value 0. And I still don't know why they got this value.
I had the same issue, but with my issue was the filedata in database was someone how deleted.Lucky i had backups and it was just as simple and as to restore it.
squidsk
09-21-2015, 12:57 PM
I had the same issue, but with my issue was the filedata in database was someone how deleted.Lucky i had backups and it was just as simple and as to restore it.
That's what happens with this bug, is that the filedata, and filecontent, get deleted. You were lucky and had a backup to go back to.
--------------- Added 1442848959 at 1442848959 ---------------
How did you fix this?
You'd want to run a script that goes through each non-zero refcount filedata and looks in the corresponding table(s) to determine the actual usage count for the filedata.
I tried to post a bit of sample code but vb.org kept hanging when I hit post.
dariyos
09-28-2015, 08:02 AM
first step:
uncomment /includes/cron/cleanup2.php
// Unused filedata is removed after one hour
//$attachdata =& datamanager_init('Filedata', $vbulletin, ERRTYPE_SILENT, 'attachment');
//$attachdata->set_condition("fd.refcount = 0 AND fd.dateline < " . (TIMENOW - 3600));
//$attachdata->delete(true, false);
2) restore a old DB in a testforum
3) search for all entrys where the attachments was assigned a post with this query:
SELECT * FROM post a, attachment b, filedata c WHERE c.refcount =0 AND a.postid = b.contentid AND b.filedataid = c.filedataid
3) Update the refcount value from 0 to 1.
4) Search for the newest IDs from the tables (testforum):
-post
-attachment
-filedata
-thread
5) Search for the IDs (in acutal DB) bigger (>) than the IDs from testforum in:
-post
-attachment
-filedata
-thread
6) export the "new" entrys (bigger (>) than newest ids from testforum) from these tables.
8) Import the new entrys in testforum.
then you have all the entrys from old database and new database mixed and the right refcount value.
9) export the mixed tables
-post
-attachment
-filedata
-thread
from testforum
10) import it to actual db.
11) upload all deleted files in your filesystem
BACKUP FIRST, IF SOMETHING WENT WRONG!
squidsk
09-28-2015, 01:56 PM
The above is not complete as it will only check post attachments. There are other content types that can be stored in the filedata table which might be where the filedata is actually being used. Albums are one that comes to mind, but potentially any mod you have that allows uploads might have added a new content type.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.