Open korridor opened 3 years ago
Given what @modelm is experiencing in #519, the given solution might not be the best idea.
Maybe it would be a good idea to add a constant like S3_UPLOADS_COMPOSER
to decide whether autoload.php
should be required or not.
Experiencing the same issue with the same steps.
If the maintainers are open to the solution with the constant, I would be happy to provide a pull request.
Same here.
I think that would be more self-contained if added directly into the plugin functions.php ... something like proposed by @korridor
// wp-content/plugins/s3-uploads/s3-uploads.php
if ( ! class_exists( '\\Aws\\S3\\S3Client' ) ) {
// Require AWS Autoloader file.
require_once dirname( __FILE__ ) . '/vendor/autoload.php';
}
was getting the following error
Error: Callable "S3_Uploads\WP_CLI_Command" does not exist, and cannot be registered as wp s3-uploads
.
Added the class_exists() code to s3-uploads.php - this fixed the error
Happened to me as well when I tried to install the plugin using WPCLI
wp plugin install "https://github.com/humanmade/S3-Uploads/archive/refs/tags/3.0.3.zip" --force
$ wp plugin list
+--------------------------+----------+-----------+------------+
| name | status | update | version |
+--------------------------+----------+-----------+------------+
| query-monitor | inactive | available | 3.6.7 |
| S3-Uploads | inactive | none | 3.0.0-beta |
+--------------------------+----------+-----------+------------+
$ wp plugin activate S3-Uploads
Error: Callable "S3_Uploads\\WP_CLI_Command" does not exist, and cannot be registered as `wp s3-uploads`.
Also, the version name is not correct.
This is happening on all v3 releases.
Hi @korridor
I fixed it by moving the following code to the begin of the s3-uploads.php file.
I did the same but fyi I had to adjust the file path.
require_once __DIR__ . '/vendor/autoload.php';
It seems like this plugin is no longer maintained ... not good.
Tagging @kovshenin for visibility on this duplicate issue as well as he seems to be the only one looking at issues recently.
Steps to reproduce
Given a wordpress instance without another plugin that provides a
\Aws\S3\S3Client
class.composer install
wp-content/plugins
folder of your wordpress instanceNow everything works fine, but if I run any wpcli command (even works with
wp user list
) the following error occurs:I think the problem is that the action
plugins_loaded
/S3_Uploads\\init
happens afterWP_CLI::add_command(..)
and theinit
function requires theautoload.php
, which loadsS3_Uploads\\WP_CLI_Command
.I fixed it by moving the following code to the begin of the
s3-uploads.php
file.