-
Notifications
You must be signed in to change notification settings - Fork 65
Fix | Conflicts between AWS SDK in this plugin and others #965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Fix | Conflicts between AWS SDK in this plugin and others #965
Conversation
| */ | ||
| function classifai_autoload() { | ||
|
|
||
| // Load the prefixed vendor autoloader (contains AWS SDK and all other dependencies) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So currently this function will return true if the autoload file is loaded properly. Now that we are introducing another autoload file, I think we'll need additional changes here to ensure both are loaded properly and show an error message if not.
Something like this (untested):
function classifai_autoload() {
$loaded = false;
// Load the prefixed vendor autoloader (contains AWS SDK and all other dependencies)
if ( file_exists( CLASSIFAI_PLUGIN_DIR . '/vendor-prefixed/autoload.php' ) ) {
require_once CLASSIFAI_PLUGIN_DIR . '/vendor-prefixed/autoload.php';
$loaded = true;
}
// Load the main vendor autoloader (contains plugin classes and other dependencies)
if ( $loaded && file_exists( CLASSIFAI_PLUGIN_DIR . '/vendor/autoload.php' ) ) {
require_once CLASSIFAI_PLUGIN_DIR . '/vendor/autoload.php';
} else {
$loaded = false;
}
if ( ! $loaded ) {
error_log( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
sprintf( 'Warning: Composer not setup in %s', CLASSIFAI_PLUGIN_DIR )
);
return false;
}
return true;
}| - name: Run Strauss to namespace dependencies | ||
| run: php -d memory_limit=2048M -d max_execution_time=300 bin/strauss.phar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? Looking at the changes in composer.json, we run this same command on the post-install-cmd hook which I think means this will automatically run after the step above
dkotter
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One other thing that needs fixed here. If running composer install locally, you'll need to ensure your environment is running PHP 7.4 (which is our minimum for this plugin). If you're running PHP 8+, composer will set PHP 8.1 as our minimum which breaks things (you can see this in some of our failing GitHub Actions on this PR). So you'll want to install PHP 7.4 locally, run composer install and then commit the composer.lock file
…-plugin-and-others
|
@sksaju thanks for the PR! Could you please rebase your PR on top of the latest changes in the base branch? |
|
@dkotter @peterwilsoncc we'll likely need to pick this one up to finish it off, to give us a bit more time I'm moving this out a release |
Description of the Change
This PR implements Strauss dependency prefixing to namespace the AWS SDK, preventing conflicts with other WordPress plugins that may use the same AWS SDK package. The implementation creates a completely isolated version of the AWS SDK under the ClassifaiVendor\ namespace.
Closes #822
How to test the Change
First, let's get everything installed and built:
# Navigate to the plugin directory and install dependencies composer install npm install npm run buildCheck That Strauss Did Its Job
Strauss should have created a
vendor-prefixeddirectory with our namespaced AWS SDK. Let's verify:You should see something like this:
Test the AWS Polly Feature
Now let's make sure our text-to-speech functionality still works:
us-east-1)The Real Test - Conflict Prevention
This is where we see if Strauss actually prevents conflicts:
If everything's working, you shouldn't see any "class already exists" or similar errors!
Test the Build Process
Let's make sure our build process works correctly:
Changelog Entry
Credits
Props @username, @username2, ...
Checklist: