classifai icon indicating copy to clipboard operation
classifai copied to clipboard

Fix | Conflicts between AWS SDK in this plugin and others

Open sksaju opened this issue 6 months ago • 0 comments

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:

  1. Head to your WordPress admin panel
  2. Navigate to ClassifAIText to Speech
  3. Enter your AWS credentials:
    • Access Key ID
    • Secret Access Key
    • AWS Region (like us-east-1)
  4. 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:

  1. Install another plugin that uses AWS SDK (WooCommerce with AWS extensions works well)
  2. Activate both plugins at the same time
  3. Check for any PHP errors in your error logs
  4. 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:

sksaju avatar Jul 27 '25 19:07 sksaju