deliciousbrains / wp-amazon-s3-and-cloudfront

Automatically copies media uploads to Amazon S3 for delivery. Optionally configure Amazon CloudFront for even faster delivery.
https://wordpress.org/plugins/amazon-s3-and-cloudfront/
312 stars 150 forks source link

Bug: Can't select existing bucket because it contains an invalid character #612

Closed JimGeorge-Ogden closed 1 year ago

JimGeorge-Ogden commented 2 years ago

When setting up the new 3.02 version of WP Offload Media Lite, you are unable to select an existing bucket if the name does not meet the 'new' criteria for bucket naming that AWS changed many many years ago. I have a bucket that I use for 100's of sites to store the images in. This bucket was created way back in the day when Amazon allowed underscores in bucket names. This has since been disallowed.

In all previous versions of the plugin, I was still able to browse existing buckets and choose this bucket for use in the plugin. I was just settings up a new site for the first time since v3.xx was released and found that I can no longer do this. This needs to be permitted for people like me who have an old bucket that is grandfathered in so we can still utilize the plugin with our bucket.

Since there are multiple TBs of data in this bucket and the bucket is used by 100's of sites, moving this data to a new bucket that follows current naming conventions and updating all of the sites to point to the new bucket is clearly not an option. I'm sure I can pick a different bucket that is allowed and then change this in the database settings, but this is not ideal. I understand having to check for naming compliance when creating a new bucket, but this check should not come into play when selecting an already existing bucket.

To Reproduce Steps to reproduce the behavior:

  1. Install Plugin
  2. Go to 'Settings -> WP Offload Media'
  3. Select the 'Media' tab
  4. Click 'Use Existing Bucket'
  5. Select from the 'Browse existing buckets' option OR enter the name of an already created, grandfathered in bucket that has an illegal character by today's standards.
  6. See error message appear that says 'Invalid character. Bucket names can contain lowercase letters, numbers, periods and hyphens.'

Expected behavior As in previous versions, I expected the plugin to accept the bucket and continue on to the next step of the setup process.

Thank you for looking into this! Jim

ianmjones commented 2 years ago

Hi @JimGeorge-Ogden, that's an interesting bug you've found there!

Can you try using the AS3CF_SETTINGS define to set the bucket and its region and let me know whether that helps?

JimGeorge-Ogden commented 2 years ago

I still had an old version 2.6.2 still laying around. I installed it to select the bucket then upgraded to 3.0.2 and all is well. I can still test manually changing the bucket and region if you would like me to. Wasn't sure if that was just to get me going or curiosity on your part. Just let me know.

Thanks!

ianmjones commented 2 years ago

Wasn't sure if that was just to get me going or curiosity on your part.

Both! Hoped it would unstick you, but also wanted to know for sure whether it would help or not.

JimGeorge-Ogden commented 2 years ago

Defining the bucket and region in the wp-config did allow me to use the plugin. I set the bucket to one with a valid name. I was at the settings screen where it showed this bucket was the working bucket for the plugin. I then added the AS3CF_SETTINGS array to wp-config and went back to the settings page and hit refresh. It then took me to the storage settings which showed the bucket was defined in the wp-config file, however it wasn't totally obvious it worked at first. The 'Save Bucket Settings' button is grayed out so I didn't realize there was more for me to do.

After opening the main settings page in a new browser tab and realizing nothing changed - I went back to the original browser tab and I clicked ahead to the 'Security' tab where the 'Keep Bucket Security As Is' button was highlighted. Once I clicked that I was returned to the main settings page where it now showed the bucket I defined in wp-config was the working bucket for the plugin.

I then tested this by adding an image to the media library. The image and it's resized versions were successfully uploaded to the correct bucket. All seemed to work as intended. So yes, this solution will allow others with my problem to finalize the setup process until the bug is corrected in a future release. I'm sure everyone may not have an old version of the plugin laying around to use the method I did earlier.

Thanks for the assistance and for looking into this!

image

ianmjones commented 2 years ago

Thanks @JimGeorge-Ogden, good to hear that defines can be used as a workaround.

I'll raise an internal ticket for this to get it scheduled for dev.

Thanks again for taking the time to report the bug.

JimGeorge-Ogden commented 2 years ago

You are absolutely welcome! I appreciate your willingness to work with me to prove/solve this issue. Thank you for a fantastic product!

ianmjones commented 1 year ago

Fixed in 3.1.0

JimGeorge-Ogden commented 1 year ago

Awesome! Thank you for handling this Ian.

Also, by great coincidence, I just so happened to be setting up a new WordPress site this morning. I installed version 3.1.0 and I can confirm that the fix does indeed allow me to select my bucket with an 'invalid' character now. After setting up the plugin I added an item to the media library and all worked as expected.

Again, appreciate the help with this. This plugin is absolutely invaluable. 👍