Fix: Display error for broken social connections in editor
Changes proposed in this Pull Request:
This change introduces a notice if there is any broken connection, and disables broken connections Added new property to connection meta to state health of connection. We already know this information, since this is cached for 12 hours, so we can easily use it in the requests. This also had an advantage, that in the editor the Notice is instantly visible, rather than before when it sent a request on page load to get the (same cached) connection results from the API, and then showing the notice.
Jetpack product discussion
1202807135507995-as-1202841973973991
Does this pull request change what data or activity we track or use?
No.
Testing instructions:
- Use your sandbox as backend with
define( 'JETPACK__SANDBOX_DOMAIN', 'your_wordrpresscom_domain' );on D86475-code - Create a broken connection for facebook:
- Go here and revoke access for WordPress
- In sandbox open wp-content/lib/external-connections.php file, and on line 655 change
$force = falseto$force = true - Open Social on your page, then go to Add new Post, and open the Social/Jetpack tab. This should refresh the test result and after that in cloud/Calypso the FB connection should show as broken.
- Revert the change in the parameters, set it back to false. Now you have a broken connection without have to wait for 12 hours.
- Open Gutenberg, and go to Social tab. Facebook connection should be shown as broken and disabled:
| Gutenberg | Classic |
|---|---|
![]() |
> |
- Click on link, which navigates to JP cloud, and fix the connection.
- Going back to the Gutenberg tab, the connection should refresh in a few seconds. Notice should disappear, and connection can be toggled again. In Classic Editor you need to refresh the page to see changes
Thank you for your PR!
When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
- :white_check_mark: Include a description of your PR changes.
- :warning: All commits were linted before commit.
- :white_check_mark: Add a "[Status]" label (In Progress, Needs Team Review, ...).
- :white_check_mark: Add testing instructions.
- :white_check_mark: Specify whether this PR includes any changes to data or privacy.
- :white_check_mark: Add changelog entries to affected projects
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 :robot:
The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.
Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Then, add the "[Status] Needs Team review" label and ask someone from your team review the code. Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.
Jetpack plugin:
- Next scheduled release: November 1, 2022.
- Scheduled code freeze: October 25, 2022.
Social plugin:
- Next scheduled release: November 2, 2022.
- Scheduled code freeze: October 26, 2022.
I got a strange error saying this class was not found
new Automattic\Jetpack\Social\Share_Limits, I just uncommented that bit of code to continue to testing, but I wonder if this was something to do with my localhost not having the dependencies correctly installed.
Maybe jetpack install --all could solve it? I have had something similar where an install solved the issue
This is working fine, @gmjuhasz! Thanks for incorporating the comments. I can give another +1 after the tests are updated!
Are you an Automattician? You can now test your Pull Request on WordPress.com. On your sandbox, run bin/jetpack-downloader test jetpack add/error-for-broken-connection to get started. More details: p9dueE-5Nn-p2
Caution: This PR has changes that must be merged to WordPress.com Hello gmjuhasz! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer and confirm D90478-code works as expected before merging this PR. Once this PR is merged, please commit the changes to WP.com. Thank you! This revision will be updated with each commit to this PR
@gmjuhasz I've done a bit of work on this, which turned out to be more than I imagined! Related to the fix in #26955 I decided we should remove is_healthy from the post field, which means we need to wait for the result of the initial API/AJAX request in the editor. I don't think that's a major issue, given the performance problem having the connection tests creates.
But, this led to a pretty major refactor of the classic editor code, so that I could use _n for i18n of the strings etc. It should refresh on window foces though, like we do in the block editor, so it's a bit closer to the same UX.
See what you think, and if you're happy we can get others on the team and Crew to take a look.
Based on this comment in Slack p1666385236922229/1664903339.698629-slack-CDLH4C1UZ , I am marking this for 11.5 milestone. This will keep it on the Releasers radar to see where y'all are at if it is still open when they're looking at cutting.
Great news! One last step: head over to your WordPress.com diff, D90478-code, and deploy it.
Once you've done so, come back to this PR and add a comment with your SVN changeset ID (e.g. r12345-wpcom).
Thank you!

>