Fails to write to object store with media_handle_sideload
traed opened this issue · 2 comments
We're importing data from a third party in a cron job and use media_handle_sideload
to import images. This has worked fine in the past but about a week or two ago it stopped working. As far as I can tell images are imported to WP and posts are created just fine but the image doesn't exist in our object store and therefore fails to load when displaying the content.
The attachments in WP looks fine though. They have URL:s pointing to the object store (Google Cloud Storage) for the main image as well as thumbnails along with meta data such as file size, but when following these URL:s they point to nothing (and of course the bucket is empty when checking in google cloud console).
We don't get any errors in the logs as far as I can see and uploading files directly to the WP media library works fine.
We're using stateless mode and have the latest version of the plugin. Any ideas on what might cause this?
Update: Seems like the images are deleted as soon as they are uploaded to the bucket. I added soft-delete policy to the bucket and now I can see the files as deleted. "Delete GCS File" is disabled in the plugin settings if that matters. What's going on?
Something on this line goes wrong. $img['path']
points to a resource in cloud storage, not on disk, so it appears to delete the file from the bucket instead of the disk? If I set the filter wp_stateless_skip_remove_media
to return true it seems to work better, but why would I need to do this? Surely it can't be intentional to delete files from the bucket when uploading them?