Skip to content

Conversation

@leogermani
Copy link
Contributor

@leogermani leogermani commented Jul 31, 2020

Introduces a new class to handle async XML-RPC requests and replace Jetpack::xmlrpc_async_call()

Changes proposed in this Pull Request:

Currently, Jetpack::xmlrpc_async_call() is used to enqueue few XML-RPC requests that are sent all at once, as a MultiCall request, at shutdown. This method forces the requests to use the "Master user" token.

As we are moving to give preference to the blog token everywhere we can, and the current user token where we are performing a user action, we needed a more flexible method that allowed us to choose which token we wanted to use.

To modify this method while keeping backward compatibility would result in a not very elegant solution, polluting the Jetpack class even more and adding complexity to an untested method. So I decided to create a new class to handle this, removing the responsibility from the Jetpack class and start writing simple tests for it.

This PR only adds the class but don't use it yet. Following PRs will replace the use of the deprecated method in favor of this class.

Note: I've first added a deprecation notice to the old method, but it breaks the tests, so I will first replace all the calls to it, and then we can review this PR to add the notice.

Jetpack product discussion

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

No

Testing instructions:

  • There is a simple PHPUnit test there that needs to pass
  • At this point, just review the code. Following PRs will test its functionality

Proposed changelog entry for your changes:

@jetpackbot
Copy link
Collaborator

jetpackbot commented Jul 31, 2020

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

E2E results is available here (for debugging purposes): https://jetpack-e2e-dashboard.herokuapp.com/pr-16674

Scheduled Jetpack release: September 1, 2020.
Scheduled code freeze: August 25, 2020

Generated by 🚫 dangerJS against 99da2f7

@leogermani leogermani changed the title saving work in progress New class to handle async XML-RPC requests Aug 3, 2020
@leogermani leogermani self-assigned this Aug 3, 2020
@leogermani leogermani added this to the 8.9 milestone Aug 3, 2020
@leogermani leogermani added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Review This PR is ready for review. labels Aug 3, 2020
@leogermani leogermani force-pushed the add/xmlrpc-async-call-lib branch 3 times, most recently from e6c2051 to 455225a Compare August 3, 2020 21:22
@leogermani leogermani marked this pull request as ready for review August 3, 2020 21:42
@leogermani leogermani added the [Status] Needs Review This PR is ready for review. label Aug 3, 2020
kraftbj
kraftbj previously requested changes Aug 3, 2020
Copy link
Contributor

@kraftbj kraftbj left a comment

Choose a reason for hiding this comment

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

Quick read through the code reads okay. I didn't test, but wonder if having it as part of the connection package is long-term more functional?

@leogermani leogermani added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Aug 3, 2020
@jeherve jeherve added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it Connect Flow Connection banners, buttons, ... labels Aug 4, 2020
@leogermani leogermani force-pushed the add/xmlrpc-async-call-lib branch from 56c669e to 8afe88b Compare August 4, 2020 14:05
@github-actions github-actions bot added the [Status] Needs Package Release This PR made changes to a package. Let's update that package now. label Aug 4, 2020
@leogermani leogermani added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Aug 4, 2020
@leogermani
Copy link
Contributor Author

Moved into the connection package

Combining the `multisite` and `single-site` functions into one to improve readability.
Copy link
Contributor

@sergeymitr sergeymitr left a comment

Choose a reason for hiding this comment

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

@leogermani I pushed a commit to simplify the code a little bit, hope that's ok.
Tested it on both single-site and multisite installs, works as a charm 👍 :shipit:

@sergeymitr sergeymitr added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Aug 4, 2020
@leogermani leogermani dismissed kraftbj’s stale review August 5, 2020 13:09

changes applied

@leogermani
Copy link
Contributor Author

Thanks @sergeymitr !

Pinging @kraftbj to see if he want to take a look after the changes

@leogermani leogermani merged commit 80ceab3 into master Aug 5, 2020
@leogermani leogermani deleted the add/xmlrpc-async-call-lib branch August 5, 2020 17:05
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Aug 5, 2020
davidlonjon added a commit that referenced this pull request Aug 6, 2020
…ic/jetpack into add/jetpack-lazy-images-package

* 'add/jetpack-lazy-images-package' of github.com:Automattic/jetpack: (40 commits)
  Lodash: Revert to previous version (#16735)
  New class to handle async XML-RPC requests (#16674)
  Social Previews: Sidebar design updates (#16725)
  Update E2E locator for classic connection flow (#16708)
  Woo Services: update to use existing Jetpack plugin install tools (#16672)
  Admin Page: avoid blank dashboard when notice is not a string (#16721)
  Admin Page: update string still using old i18n format (#16722)
  Social Previews: Add sidebar UI (#16633)
  Fix recurring payments block disconnecting (sometimes) when existing article is reopened in block editor. (#16640)
  Connection Register: Add current user email to connection register request (#16712)
  Update versions to start 8.9 Release cycle (#16706)
  Donations block: Make currency and amounts editable (#16593)
  Update dependency @automattic/calypso-color-schemes to v2
  Error Notice: removing HTML code, adjusting maximum width. (#16690)
  Update dependency swiper to v6 (#16587)
  Site Scan: Short-circuit update_threats_link() if Admin Bar is not present (#16677)
  Update vulnerable NPM packages (#16659)
  E2E Tests: Add Jetpack updater test (#16437)
  check for subdir site before rendering Ads.txt section (#16671)
  VideoPress Block: Retain alignment support (#16651)
  ...
pereirinha pushed a commit that referenced this pull request Sep 10, 2020
* add async call class to connection package

* add docs to the new class

* Async XMLRPC Requests: Simplifying the code.

Combining the `multisite` and `single-site` functions into one to improve readability.

Co-authored-by: Sergey Mitroshin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Connect Flow Connection banners, buttons, ... [Package] Connection [Status] Needs Package Release This PR made changes to a package. Let's update that package now. [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants