Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Social | Classic editor connections schema changes #41778

Open
wants to merge 11 commits into
base: trunk
Choose a base branch
from

Conversation

manzoorwanijk
Copy link
Member

@manzoorwanijk manzoorwanijk commented Feb 13, 2025

This PR contains all the changes we need for classic editor to use the new schema.

Proposed changes:

  • The commits in the PR are sequential and iterate over each other. You can go through them individually to see how things changed.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

  • Install and activate the Classic Editor plugin on your site
  • For Simple sites you can activate the classic view from View Options at the top
  • Add some Social connections to the site
  • Create a post using classic editor
  • Confirm that the connections are loaded fine
  • Publish a post sharing only to some of the connections, leaving some unchecked
  • Confirm that the post gets shared only to the selected connections
  • Edit the same post again
  • Confirm that all the connections are now unchecked by default
  • Enable a connection and reshare the post
  • Confirm that the post is reshared to the selected connections and not to the other connections
  • Break a connection by removing Jetpack from connected apps on a network
  • On the social admin page, update a connection to update connection test cache
  • Open the Network tab
  • Load the classic editor again
  • Confirm that the connection tests use the wpcom/v2 endpoint instead of Ajax
  • Confirm that you see the broken connection notice
  • Do a sanity check for block editor to see connections work as expected for both new and existing posts

Copy link
Contributor

github-actions bot commented Feb 13, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin, and enable the update/social-classic-editor-schema-changes branch.

  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack update/social-classic-editor-schema-changes
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

Copy link
Contributor

github-actions bot commented Feb 13, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ 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 🤖


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.


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Choose a review path based on your changes:
    • A. Team Review: add the "[Status] Needs Team Review" label
      • For most changes, including minor cross-team impacts.
      • Example: Updating a team-specific component or a small change to a shared library.
    • B. Crew Review: add the "[Status] Needs Review" label
      • For significant changes to core functionality.
      • Example: Major updates to a shared library or complex features.
    • C. Both: Start with Team, then request Crew
      • For complex changes or when you need extra confidence.
      • Example: Refactor affecting multiple systems.
  3. Get at least one approval before merging.

Still unsure? Reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen semi-continuously (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly. The next release is scheduled for none scheduled (scheduled code freeze on undefined).

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Feb 13, 2025
Copy link
Contributor

github-actions bot commented Feb 13, 2025

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/_inc/lib/core-api/wpcom-fields/post-fields-publicize-connections.php 91/178 (51.12%) -30.34% 54 💔
projects/plugins/jetpack/_inc/lib/core-api/class-wpcom-rest-field-controller.php 65/160 (40.62%) -3.12% 5 💔

Full summary · PHP report · JS report

Add label I don't care about code coverage for this PR Use this label to ignore the check for insufficient code coveage. to override the failing coverage check.

Since publicize package will always be the latest version regardless of whether there is an older version of a plugin, we can safely remove it.
@github-actions github-actions bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests labels Feb 13, 2025
@manzoorwanijk manzoorwanijk changed the title Update/social classic editor schema changes Social | Classic editor connections schema changes Feb 13, 2025
@manzoorwanijk manzoorwanijk added [Status] Needs Team Review and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Feb 13, 2025
@manzoorwanijk manzoorwanijk self-assigned this Feb 13, 2025
@manzoorwanijk manzoorwanijk marked this pull request as ready for review February 13, 2025 12:17
@manzoorwanijk manzoorwanijk requested a review from a team February 13, 2025 12:17
Copy link
Contributor

@pablinos pablinos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few thoughts! But generally it's looking good

projects/packages/publicize/src/class-publicize-base.php Outdated Show resolved Hide resolved
@@ -971,7 +969,7 @@ public function get_filtered_connection_data( $selected_post_id = null ) {
* If this is a global connection and this user doesn't have enough permissions to modify
* those connections, don't let them change it.
*/
if ( ! $done && $this->is_global_connection( $connection_meta ) && ! current_user_can( $this->GLOBAL_CAP ) ) {
if ( ! $done && $connection['shared'] && ! current_user_can( $this->GLOBAL_CAP ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have a is_shared method on the connection or something, so we remove the chance of typos etc? We're also mixing terms 'shared' and 'global'. It would be good to make sure we're only using one of those.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we can add a method to the connections class to check if a connection is shared.

<?php
checked( true, $connection_data['enabled'] && $connection_healthy );
disabled( false, $connection_healthy );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting flaw currently. If we know that the connection is broken from the last test, then we should update the cache to show that. Currently the cache might have all connections with an ok status, but the test-connections call then disabled it.

I think it's probably a follow-up though. It's how it also works in the block editor, but should we remove this disabled logic? Might it be better to update it to check that the status is ok?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned above, the status is by default null until connection tests are run.

May be in a separate change, we should use that connection test result call to save the connections list and then we could use the status field from there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I don't think it's for this change, but we don't actually store the status of the connections now do we? So in the frontend, that's only reflected after the test connections call. I think we should update the connections cache with the result from the test connections call, and that should mean things update and jump around less.

We might want to check we're storing the status of the connections properly on WPCOM too, or we will try and share to broken connections. I think this bit is fine, but something to check while we're at it.

@@ -125,7 +125,7 @@ jQuery( function ( $ ) {
unsupportedConnections++;

isInvalid = true;
} else if ( connection.status === 'broken' ) {
} else if ( [ 'broken', 'must_reauth' ].includes( connection.status ) ) {
brokenConnections++;

isInvalid = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The connections that need reauth are treated as broken from the point of view of notifying the user, but they're not actually broken, and should still be able to be used like a valid connection. must_reauth used to be because the API had changed, but now it is if the connection will expire at some point soon.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I updated the messaging on the similar lines that you did in #41494

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's not the messaging, it's the fact that it sets isInvalid to true. Doesn't that mean we'll disable it?

projects/packages/publicize/src/class-publicize-base.php Outdated Show resolved Hide resolved
projects/packages/publicize/src/class-publicize-base.php Outdated Show resolved Hide resolved
@@ -449,7 +449,7 @@ public function post_page_metabox() {
$labels = array();

foreach ( $connections_data as $connection_data ) {
if ( ! $connection_data['enabled'] || ( isset( $connection_data['is_healthy'] ) && false === $connection_data['is_healthy'] ) ) {
if ( ! $connection_data['enabled'] ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be checking that the status is ok too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

status by default is null and is now set only on connection test results.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Do you think it could be safer to check status here too? I feel like we should be storing that, so we'll just have to put this check back in when we do.

projects/packages/publicize/src/class-publicize-base.php Outdated Show resolved Hide resolved
Copy link

Code Coverage Summary

Cannot generate coverage summary while tests are failing. 🤐

Please fix the tests, or re-run the Code coverage job if it was something being flaky.

Full summary · PHP report · JS report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Publicize Now Jetpack Social, auto-sharing [Package] Publicize [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Status] Needs Team Review [Tests] Includes Tests [Type] Task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants