Skip to content

Connectors: Support filesystem credentials when installing plugins. - #13953

Open
Vedanshmini26 wants to merge 1 commit into
WordPress:trunkfrom
Vedanshmini26:fix/65223-connectors-filesystem-credentials
Open

Vedanshmini26 wants to merge 1 commit into
WordPress:trunkfrom
Vedanshmini26:fix/65223-connectors-filesystem-credentials

Conversation

@Vedanshmini26

Copy link
Copy Markdown

When the filesystem method requires credentials that are not stored (for example, FS_METHOD is ftpext), installing a connector plugin from Settings > Connectors fails with "Failed to install plugin for X." The REST API plugins endpoint rejects the request up front (fs_unavailable) and cannot take credentials. Plugins > Add Plugin works in the same environment because it uses wp.updates.installPlugin(), which shows the "Connection Information" modal.

The Gutenberg PR changes the Connectors client to install through wp.updates.installPlugin() when credentials are needed. This PR adds the server-side pieces that flow needs:

  • src/wp-admin/options-connectors.php: enqueues the updates script and prints wp_print_request_filesystem_credentials_modal() and wp_print_admin_notice_templates(), the same way plugin-install.php and import.php do. The modal is only printed when credentials are actually required.
  • src/wp-includes/connectors.php: adds a filesystemCredentialsRequired flag to the Connectors script module data. It is true only when the filesystem method is not direct and no credentials are stored. This is the same check WP_REST_Plugins_Controller::is_filesystem_available() uses, so the client switches to wp.updates in exactly the cases where REST would fail.
  • Tests: covers the flag for direct, for a non-direct method without stored credentials, and for a non-direct method with stored credentials.

The PHP changes do nothing on their own. They take effect once the Gutenberg change lands and the pinned Gutenberg hash is bumped. Until then, the extra script and markup on this screen are inert.

Testing Instructions

Automated:

npm run test:php -- --group connectors

Manual (needs the Gutenberg change from WordPress/gutenberg#78367 in the build):

  1. Set define( 'FS_METHOD', 'ftpext' ); in wp-config.php, and do not store FTP credentials.
  2. Make sure the AI plugin is active and a provider plugin (for example, ai-provider-for-anthropic) is not installed.
  3. Go to Settings > Connectors and click Install for that provider.
  4. Expected: the "Connection Information" modal opens. Valid credentials install and activate the plugin. Cancel aborts with no error notice.
  5. Remove the FS_METHOD line and repeat. The install goes through REST with no modal, as before.

Server-side check without the Gutenberg change: with FS_METHOD set to ftpext, the Connectors page source contains #request-filesystem-credentials-dialog and "filesystemCredentialsRequired":true. With direct, there is no modal and the flag is false.

Trac ticket: https://core.trac.wordpress.org/ticket/65223

When the filesystem method requires credentials that have not been stored, the REST API plugins endpoint cannot install plugins, so installing a connector plugin from Settings > Connectors failed with a generic error instead of showing the "Connection Information" modal.

This loads the `updates` script on the Connectors screen, prints the filesystem credentials modal and admin notice templates, and exposes a `filesystemCredentialsRequired` flag to the Connectors script module. This allows the client to install plugins via `wp.updates.installPlugin()`, matching Plugins > Add Plugin.

The client-side changes are in Gutenberg: WordPress/gutenberg#78367

See #65223.
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props sheldorofazeroth, rejaulalomkhan.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@rejaulalomkhan

Copy link
Copy Markdown

Thanks for the patch, @Vedanshmini26! Adding filesystem credential handling to the connectors settings screen and exposing filesystemCredentialsRequired is a clean way to support environments without direct filesystem access. I tested this locally:

Patch Testing Report

Patch tested: #13953

Environment

  • WordPress: 7.2-alpha-63166-src
  • PHP: 8.3.35
  • Server: PHP CLI / Docker (PHPUnit 9.6.38)
  • Database: MySQL 8.4.11
  • Browser: N/A (unit tests & server-side inspection)
  • OS: macOS (Darwin arm64)
  • Theme: N/A
  • MU Plugins: None activated
  • Plugins: None activated

Steps taken

  1. Ran tests/phpunit/tests/connectors/wpConnectorsGetConnectorScriptModuleData.php on single site: all 11 tests pass (27 assertions).
  2. Ran the same test file on multisite (-c tests/phpunit/multisite.xml): all 11 tests pass.
  3. Ran with --order-by=reverse: all 11 tests pass.
  4. Ran the full connectors test group: all 115 tests pass (285 assertions).
  5. Tested on current trunk code (reverted src/ changes): all 3 new tests error as expected (Undefined array key "filesystemCredentialsRequired").
  6. Tested 4 targeted mutations against the new logic:
    • Setting $data['filesystemCredentialsRequired'] = true by default -> caught by test_filesystem_credentials_not_required_for_direct_filesystem_method (Failed asserting that true is false).
    • Inverting $filesystem_credentials_are_stored -> caught by test_filesystem_credentials_required_when_credentials_are_not_stored (Failed asserting that false is true).
    • Inverting 'direct' !== get_filesystem_method() to '===' -> caught by test_filesystem_credentials_required_when_credentials_are_not_stored (Failed asserting that false is true).
    • Ignoring stored credentials check ($data['filesystemCredentialsRequired'] = true) -> caught by test_filesystem_credentials_not_required_when_credentials_are_stored (Failed asserting that true is false).
  7. ✅ Patch is solving the problem: the new script module flag accurately indicates whether credentials are required, modal and update scripts are cleanly enqueued in options-connectors.php, and all unit tests pass without regressions across single site and multisite.

Expected result

  • The filesystemCredentialsRequired flag is false when filesystem method is direct or credentials are stored, and true when credentials are required and not stored.

Additional Notes

  • Verified that wp_print_request_filesystem_credentials_modal() and wp_print_admin_notice_templates() in src/wp-admin/options-connectors.php match the standard implementation in plugin-install.php.
  • AI assistance: Antigravity (Gemini 3.8 Flash) was used to run the tests; results reviewed by me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants