Server Information
osTicket Version v1.16.1 (b42ddc7)
Web Server Software Apache/2.4.53 (Debian)
MySQL Version 10.5.15
PHP Version 8.1.4

I've had a problem recently where the database got too large to contain any more attachments. Whilst the tickets came through the attachments failed. I've moved the attachments out of the database into a separate directory and migrated the files over into this folder.

However, with the ones that are missing the database still seems to think they are there. I ran sudo -u www-data php manage.php file migrate --backend D --to F and get IOErrors as it can't find the files. I've gone through the tickets, removing some of the corrupt attachments manually and this appears to have reduced the amount of IO errors. There's just two left which give "Unable to read from file".

Is there an easy way to purge these from the database or am I stuck to going through all the tickets?

  • For info. I managed to fix it by finding the offending ticket and deleting it. I did a search as below on the file attachment which gave me more detail. As it was an old ticket I just deleted that one in osTicket. Re-ran the migration and no more errors.

    mysqldump -u "databaseuser" --skipextended-insert "databasename" | grep --color=auto -w "attachmentname"

@northernnoel

For one you are using PHP 8.1 which is not supported at all. v1.16.1 requires PHP 8.0. So make that change first. Also, make sure you downloaded and installed the latest version of the plugin from our website as they will have PHP 8.0 support.

To answer your question as long as you know which files you want to remove you can delete the ost_file record, any related ost_file_chunk records, any related ost_attachment records, and if they were images used inline then you will need to do a search in the thread entries table for the file keys and remove the img tags.

The best way to go about deleting orphaned files is to setup a cron job. We have a Cron Task that purges any files that are no longer used. However seeing as you said they are attached to tickets they might not be seen as "orphaned'.

Cheers.

Thanks Kevin, that's interesting I updated to v1.16.1 and PHP 8.1 to see if it fixed the issue initially. Originally it was on PHP 7.4 which gave the warning and said to update to at least PHP 8.0. As 8.1 is a later edition I opted for that and it gave the green tick for the upgrade.

I'll have a search through the database for those and see if I can clean it up.

For info. I managed to fix it by finding the offending ticket and deleting it. I did a search as below on the file attachment which gave me more detail. As it was an old ticket I just deleted that one in osTicket. Re-ran the migration and no more errors.

mysqldump -u "databaseuser" --skipextended-insert "databasename" | grep --color=auto -w "attachmentname"

Write a Reply...