Make WordPress Core

Opened 2 months ago

Closed 2 months ago

#64855 closed defect (bug) (fixed)

Connectors: AI provider plugins shown as "not installed" on sites with many plugins

Reported by: clifgriffin's profile clifgriffin Owned by: jorgefilipecosta's profile jorgefilipecosta
Milestone: 7.0 Priority: normal
Severity: normal Version: trunk
Component: AI Keywords:
Focuses: Cc:

Description

Description

The AI Connectors admin page (options-connectors.php) fails to detect installed AI provider plugins when the site has more than ~10 plugins installed and the AI provider plugins fall outside the first 10 alphabetically. Affected provider plugins (Anthropic, Google, OpenAI, or any third-party connector plugin) show as "not installed" even though they are installed and active.

This only affects sites where the alphabetically-sorted first 10 plugins do not include the AI connector provider plugins. Sites with fewer than ~10 total installed plugins, or where the provider plugins happen to sort into the first 10, are unaffected.

Root Cause

In routes/connectors-home/use-connector-plugin.ts, the useConnectorPlugin hook calls getEntityRecords("root", "plugin") without specifying per_page: -1. Core-data's getQueryParts() defaults perPage to 10 (packages/core-data/src/queried-data/get-query-parts.ts), so the selector only returns the first 10 plugin records from the store, even though the REST API response contains all installed plugins.

On a site with many plugins, any connector provider plugin that sorts past position 10 alphabetically will never be found by the .find() call:

const plugin = plugins.find(
    (p) => p.plugin === `${pluginSlug}/plugin`
);

This causes derivedPluginStatus to be set to "not-installed" and the UI shows an "Install" button for plugins that are already installed and active.

Steps to Reproduce

  1. Install WordPress 7.0 beta 5
  2. Have more than ~10 plugins installed (they don't need to be active — just installed on disk so that the provider plugins sort past position 10 alphabetically)
  3. Install and activate any AI provider plugin (e.g., ai-provider-for-google, ai-provider-for-anthropic, or ai-provider-for-openai)
  4. Navigate to Settings > Connectors (options-connectors.php)
  5. Observe that the connector shows an "Install" button despite the provider plugin being installed and active

Expected Result

Connector should show as active/connected.

Actual Result

Connector shows "Install" button. In the browser console, wp.data.select('core').getEntityRecords('root', 'plugin') returns only 10 plugins instead of the full list.

Proposed Fix

In the useConnectorPlugin hook, change:

const plugins = store2.getEntityRecords("root", "plugin");

to:

const plugins = store2.getEntityRecords("root", "plugin", { per_page: -1 });

This matches the pattern used elsewhere in core when fetching unpaginated entity records.

Notes

The plugins REST controller (class-wp-rest-plugins-controller.php) already returns all plugins without pagination (it explicitly removes page/per_page from collection params), so the REST API response is correct — the issue is purely in the client-side selector pagination.

Environment

WordPress 7.0 beta 5, tested with 238 installed plugins (1 active).

Change History (4)

#1 @gziolo
2 months ago

  • Milestone changed from Awaiting Review to 7.0

#2 @gziolo
2 months ago

  • Owner set to jorgefilipecosta
  • Status changed from new to assigned

#3 @gziolo
2 months ago

This bug was fixed in https://github.com/WordPress/gutenberg/pull/76594 and should be synced to trunk in WordPress core, along with other changes lined up for 7.0 RC1.

#4 @gziolo
2 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

Issues resolved with [62063].

Note: See TracTickets for help on using tickets.