Fix | Conflicts between AWS SDK in this plugin and others
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 https://github.com/10up/classifai/issues/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 build
Check That Strauss Did Its Job
Strauss should have created a vendor-prefixed directory with our namespaced AWS SDK. Let's verify:
# See if the prefixed directory exists
ls -la vendor-prefixed/aws/
# Check that classes are properly namespaced
grep -r "ClassifaiVendor" vendor-prefixed/aws/
You should see something like this:
vendor-prefixed/aws/
├── aws-sdk-php/
│ ├── src/
│ │ ├── Aws/
│ │ │ ├── Polly/
│ │ │ └── ... (other AWS services)
│ └── autoload.php
Test the AWS Polly Feature
Now let's make sure our text-to-speech functionality still works:
- Head to your WordPress admin panel
- Navigate to ClassifAI → Text to Speech
- Enter your AWS credentials:
- Access Key ID
- Secret Access Key
- AWS Region (like
us-east-1)
- Try generating speech from a post - you should get an audio file back
The Real Test - Conflict Prevention
This is where we see if Strauss actually prevents conflicts:
- Install another plugin that uses AWS SDK (WooCommerce with AWS extensions works well)
- Activate both plugins at the same time
- Check for any PHP errors in your error logs
- Test both plugins to make sure they still work properly
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:
# Run the archive command
npm run archive
# Check what's in the release directory
ls -la release/
Changelog Entry
Added - Implement Strauss dependency prefixing for AWS SDK to prevent conflicts with other plugins
Credits
Props @username, @username2, ...
Checklist:
- [ ] I agree to follow this project's Code of Conduct.
- [ ] I have updated the documentation accordingly.
- [ ] I have added Critical Flows, Test Cases, and/or End-to-End Tests to cover my change.
- [ ] All new and existing tests pass.