⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@sksaju
Copy link
Contributor

@sksaju sksaju commented Jul 27, 2025

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 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 sksaju requested review from a team, dkotter and jeffpaul as code owners July 27, 2025 19:13
@github-actions github-actions bot added this to the 3.6.0 milestone Jul 27, 2025
@github-actions github-actions bot added the needs:code-review This requires code review. label Jul 27, 2025
@jeffpaul jeffpaul removed their request for review August 5, 2025 01:42
*/
function classifai_autoload() {

// Load the prefixed vendor autoloader (contains AWS SDK and all other dependencies)
Copy link
Collaborator

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;
}

Comment on lines 51 to 52
- name: Run Strauss to namespace dependencies
run: php -d memory_limit=2048M -d max_execution_time=300 bin/strauss.phar
Copy link
Collaborator

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

Copy link
Collaborator

@dkotter dkotter left a 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

@dkotter dkotter modified the milestones: 3.6.0, 3.7.0 Aug 18, 2025
@github-actions github-actions bot added the needs:refresh This requires a refreshed PR to resolve. label Aug 21, 2025
@dkotter dkotter modified the milestones: 3.7.0, 3.8.0 Sep 11, 2025
@github-actions github-actions bot removed the needs:refresh This requires a refreshed PR to resolve. label Sep 26, 2025
@github-actions github-actions bot added the needs:refresh This requires a refreshed PR to resolve. label Jan 7, 2026
@github-actions
Copy link

github-actions bot commented Jan 7, 2026

@sksaju thanks for the PR! Could you please rebase your PR on top of the latest changes in the base branch?

@jeffpaul
Copy link
Member

@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

@jeffpaul jeffpaul modified the milestones: 3.8.0, 3.9.0 Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:code-review This requires code review. needs:refresh This requires a refreshed PR to resolve.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conflicts between AWS SDK in this plugin and others

4 participants