humanmade / S3-Uploads

The WordPress Plugin to Store Uploads on Amazon S3
1.92k stars 389 forks source link

Post-processing of the image failed #554

Open johanguse opened 2 years ago

johanguse commented 2 years ago

Hey I was stuck for two days in this erro. Any ideia how to fix? Is weird because my WordPress still showing that my Max Upload still 1 MB I'm using Docker with WP (Multisite / Network) 5.7.2 and S3 Uploads plugin is version 2.3.0

If I try to upload some media I got the error (wp-admin/async-upload.php 500 (Internal Server Error)) image

If I Trying by simple upload I got this Fatal error: Uncaught Error: Call to undefined function GuzzleHttp\Psr7\mimetype_from_filename() in /var/www/html/wp-content/plugins/S3-Uploads/inc/class-s3-uploads-stream-wrapper.php:193 Stack trace: #0 [internal function]: S3_Uploads_Stream_Wrapper->stream_flush() #1 /var/www/html/wp-admin/includes/file.php(930): move_uploaded_file('/tmp/phpOWB4vv', 's3://sandbox-co...') #2 /var/www/html/wp-admin/includes/file.php(1020): _wp_handle_upload(Array, Array, '2021-10-26 19:0...', 'wp_handle_uploa...') #3 /var/www/html/wp-admin/includes/media.php(303): wp_handle_upload(Array, Array, '2021-10-26 19:0...') #4 /var/www/html/wp-admin/media-new.php(33): media_handle_upload('async-upload', 0) #5 {main} thrown in /var/www/html/wp-content/plugins/S3-Uploads/inc/class-s3-uploads-stream-wrapper.php on line 193

I've try a lot of things from internet from increase uploads in php.ini to use use_gd_editor https://www.3ptechies.com/fix-post-processing-of-the-image-failed.html

This is my Media Handling Stuff Config
Active editor S3_Uploads_Image_Editor_Imagick
ImageMagick version number 1690
ImageMagick version string ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org
File uploads Enabled
Max size of post data allowed 256M
Max size of an uploaded file 128M
Max effective file size 128 MB
Max number of files allowed 20
GD version bundled (2.1.0 compatible)
Ghostscript version 9.2
My server Stuff Config
Server architecture Linux 5.4.129-63.229.amzn2.x86_64 x86_64
Web server Apache/2.4.38 (Debian)
PHP version 7.4.21 (Supports 64bit values)
PHP SAPI apache2handler
PHP max input variables 3000
PHP time limit 600
PHP memory limit 512M
Max input time -1
Upload max filesize 128M
PHP post max size 256M
cURL version 7.64.0 OpenSSL/1.1.1d
Is SUHOSIN installed? Não
Is the Imagick library available? Sim
Are pretty permalinks supported? Sim
.htaccess rules Custom rules have been added to your .htaccess file.
felipeelia commented 2 years ago

Unfortunately, we are having the same problem. Any suggestions on how to fix it? Thanks

tylercherpak commented 2 years ago

Hey y'all 👋 Is there any reason you don't include the composer.lock in the git repo? I think this might be caused by a not having the lock file and the combo of loosely defining the version with the ~ character. The ~ is great since it makes updating to minor version updates super easy but should be accompanied by the lock file to insure that only happens when you actual want to run composer update. Thanks for making such a great plugin for the community!! 😄

felipeelia commented 2 years ago

Chiming in again to second what @tylercherpak said and also to share a fix we came up with. Instead of simply calling composer install it seems that if we specify an older version of the AWS SDK, things work again: composer require aws/aws-sdk-php:"3.198.8" Thanks!

rmccue commented 2 years ago

@tylercherpak .lock files are for fully installable projects, rather than packages/plugins like S3 Uploads. They wouldn't have any affect when installing S3 Uploads via Composer.

If the issue is compatibility with newer versions of the SDK, then we do need to fix that. cc @joehoyle

tylercherpak commented 2 years ago

Hey @rmccue Thanks for the quick response. 😄 I think with the current set up, the plugin is going to auto-update the minor versions for the sdk whenever a new version is published. Which could cause issues if the sdk changes in an unexpected way.

If I understand correctly, you could change this to be able to handle compatibility issues with the sdk in a more manageable way if the version was a specific version. Thanks again for everything! 😄

rmccue commented 2 years ago

We'd want to change our version constraints to be something like ~1.2.3 <= 1.2.41 if there are compatibility problems with a specific version, rather than a lock file; but in either case, if it's broken, then that's a bug we have.

mindfullsilence commented 2 years ago

What's the current workaround to get the package back to working order?

ThyNameIsMud commented 2 years ago

