cron jobs deleting image files in uploads folder
-
taken me days to find this, every day hundred of images have been deleted, found out its your cron job doing it
wp_scheduled_delete()
WPO\WC\PDF_Invoices\Main->attachments_cleanup()
-
Hi! I’m sorry to hear that. It’s pretty unlikely that this function is deleting your images, as it specifically targets PDF files (source) and only in the attachments subfolder folder of the PDF invoice temp folder (wp-content/uploads/wpo_wcpdf/attachments).
I may be missing something, but for as far as I can see regular images or anything outside of the plugin’s own temp folder can’t be affected by this. Could you share how you found this to be the culprit? If it is indeed this plugin I’ll do my best to help resolve this as quickly as possible.
I suspected that a cron job was deleting images, so I installed wcrontrol and looked at every cron job that was installed, and saw yours was using wp_scheduled_delete()
so I ran it, immediately the system started to delete image files from the uploads folder.
somehow thinking they were unattached.
I have disabled the cron job and also disbaled the 7 day cleanup.
there was a minor woocommerce update recently, and this has started happening since then
these images are in the uploads folder ordered by date
- This reply was modified 6 years, 5 months ago by k0872.
I suspected that a cron job was deleting images, so I installed wcrontrol and looked at every cron job that was installed, and saw yours was using wp_scheduled_delete()
so I ran it, immediately the system started to delete image files from the uploads folder.
somehow thinking they were unattached.
Did you run the entire
wp_scheduled_delete
action? There may have been other processes (indirectly) hooked into that as well.I have disabled the cron job and also disbaled the 7 day cleanup.
If you have a staging environment where you can test one of them disabled at a time, that would provide us with some more specific information. If you have disabled
wp_scheduled_delete
entirely any other process may be stopped as well so you still can’t be sure of anything. I understand you can’t do this on a live site though.there was a minor woocommerce update recently, and this has started happening since then
WooCommerce also has some cleanup functions since 3.4 but I don’t think they delete any files. Of course it may be possible that there’s another plugin hooking into any of the woocommerce privacy cleanup actions that also have been introduced recently.
these images are in the uploads folder ordered by date
Which should normally be separate from the PDF invoices temp folder unless you have made modifications to this. Again, my code only erases PDF files, and as far as I can see it can only do so in its own folder.
Let me know if the issue is resolved after disabling the 7 day cleanup (in the plugin settings, Status tab, I presume?), or if you find any additional leads to what may have caused this!
Could you post a screenshot of the locations of the temporary folders listed under WooCommerce > PDF Invoices > Status? You can mark out anything before ‘wp-content’ if you wish.
The central temp folder is /home/public_html/engine/wp-content/uploads/wpo_wcpdf/. By default, this folder is created in the WordPress uploads folder (/home/public_html/engine/wp-content/uploads/), which can be defined by setting UPLOADS in wp-config.php.
I ran from wpcrontrol
hook is
wp_scheduled_deletearguments is
Noneaction
wp_scheduled_delete()
WPO\WC\PDF_Invoices\Main->attachments_cleanup()
2018-06-16 13:41:23 (3 hours 34 minutes) Once Daily Edit | Run Nowwhen this is run, the images from the uploads folder delete.
- This reply was modified 6 years, 5 months ago by k0872.
so I disabled your plugin, and then ran the cron manually
wp_scheduled_delete None
wp_scheduled_delete()
2018-06-17 11:41:23 (2 hours 39 minutes) Once Daily
no images were deleted, if I enable your plugin and then run the same cron which is modified with your cron, it deleted hundreds of images..
I now have found what is deleting images, it may be a combination of your plugin and something else, but if I disable your plugin images do not get deleted.
I have changed the date in wp-config
define(‘EMPTY_TRASH_DAYS’, 3000 );
which may have fixed it
its all very odd
I have just run it with your plugin re activated and the good news is that no images were deleted..
so adding define(‘EMPTY_TRASH_DAYS’, 3000 ); or restoring the bin stopped it.
unfortunately our custom mods to the premium tmeplates need fixing since reactivating
I will in a few days be able to test deleting the line in the config and report the results.
Thanks for reporting! What you write actually sounds like the
wp_scheduled_delete
function is run and removing images belonging to posts (media library entries) that were already in the trash. That would explain why setting theEMPTY_TRASH_DAYS
to a 3000 days and/or restoring the trash would prevent the trash from being emptied (and images subsequently deleted).It still doesn’t explain why it deleted those images with the plugin activated and didn’t when it was reactivated later – I still have not been able to replicate this myself either (nor had any other reports of this).
unfortunately our custom mods to the premium tmeplates need fixing since reactivating
Let me know if you need more help with this – send us an email at [email protected] in that case because www.remarpro.com does not allow us to use these forums for supporting our premium extensions.
- The topic ‘cron jobs deleting image files in uploads folder’ is closed to new replies.