woocommerce / google-listings-and-ads

Sync your store with Google to list products for free, run paid ads, and track performance straight from your store dashboard.
https://woo.com/products/google-listings-and-ads/
GNU General Public License v3.0
44 stars 21 forks source link

[API Pull] Handle exception when deactivating the plugin and the WPCOM token does not exist. #2449

Closed jorgemd24 closed 1 month ago

jorgemd24 commented 1 month ago

Changes proposed in this Pull Request:

Part of #2146 .

Currently, we throw an exception if the request to revoke the token fails, such as when the WPCOM token is not found and therefore can't be deleted. This can lead to a fatal error when deactivating the plugin, preventing its deactivation. Since not all merchants will opt into the new mechanism, the scenario where the WPCOM token is missing is possible. To prevent this fatal error, I think it's better to catch the exception and log the error.

Additionally, I've removed the "Revoke WPCOM Access token" option from the Connection Test page. We now have a similar option, "WPCOM REST API Status" -> "Disconnect," which has the same purpose, making the option redundant.

image

Screenshots:

Detailed test instructions:

  1. Revoke any WPCOM token, you can use the connection test page if you already have one WPCOM token.
  2. Deactivate the plugin.
  3. See that we prevent the fatal error and log the error.

Additional details:

Changelog entry

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 64.7%. Comparing base (7ff8a9e) to head (dc34f56). Report is 1 commits behind head on feature/google-api-project.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2449/graphs/tree.svg?width=650&height=150&src=pr&token=UROWUPF1LX&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce)](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2449?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) ```diff @@ Coverage Diff @@ ## feature/google-api-project #2449 +/- ## ============================================================== + Coverage 64.6% 64.7% +0.1% + Complexity 4552 4550 -2 ============================================================== Files 473 473 Lines 17757 17747 -10 ============================================================== + Hits 11478 11483 +5 + Misses 6279 6264 -15 ``` | [Flag](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2449/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) | Coverage Δ | | |---|---|---| | [php-unit-tests](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2449/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) | `64.7% <100.0%> (+0.1%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2449?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce) | Coverage Δ | | |---|---|---| | [src/API/WP/OAuthService.php](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2449?src=pr&el=tree&filepath=src%2FAPI%2FWP%2FOAuthService.php&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce#diff-c3JjL0FQSS9XUC9PQXV0aFNlcnZpY2UucGhw) | `96.4% <100.0%> (+0.4%)` | :arrow_up: | | [src/ConnectionTest.php](https://app.codecov.io/gh/woocommerce/google-listings-and-ads/pull/2449?src=pr&el=tree&filepath=src%2FConnectionTest.php&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=woocommerce#diff-c3JjL0Nvbm5lY3Rpb25UZXN0LnBocA==) | `0.0% <ø> (ø)` | |