App for Cloudflare® Pro

App for Cloudflare® Pro 1.8.9

New R2 storage issue

moonlike1871

New member
After a while of not publishing anything new on the site, we just started to write some new content.

However, it looks like something isn't right with our R2 deployment. First, adding new media results in blank thumbnails on the media page:
1746624628613.png

None of my media files show a URL for static.domain.com anymore - they are all using my regular domain.com. I'm certain that the URLs have been using the "static" domain previously and have no idea when they would have reverted.

The site isn't broken because I have Cloudflare forwarding /wp-content/uploads to my R2 bucket, but media uploads aren't working correctly and all of the old URLs have reverted back to domain.com.

I'm not sure where to start on troubleshooting. The Migrate Existing Media doesn't show anything to migrate. If I browse my R2 bucket, there are files there in multiple sizes as I'd expect. When I upload a new image, it appears in R2 without having to use the Migrate Existing Media button. But none of my media library thumbnails are showing and the URLs are not referencing the R2 site.

The thumbnails are receiving a 404 error when trying to access them (note that this is not the "static" URL, but the naked domain - but the redirect works fine and matches the URL that Cloudflare lists in the R2 bucket for the image):
1746625758484.png

Despite the fact that they are clearly in the bucket:
1746625776164.png

Can you point me in the right direction to troubleshoot?
 
If you look at your Cloudflare settings page (the same place that you enter your API Token), what is the External data URL set to?

It almost sounds like that setting may have been removed/cleared out (if it doesn’t know what the URL of your public bucket is, it can’t point anything to it).
 
The external data URL is still set to the normal static.domain.com entry. All of my old media is still normally accessible at this domain as well (since I have the entire /wp-content/uploads directory forwarded, my site would be very broken if the old media were returning a 404 from Cloudflare):
1746628113205.png

