Connection: include connection-using plugin slugs on every authorize URL#48713
Open
bindlegirl wants to merge 3 commits into
Open
Connection: include connection-using plugin slugs on every authorize URL#48713bindlegirl wants to merge 3 commits into
bindlegirl wants to merge 3 commits into
Conversation
Centralize the `plugins` query arg on every Jetpack authorize URL by populating it once inside `Manager::get_authorization_url()` from `Plugin_Storage::get_all()`. Every existing call site (My Jetpack, SSO, Identity Crisis, the Connection Notice, the connectors card, Publicize, Post-by-Email) now picks the value up automatically. Drop the now-redundant `plugins` request param from the `/connection/register` and `/connection/authorize_url` REST endpoints plus the JS callers in `connectors-card.js` that used to send it - the single server-side source replaces both. Tests for the two REST endpoints now seed `Plugin_Storage` instead of passing the param, with a `tearDown` reset so the static state does not leak between tests. New `ManagerTest::test_get_authorization_url_includes_plugins_from_storage` covers the new behavior end-to-end. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Contributor
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 3 files.
|
`ReflectionClass::setStaticPropertyValue()` cannot reach private static properties on PHP <8.1 without going through `getProperty()` + `setAccessible(true)` first. The new `test_get_authorization_url_includes_plugins_from_storage` was calling the former directly and tripped CI on the lower PHP versions in the matrix. Factor the existing fallback (already used in `REST_Endpoints_Test` and `Plugin_Storage_Test`) into a small helper on the test class and route the four call sites in the new test through it. Co-authored-by: Cursor <cursoragent@cursor.com>
The reset_plugin_storage() helpers in ManagerTest and REST_Endpoints_Test were flipping the static $configured flag back to false between tests. That makes Plugin_Storage::get_all() hand back a WP_Error object instead of an array, and Manager::register() then stuffs that object into the HTTP request body it passes to wp_remote_request(). On PHP 8.5, the Requests library bundled with WordPress core walks that body via RecursiveArrayIterator (Requests/src/Transport/Curl.php:630), which now emits a deprecation when an object is used as the backing array. With phpunit.xml's failOnDeprecation=true, that single deprecation fails the whole connection package test run -- specifically attributed to Webhooks_Test::test_handle_connect_url_redirect, an unrelated test that just happens to call register() during the redirect flow. Resetting to a "post-plugins_loaded" state ($configured = true, empty $plugins) keeps get_all() returning a plain array, matches what production code sees once plugins_loaded has fired, and lets the downstream test continue to work on PHP 8.5. Also simplifies the new ManagerTest case: with $configured already true, we can drop the back-and-forth configure() / set_plugin_storage_configured() dance and let Plugin::add() seed plugins directly via Plugin_Storage::upsert(). Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related CONNECT-186
Proposed changes
pluginsquery arg on every Jetpack authorize URL by populating it once insideManager::get_authorization_url()fromPlugin_Storage::get_all(). Every existing caller (My Jetpack, SSO, Identity Crisis, the Connection Notice, the connectors card, Publicize, Post-by-Email) now picks the slug list up automatically — previously only the new connectors-card flow sent it.pluginsrequest param from the/connection/registerand/connection/authorize_urlREST endpoints plus the JS callers inconnectors-card.jsthat used to send it. The single server-side source replaces both.ManagerTestcase for the new behavior end-to-end and update the affectedREST_Endpoints_Testcases to seedPlugin_Storagedirectly. AtearDownreset hook keeps the class's private static state from leaking between tests.Related product discussion/links
Does this pull request change what data or activity we track or use?
No — the same
pluginsquery arg is already sent today via the/connection/registerand/connection/authorize_urlREST endpoints (when called from the connectors card). This PR just makes the value emitted on every authorize URL flow rather than only that one. The data itself is unchanged: a comma-separated list of slugs fromPlugin_Storage::get_all(), which already feeds thejetpack_connection_active_pluginsoption synced to WPCOM.One subtle wire-format change worth flagging for reviewers: the comma between slugs now arrives at WPCOM URL-encoded once (
plugins=jetpack%2Cwoocommerce) instead of literal (plugins=jetpack,woocommerce), because the value goes throughurlencode_deep()insideget_authorization_url()beforeadd_query_arg. WPCOM decodes query args normally so this is functionally equivalent.Testing instructions
wordpress.com/jetpack/connect/authorize?...URL has aplugins=...query arg:Made with Cursor