App for CloudflareĀ® Pro

App for CloudflareĀ® Pro 1.8.6

Several errors

Probably something that could be sent to the error logging system once I get that sorted out. Did I mention how dumb I think it is that WordPress has no internal error logging system? šŸ˜€
 
Ya, itā€™s pretty unbelievable how bad it is internally. Building this plugin for it brought me close to losing my mind. See this thread:

 
I found an image (HomerFacePalm-300x198.jpg) wasn't transferred to R2. Can you please advise if there is some log where I can see what images haven't been uploaded?
 
Is the file in your local filesystem still? There wouldnā€™t really be a way to log things that *didnā€™t* happen. Once a logging system is in place, we could log things that did happen or we could log things that tried to happen but failed.

For the failing part though, internally the mechanism that transfers a file to R2 will automatically retry if it fails for any reason. Not saying itā€™s impossible, but Iā€™ve yet to see an instance firsthand where something ended up not transferring on the automatic second attempt (it would be incredibly rare and the first thing Iā€™d look at would be underlying network issues with the server).

There is a general R2 log for all the things on Cloudflareā€™s side (they have no UI for it though). You can access it via the plugin on the R2 page in WordPress (clicking on class A and class B numbers for example).

It does seem like it would be a good idea to add ā€œvalidationā€ mode to the CLI migration tool where it spins through all the media that should be on R2 and validates that they are in fact there as well as all its variations. Iā€™m going to be away from an actual development computer for the next 48 hours though, but I could probably have something that does that on Thursday.
 
yes it is
Is the media flagged as being in R2 (orange cloud when browsing it in WordPress media system)?
yes but it doesn't display all the records, only the recent ones
Ya, itā€™s not particularly greatā€¦ their logging system is designed more for building specific queries and running those queries (itā€™s why Cloudflare itself doesnā€™t even let you see it in their normal dashboard).
 
Is the media flagged as being in R2 (orange cloud when browsing it in WordPress media system)?
the file was never transferred to r2 but it is on the file system. I ended up uploading it manually to R2 but it sucks because I'm finding there are other files which weren't transferred.
 
Last edited:
I found the WP plugins created files and folders in wp-content/uploads folder (filesystem) rather than R2 so I think placing the redirect rules in CloudFlare is risky when you are not relying on media files only.

I had to disable the CloudFlare redirect rule and I think the safest approach would be to modify the media urls in the database (pointing to wp-content/uploads and replace them by the External data URL. This would prevent breaking the plugins that rely on the filesystem.
 
Do you have an example of one of the plugins so I can go digging on it? It would be nice if they at least used a different prefix so someone could differentiate them.
 
Do you have an example of one of the plugins so I can go digging on it? It would be nice if they at least used a different prefix so someone could differentiate them.
Yes, none of the folders of the following plugins were uploaded to R2. In fact, I checked the filesystem and noticed the plugins created new folders in the upload folder (which shouldn't happen, they should be created in R2 instead):
1713375304596.png
 
Yes, none of the folders of the following plugins were uploaded to R2. In fact, I checked the filesystem and noticed the plugins created new folders in the upload folder (which shouldn't happen, they should be created in R2 instead):
View attachment 36
Ya, WordPress doesnā€™t have an abstracted filesystem like XenForo does, so we canā€™t just say everything going to the uploads folder goes to R2, instead we do need to hook into things upstream (which frankly is a pain in the ass), so the R2 stuff does work by hooking into the media system. Iā€™ll look at those when I get back to a computer and see if maybe itā€™s viable to hook into the individual plugins as well.
 
Ya, WordPress doesnā€™t have an abstracted filesystem like XenForo does, so we canā€™t just say everything going to the uploads folder goes to R2, instead we do need to hook into things upstream (which frankly is a pain in the ass), so the R2 stuff does work by hooking into the media system. Iā€™ll look at those when I get back to a computer and see if maybe itā€™s viable to hook into the individual plugins as well.
it's fine if the plugin files are being served from the file system but if the media files are being served from R2 their URLs across the database need to definitely be overwritten and pointed to r2
 
Question: is there any way to set a dynamic rule in CloudFlare that redirects the media to R2 only if the file requested is not inside a folder?
We have all the uploaded images inside the /uploads/ older and if I can exclude the requests made to subfolders (which are the plugins) then I guess I can keep the redirect in place and keep serving the uploads from R2
 
it's fine if the plugin files are being served from the file system but if the media files are being served from R2 their URLs across the database need to definitely be overwritten and pointed to r2
Not sure there's a realistic way to do it just for media if there's nothing differentiating media vs. other things based on the URL itself. I suppose one could go into the database and do a find/replace with a SQl query, but that's going to get sketchy and isn't necessarily going to handle everything (for example how would you handle a 3rd party site that references the old URL without having access to their database/HTML source?) But for posts within your own site, you could do that via SQL find/replace.

Question: is there any way to set a dynamic rule in CloudFlare that redirects the media to R2 only if the file requested is not inside a folder?
We have all the uploaded images inside the /uploads/ older and if I can exclude the requests made to subfolders (which are the plugins) then I guess I can keep the redirect in place and keep serving the uploads from R2
Ya, you should be able to since the expressions for Redirect Rules are fairly flexible. You would just need to know what to key on. If a "subdirectory" means it has more than certain number of slashes in the URI, you could key on that. Or maybe it simply doesn't start with "20" (media URIs normally start with the year... so anything that doesn't start with "20" would potentially cover any non-media that was uploaded since 2000). Really just depends on your site, how it's configured and what is unique about the URIs between media and third party plugin things that are uploaded into the uploads folder.
 
Not sure there's a realistic way to do it just for media if there's nothing differentiating media vs. other things based on the URL itself.
Well, Wordpress uploads the media in folders with the date (if it is set up in that way) or just in the /uploads folder. Anything else (not matching the date folders but matching other folder name) could be not modified

Not sure there's a realistic way to do it just for media
Well, right now I can't use R2 because any of my plugins don't create the files in R2 so I'm just in the middle and can't use R2 unless I have a Wordpress site with no plugins.

(for example how would you handle a 3rd party site that references the old URL without having access to their database/HTML source?)
If the referred url refers to a file inside /uploads folder or inside /uploads/year/month/ folder then redirect it to R2.
 
Well anything in /uploads/year/month/ is of course going to be in /uploads, so you could key on the URI starting with /uploads?
 
Well, right now I can't use R2 because any of my plugins don't create the files in R2 so I'm just in the middle and can't use R2 unless I have a Wordpress site with no plugins.
You should be able to minus the redirect part for old media, right? For example if you were to use it just going forward and not messing with old media (whereā€™d you need redirects), it should work (the way the system works, itā€™s not an either/orā€¦ some media can be local and some can be in R2).
 
so you could key on the URI starting with /uploads
Remember the problem is all plugins save their data on /upload/XXX (plugin name folder)
So you don't want to redirect to R2 those folders. Instead, you want to redirect to R2 only the files on /upload (root) or /uploads/year/month/ which are the media files.

Am I explaining better?
 
Last edited:
Back
Top