Repository navigation
Connectors: Support filesystem credentials when installing plugins. - #13953
Vedanshmini26 wants to merge 2 commits into
Conversation
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.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
Thanks for the patch, @Vedanshmini26! Adding filesystem credential handling to the connectors settings screen and exposing Patch Testing ReportPatch tested: #13953 Environment
Steps taken
Expected result
Additional Notes
|
|
Hey, thanks for the patch! I checked the changes, and the flag and modal markup seem to match the REST filesystem check. However, I couldn't find anything in this patch that actually reads Just a couple of questions:
|
# Conflicts: # src/wp-admin/options-connectors.php
t-hamano
left a comment
There was a problem hiding this comment.
Sorry for the late reply, @Vedanshmini26, and thank you for working on this!
Since this PR was opened, WordPress/gutenberg#78367 has switched to a different approach. The client now tries the REST endpoint first and falls back to wp.updates.installPlugin() only when the request fails with fs_unavailable. With this approach, the filesystemCredentialsRequired flag and its tests are no longer needed. The only core change required is the options-connectors.php part, which matches what the Gutenberg PR does in lib/compat/plugin/connectors.php.
Because this is a significant change from this PR, I'll close it and open a new PR that matches the Gutenberg PR. You'll still be included in the props.
When the filesystem method requires credentials that are not stored (for example,
FS_METHODisftpext), 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 useswp.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 theupdatesscript and printswp_print_request_filesystem_credentials_modal()andwp_print_admin_notice_templates(), the same wayplugin-install.phpandimport.phpdo. The modal is only printed when credentials are actually required.src/wp-includes/connectors.php: adds afilesystemCredentialsRequiredflag to the Connectors script module data. It istrueonly when the filesystem method is notdirectand no credentials are stored. This is the same checkWP_REST_Plugins_Controller::is_filesystem_available()uses, so the client switches towp.updatesin exactly the cases where REST would fail.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:
Manual (needs the Gutenberg change from WordPress/gutenberg#78367 in the build):
define( 'FS_METHOD', 'ftpext' );inwp-config.php, and do not store FTP credentials.ai-provider-for-anthropic) is not installed.FS_METHODline and repeat. The install goes through REST with no modal, as before.Server-side check without the Gutenberg change: with
FS_METHODset toftpext, the Connectors page source contains#request-filesystem-credentials-dialogand"filesystemCredentialsRequired":true. Withdirect, there is no modal and the flag isfalse.Trac ticket: https://core.trac.wordpress.org/ticket/65223