Automattic / Automattic/studio

New site creation fails with "EventDispatcherInterface not found" on WordPress 7.0.x

Open
#4,412 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
517
Forks
95
Avg merge
1d 22h
Merged PRs (30d)
162

Description

### Quick summary

Creating any new site via studio site create fails during PHP server startup with a fatal error: Interface "WordPress\AiClientDependencies\Psr\EventDispatcher\EventDispatcherInterface" not found. This affects all WordPress 7.0.x versions (7.0, 7.0.1, 7.0.2) in Studio 1.17.0 on Windows 11.

**PS: AI USED TO CREATE THIS REPORT, BECAUSE IT CREATED THE WORK AROUND**

### Steps to reproduce

1. Run studio site create --name "test" --path "C:\Users...\Studio\test"
2. Observe that "Copying bundled WordPress…" and "Setting up SQLite integration…" succeed
3. After "Starting WordPress server…" spins for a few seconds, it fails

Or equivalently from any path:

`studio site create --name "test-bug" --path "/c/Users/PHALCON/Studio/test-bug"`

The error is 100% reproducible — 5 out of 5 fresh site creation attempts failed identically across different site names and directories.

### What you expected to happen

A new WordPress site should be created and started successfully, just like existing sites continue to work fine.

### What actually happened

PHP crashes during wp-settings.php load with:

Fatal error: Uncaught Error: Interface "WordPress< />iClientDependencies< />sr< />ventDispatcher< />ventDispatcherInterface" not found in wp-includes/ai-client/adapters/class-wp-ai-client-event-dispatcher.php:22 Full log from ~/.studio/daemon/logs/studio-site--error-.log:

Fatal error: Uncaught Error: Interface "WordPress< />AiClientDependencies< />Psr< />EventDispatcher< />EventDispatcherInterface" not found in ...< />wp-includes< />ai-client< />adapters< />class-wp-ai-client-event-dispatcher.php:22
Stack trace:
[#0]() ...< />wp-settings.php(293): require()
Automattic/studio#1 < />WP-CLI bootstrap< />: require('...< />wp-settings.php')
...
< />PHP Server< /> Failed to start server: Error: PHP command failed (code: 255)
The same pattern also fails for other PSR interfaces used by adjacent adapter files:

Psr< />Http< />Client< />ClientInterface
Psr< />Http< />Message< />RequestInterface
Psr< />Http< />Message< />ResponseInterface
Psr< />SimpleCache< />CacheInterface
Root cause: wp-settings.php (lines 289-295) registers an autoloader via spl_autoload_register() for the WordPress< />AiClientDependencies< /> namespace at line 289, then immediately requires adapter classes at lines 290-295 that implement those scoped PSR interfaces. The autoloader hasn't fired yet when these require calls execute, so the interfaces are missing. Existing sites that were created on earlier WP versions and live-updated bypass this race condition.

**Available workarounds:**
Patch the cached WordPress files in < />/.studio/server-files/wordpress-versions/{latest,7.0.1,7.0}/wp-settings.php to pre-load the PSR interfaces before the adapter requires. Replace lines 289-295:

require ABSPATH . WPINC . '/php-ai-client/autoload.php';

// Pre-load PSR interfaces so the adapter classes below can
// safely implement them without relying on autoloader timing.
$< />ai_tp = ABSPATH . WPINC . '/php-ai-client/third-party/Psr/';
if ( is_dir( $< />ai_tp ) ) {
$iter = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator( $< />ai_tp, FilesystemIterator::SKIP_DOTS )
);
foreach ( $iter as $fi ) {
if ( $fi->isFile() && 'php' === $fi->getExtension() ) {
require_once $fi->getPathname();
}
}
}
unset( $< />ai_tp, $iter, $fi );

require ABSPATH . WPINC . '/ai-client/adapters/class-wp-ai-client-http-client.php';
// ... rest of adapter requires unchanged
Note: Only pre-load files under third-party/Psr/ (interfaces). Do NOT pre-load third-party/Nyholm/ or third-party/Http/ as those contain implementations with constructor side effects.

### App or CLI?

Both

### Version

1.17.0

### Impact

Some (< 50%)

### Available workarounds?

No and the app is unusable

### Platform

Windows

### Architecture

x64 (Intel, AMD)

### Logs or notes

All 5 failed attempts produced identical errors across different site names. The php-ai-client/third-party/ directory has all the needed interface files — they just aren't loaded in time. The autoloader in php-ai-client/autoload.php works correctly when called lazily (which is why existing sites are fine), but the eager require pattern in wp-settings.php:290-295 creates a race on the very first PHP boot of a freshly-created site.

**PS: THESE ARE THE ORIGINAL ERRORS I GOT WITH STUDIO BEFORE I ESCALATED THE FIX TO AI**

Image

Image

Contributor guide

Open the contributing guide

Research direction

Start by reproducing `studio site create` on Windows with WordPress 7.0.x and inspect `~/.studio/daemon/logs/studio-site--error-.log`. Read the bundled WordPress `wp-settings.php` lines 289-295, `php-ai-client/autoload.php`, and the `ai-client/adapters` files; done means fresh sites start successfully without missing PSR-interface errors while existing-site behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
cli, desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.