-
Notifications
You must be signed in to change notification settings - Fork 20
Description
Hey guys,
I was having issues after I upgraded to WP 7 nightly. The connectors screen would not accept my openai API key, no matter how many times I tried, and I would get the error “It was not possible to connect to the provider using this key.”
The openai provider availability check was always returning false, even though before the upgrade it was working fine. I stepped through the code and could not figure out why.
Then I decided to disable all plugins. It worked!
Then enabling each plugin one by one, I found that when I enabled plugin-check - the connectors screen would break.
Looking in the code of plugin-check, it includes it's own wp-ai-client, and it's autoload is overriding the WP core version.
I am thinking that plugins that include the wp-ai-client via composer (e.g. plugin-check) will cause similar problems to what I found. That is why I posted this here, and not under the plugin-check repo.
Ideally, the WP core version of wp-ai-client should take priority.
Here is a codex summary, which explains it all:
Environment
- WordPress 7.0-beta2-61775
- ai-provider-for-openai active
- plugin-check 1.8.0 active
- OpenAI provider is registered, no registration exceptions
Reproduction
- Activate ai-provider-for-openai.
- Activate plugin-check.
- Go to Connectors settings and enter a valid OpenAI key.
- Save settings.
- Expected
- _wp_connectors_is_api_key_valid() should validate via the provider model-list endpoint and return true for a valid key.
- Actual
- Validation returns false consistently, and the provider list-models API call is never reached.
Technical root cause
plugin-check loads Composer autoload with prepend ($loader->register(true)), and maps:
WordPress\AiClient\ -> plugin-check/vendor/wordpress/php-ai-client/src
WordPress\AI_Client\ -> plugin-check/vendor/wordpress/wp-ai-client/includes
Because of that, WordPress core and plugin-check end up with a mixed WordPress\AiClient class graph:
WordPress\AiClient\AiClient resolves to core
but WordPress\AiClient\Providers\ProviderRegistry resolves to plugin-check vendor copy (older API behavior)