Version 2.3.0 uses a deprecated function that was removed from the SDK.

https://github.com/humanmade/S3-Uploads/blob/2.3.0/inc/class-s3-uploads-stream-wrapper.php#L193

This line should read

($type = Psr7\MimeType::fromFilename($params['Key']))

Recommendation would likely be updating to package to the latest version, 3.0.3.

johanguse commented 2 years ago

Version 2.3.0 uses a deprecated function that was removed from the SDK.

https://github.com/humanmade/S3-Uploads/blob/2.3.0/inc/class-s3-uploads-stream-wrapper.php#L193

This line should read

($type = Psr7\MimeType::fromFilename($params['Key']))

Recommendation would likely be updating to package to the latest version, 3.0.3.

I can't install V 3.0.3 Already try a lot of things to fix this, but without success!

Your requirements could not be resolved to an installable set of packages.

  Problem 1

    - pcov/clobber v2.0.3 requires ext-pcov ^1.0 -> the requested PHP extension pcov is missing from your system.

    - pcov/clobber v2.0.2 requires ext-pcov ^1.0 -> the requested PHP extension pcov is missing from your system.

    - pcov/clobber v2.0.1 requires ext-pcov ^1.0 -> the requested PHP extension pcov is missing from your system.

    - pcov/clobber v2.0.0 requires ext-pcov ^1.0 -> the requested PHP extension pcov is missing from your system.

    - Installation request for pcov/clobber ^2.0 -> satisfiable by pcov/clobber[v2.0.0, v2.0.1, v2.0.2, v2.0.3].

  To enable extensions, verify that they are enabled in your .ini files:

    - /usr/local/etc/php/php-cli.ini

    - /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini

    - /usr/local/etc/php/conf.d/docker-php-ext-zip.ini

  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Running update with --no-dev does not mean require-dev is ignored, it just means the packages will not be installed. If dev requirements are blocking the update you have to resolve those problems.

The command '/bin/sh -c wget -O /tmp/S3-Uploads.zip https://github.com/humanmade/S3-Uploads/archive/3.0.3.zip &&   unzip -d /tmp/plugins /tmp/S3-Uploads.zip &&   mv /tmp/plugins/S3-Uploads-3.0.3 /tmp/plugins/S3-Uploads &&   cd /tmp/plugins/S3-Uploads &&   composer install --optimize-autoloader --no-dev -vvv' returned a non-zero code: 2

script returned exit code 2
ThyNameIsMud commented 2 years ago

@johanguse Platform requirements aren't being satisfied which given how you're using this plugin is probably intentional. Update your command to ignore them with the flag --ignore-platform-reqs:

/bin/sh -c wget -O /tmp/S3-Uploads.zip https://github.com/humanmade/S3-Uploads/archive/3.0.3.zip && unzip -d /tmp/plugins /tmp/S3-Uploads.zip && mv /tmp/plugins/S3-Uploads-3.0.3 /tmp/plugins/S3-Uploads && cd /tmp/plugins/S3-Uploads && composer install --optimize-autoloader --ignore-platform-reqs --no-dev -vvv

johanguse commented 2 years ago

@johanguse Platform requirements aren't being satisfied which given how you're using this plugin is probably intentional. Update your command to ignore them with the flag --ignore-platform-reqs:

/bin/sh -c wget -O /tmp/S3-Uploads.zip https://github.com/humanmade/S3-Uploads/archive/3.0.3.zip && unzip -d /tmp/plugins /tmp/S3-Uploads.zip && mv /tmp/plugins/S3-Uploads-3.0.3 /tmp/plugins/S3-Uploads && cd /tmp/plugins/S3-Uploads && composer install --optimize-autoloader --ignore-platform-reqs --no-dev -vvv

And now I get new error. Similar to this thread: https://github.com/humanmade/S3-Uploads/issues/530

Error: Callable "S3_Uploads\\WP_CLI_Command" does not exist, and cannot be registered as wp s3-uploads.

In the end I'll change the plugin, I can't handle this , too much error!

AndPicc commented 2 years ago

the problem seems to be that version 3.199.0 of aws-sdk-php is introducing support for guzzlehttp/psr7 version 2 and above, but the S3-Uploads versions 2* are not compatible with it.

The thing here is that S3-Uploads 2.3 is requiring aws-sdk in this way:

"aws/aws-sdk-php": "~3.18"

but technically it is not compatible with 3.199.0, hence that statement is incorrect and it causes the error reported in this thread.

I understand that version 3 is working just fine (indeed in my projects I have updated it), but I think you should probably release a patch for version 2 where you modify the composer.json to ensure that it doesn't pull an incompatible version of aws-sdk.

cheers!