10up / windows-azure-storage

Use the Microsoft Azure Storage service to host your website's media files.
https://wordpress.org/plugins/windows-azure-storage/
BSD 2-Clause "Simplified" License
62 stars 46 forks source link

WP 6.2.2 error #184

Closed jperalesHogarth closed 2 months ago

jperalesHogarth commented 1 year ago

Describe the bug

Hello, thank you for this awesome plugin, I've found some issues with image uploading with this:

PHP: 8.2 WP: 6.2.2

I'm able to sync previous images with Azure, but can't add more images to Azure when I activate the Azure's plugin.

1172 line is about array_flip, but I'm pretty sure that the error is related with next line where blob returns an error.

I hope you can help me!

Steps to Reproduce

Try to upload a photo to media library. After configuration.

Screenshots, screen recording, code snippet

Stack trace:

0 /home/ubuntu/environment/project/wp-content/plugins/windows-azure-storage/includes/class-windows-azure-rest-api-client.php(1172): array_flip()

1 /home/ubuntu/environment/project/wp-content/plugins/windows-azure-storage/includes/class-windows-azure-rest-api-client.php(868): Windows_Azure_Rest_Api_Client->_sanitize_remote_paths()

2 /home/ubuntu/environment/project/wp-content/plugins/windows-azure-storage/includes/class-windows-azure-helper.php(449): Windows_Azure_Rest_Api_Client->sanitize_blobs_names()

3 /home/ubuntu/environment/project/wp-content/plugins/windows-azure-storage/windows-azure-storage.php(614): Windows_Azure_Helper::get_unique_blob_name()

4 /home/ubuntu/environment/project/wp-includes/class-wp-hook.php(308): windows_azure_storage_wp_handle_upload_prefilter()

5 /home/ubuntu/environment/project/wp-includes/plugin.php(205): WP_Hook->apply_filters()

6 /home/ubuntu/environment/project/wp-admin/includes/file.php(810): apply_filters()

7 /home/ubuntu/environment/project/wp-admin/includes/file.php(1082): _wp_handle_upload()

8 /home/ubuntu/environment/project/wp-admin/includes/media.php(303): wp_handle_upload()

9 /home/ubuntu/environment/project/wp-admin/includes/ajax-actions.php(2598): media_handle_upload()

10 /home/ubuntu/environment/project/wp-admin/async-upload.php(33): wp_ajax_upload_attachment()

11 {main}

thrown in /home/ubuntu/environment/project/wp-content/plugins/windows-azure-storage/includes/class-windows-azure-rest-api-client.php on line 1172

Environment information

PHP: 8.2 WP: 6.2.2

WordPress information

6.2.2

Code of Conduct

andreadistefano commented 1 year ago

I think I found the same bug. Same versions of PHP and WP.
I am not sure as I can't find a way to get to the stack trace in the logs, but still the plugin is not uploading pictures to the storage.

mayendrams commented 1 year ago

PHP: 8.2.0 WP: 6.2.2

Same versions of PHP and WP. Running on local machine with azurite blob storage emulator. Found the same issue.

Fatal error: Uncaught TypeError: array_flip(): Argument #1 ($array) must be of type array.

I think it is around $remote_paths = array_flip( $group_contents ); When I add condition to ignore that, the file seems successfully uploaded on the UI(because the url is generated on Media Library) but it never reached to blob storage and the filenames added randomly. For example: -64d0a85ca3319–64d0a85ca331flogo.png URL : http://127.0.0.1:10000/devstoreaccount1/content/2023/08/:64d0a85ca3319-64d0a85ca331flogo.png.png

jhessfaith commented 1 year ago

if ( is_wp_error($group_contents) ){ echo $group_contents->get_error_message(); die; } I added this above line 1172 in order to see what was causing this issue for me and got a result of forbidden.

If you trace the code back, it was coming from the call Windows_Azure_Helper::wp_upload_dir.

For me it turned out to be an authentication issue to the container. There was a misspelling in my account key.