(note, you are welcome to look at any of the URLs directly, I'm just avoiding posting them in the public forum - let me know if you need to see anything)
 
As far as you can tell, is everything working except the bucket URLs aren't being used? Like uploading a new media item does result in it landing in the R2 bucket?

This is the exact logic it uses to decide when to transform what is normally a local URL into the external/bucket URL:
  1. R2 itself needs to be enabled (and on the R2 settings page, you should have the bucket name set).
  2. The media item must be flagged as being in R2 (if you click one of the media to view the details about it, right under Uploaded by there should be Stored in R2 (will be Yes or No).
  3. R2 location needs to be set (under the same Stored in R2 line... should be Site bucket if it's an individual site).
  4. External data URL needs to not be blank (you already checked that), as you can't point to a URL if we don't know the URL itself.
If all that seems to be okay/as expected, I suppose it's possible that a third-party plugin may be overriding the output of WordPress' wp_get_attachment_url filter, but can't really think of a reason one would do that. Have you installed any new plugins that do anything with media by chance?
 
As far as you can tell, is everything working except the bucket URLs aren't being used? Like uploading a new media item does result in it landing in the R2 bucket?

I'm not quite sure what's happening, to be honest.

I just uploaded a new media file to Wordpress. Upon uploading, the thumbnail is blank. When I check R2, there is nothing there. The migration didn't happen automatically.

If I go to Migrate Existing Media, I see that there is one that hasn't been migrated and a lot that have:
1746638089965.png

If I click the Migrate button, the file appears in Cloudflare:
1746638334149.png


But it doesn't appear in Wordpress - also note that there is no indication of migrated or not here, or a storage bucket, and the URL still is domain.com instead of static.domain.com:
1746638255426.png

The image which is uploaded is also not publicly accessible - you get a 404 if you try to access the R2 storage URL for that image (by which I mean you can actually look up the URL in the Cloudflare UI and try to access it, and get a 404 - so there is no chance of a mistype here):
1746638493144.png

The last part doesn't make sense to me because every other item in that storage bucket is just fine; it's accessible to the outside world. It's only newly added/migrated items that are getting a 404.

None of the existing media have the "Uploaded to R2" or storage bucket indicators on their media pages.

I did a full review of my plugins, there is only one new plugin (which is just a lightbox plugin) but disabling it doesn't change any of the above behavior. R2 is turned on, the bucket is correctly identified, and the R2 URL is correct.
 
Last edited:
I know this is going to seem like a random question, but it's not... In your WordPress admin, in the navigation area on left side, under Cloudflare, what's the last item in that section (should be either Settings or Backup / restore)?

If you have access to phpMyAdmin or MySQL and you are able to run a query, can you check to see what the option_value is for the record you get with this query?

SQL:
SELECT * FROM `wp_options` WHERE `option_name` = "_transient_acf_int"
 
The last item is Settings.

Code:
+-----------+--------------------+----------------------------------------------------------------------------------+----------+
| option_id | option_name        | option_value                                                                     | autoload |
+-----------+--------------------+----------------------------------------------------------------------------------+----------+
|   1184092 | _transient_acf_int | a:4:{s:1:"d";i:1742392035;s:1:"l";s:5:"1.8.9";s:1:"u";i:10;s:1:"v";s:5:"1.8.6";} | on       |
+-----------+--------------------+----------------------------------------------------------------------------------+----------+
1 row in set (0.000 sec)
 
So it appears that something is going on with WordPress transients in your setup (not sure what... but *something*).

That transient record hasn't been updated since about 6 weeks ago (March 19), but it should be updated *far* more recently. Did you change anything with your server around that time?

If you look in your WordPress wp-content folder, is there a file named object-cache.php? If someone moved transients out of the database and into something like Memcached or Redis, that file would be there (if it's not there, it still should be using the database for transients).
 
There was, indeed, an object-cache.php. I had W3 Total Cache installed but it's been deactivated for... like, ever. I'm not sure when I used it last. Definitely a lot longer than 6 weeks ago so I'm not sure what happened 6 weeks ago.

However, the object-cache.php was there. I removed it and deleted the deactivated cache plugin and nearly everything is back to normal - at least the static.domain.com URLs are back, the media transfer status is back, the bucket information is back. THANK YOU!

I'm still having intermittent issues with 404 errors from the thumbnails, though, which I've never seen before. This seems (?) to only happen on bulk uploads but it's hard to tell - I keep testing and haven't had it occur on an individual upload.

The file uploads in the media library successfully, I can see the status looks okay:
1746649263642.png

The image thumbnail in the media library is blank, though. If I inspect the thumbnail and grab the URL for the image, and I go into R2, it's there:
1746649302301.png

But accessing the R2 URL (the one published in Cloudflare) gives me a 404 error. If I use the download link in the media page, it downloads a happy image, I just can't access it:
1746651797285.png

I mean, this certainly - at first glance - looks like it's not a plugin issue since the file is there, and Cloudflare is giving me a 404 for a link that it provides me itself, but I can't replicate it with direct R2 uploads - only when the automatic transfer happens in the plugin.

Happy to take this to the Cloudflare forums to seek advice as well. I do appreciate the time you take to help your customers.
 
Last edited:
I have a theory that something that was happening earlier while the object cache was effing things up was causing issues. I was having repeated issues with the missing thumbnails, but only on the one batch of pictures that I kept trying to upload - subsequent batches don't yet display this behavior.

Don't do anything on this if you were going to look into it. Again, it sure seems like a Cloudflare problem not a plugin problem.
 
Do you have a URL that's giving you a 404 that you could share? Was just going to say, I bet it's Cloudflare's cache. If you flush your browser cache and purge Cloudflare's cache for the zone and it magically starts working, you'll know that was it.
 
Forgot to mention (just in case you or anyone else wants to use a third-party object storage system (what that object-cache.php file does)... You *can* in fact do it, as long as it works. I use it on my sites (uses Memcached for the object cache). But if whatever it's using on the backend (in my case, Memcached) is down or something else about it isn't working as expected, you would lose a bunch of critical functions in WordPress (like transients).

TL;DR: you can use third-party object caches, but they *do* actually need to work.
 
Back
Top