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

Remove Woo plugin header #8050

Merged
merged 11 commits into from
Feb 5, 2024
Merged

Remove Woo plugin header #8050

merged 11 commits into from
Feb 5, 2024

Conversation

vbelolapotkov
Copy link
Collaborator

@vbelolapotkov vbelolapotkov commented Jan 19, 2024

There are some internal problems caused by existence of Woo header in the plugin file.
However, removing Woo header will break mechanism used for loading translations from translate.wordpress.com.
This PR removes Woo header and fixes the problem with loading translations.

More context in p1705063122937369-slack-CGGCLBN58

Changes proposed in this Pull Request

  • Remove Woo header from the plugin file and old filter used to hook into translations update process ran by Woo.
  • Implement similar solution for hooking into WP translations update process to load translations from translate.wordpress.com.

Test coverage exception

Most of the code interacts directly with WordPress plugin update process, so there is very little value in covering it with automated tests, because it'll require lots of mocking and code without really testing the behavior.

This decision was discussed with @RadoslavGeorgiev in a call (p1706252630150489-slack-CGGCLBN58).

Testing instructions

  • If using dev tools plugin, disable proxy for wordpress.com. Server is not needed in these tests, but downloading files from translate.wordpress.com is.

  • Open debug.log file wp-content/debug.log to monitor errors in the process.

  • Open plugins translation folder in your file manager. The path depends on your WP installation (local or within docker), bur the relative path is wp-content/languages/plugins

  • Remove all the existing translations files (it's pretty safe, new translations will be loaded).

  • Go to WP admin dashboard > Settings > General, and change language to one of the languages supported by WooPayments: https://woo.com/document/woopayments/customization-and-translation/translations/

  • Go to WP updates page: /wp-admin/update-core.php, at the bottom of the page a button to update translations should appear, click it to load new packages.

  • Once update process is completed check that translations for WooPayments appeared in translation folder mentioned above.

  • Check that plugin pages have translations.

  • Compare the translation files with files from wordpress.com. For this:

    • Go to translations packages debug page, url can be found here: PaJDYF-6n7-p2
    • Use regex finder to find package file name. Regex for v7.0.0 Fr package: 7_0_0.*fr_fr.zip. Note, do not use files from test builds (they have test in file name).
    • Download the package file from https://translate.files.wordpress.com/<file name starting from date>. Example: https://translate.files.wordpress.com/2024/01/woocommerce-payments-7_0_0-1704390844-es_es.zip.
    • Unpack package and compare the contents of a package with translations files installed by WP. The file names and sizes should match.
  • Try the same steps by selecting new language in Settings > General.

  • Try removing some .po files from WP translations folder, and go back to WP updates page: /wp-admin/update-core.php, new translations should be offered again.

  • Try breaking the flow either by enabling local server proxy, or introducing some fake exceptions/errors. There should be no errors logged in debug.log from WooPayments, but error message should be logged in WooPayments log file in Woo > Sytem > Logs.


  • Run npm run changelog to add a changelog file, choose patch to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.
  • Covered with tests (or have a good reason not to test in description ☝️)
  • Tested on mobile (or does not apply)

Post merge

@botwoo
Copy link
Collaborator

botwoo commented Jan 19, 2024

Test the build

Option 1. Jetpack Beta

  • Install and activate Jetpack Beta.
  • Use this build by searching for PR number 8050 or branch name update/translations-loading in your-test.site/wp-admin/admin.php?page=jetpack-beta&plugin=woocommerce-payments

Option 2. Jurassic Ninja - available for logged-in A12s

🚀 Launch a JN site with this branch 🚀

ℹ️ Install this Tampermonkey script to get more options.


Build info:

  • Latest commit: 3771878
  • Build time: 2024-02-05 08:39:18 UTC

Note: the build is updated when a new commit is pushed to this PR.

Copy link
Contributor

github-actions bot commented Jan 19, 2024

Size Change: 0 B

Total Size: 1.27 MB

ℹ️ View Unchanged
Filename Size
release/woocommerce-payments/assets/css/admin.css 1.06 kB
release/woocommerce-payments/assets/css/success.css 158 B
release/woocommerce-payments/dist/blocks-checkout-rtl.css 1.81 kB
release/woocommerce-payments/dist/blocks-checkout.css 1.81 kB
release/woocommerce-payments/dist/blocks-checkout.js 83.7 kB
release/woocommerce-payments/dist/checkout-rtl.css 318 B
release/woocommerce-payments/dist/checkout.css 319 B
release/woocommerce-payments/dist/checkout.js 35.9 kB
release/woocommerce-payments/dist/index-rtl.css 37 kB
release/woocommerce-payments/dist/index.css 37 kB
release/woocommerce-payments/dist/index.js 291 kB
release/woocommerce-payments/dist/multi-currency-analytics.js 1.05 kB
release/woocommerce-payments/dist/multi-currency-rtl.css 3.4 kB
release/woocommerce-payments/dist/multi-currency-switcher-block.js 61.2 kB
release/woocommerce-payments/dist/multi-currency.css 3.4 kB
release/woocommerce-payments/dist/multi-currency.js 56.6 kB
release/woocommerce-payments/dist/order-rtl.css 676 B
release/woocommerce-payments/dist/order.css 679 B
release/woocommerce-payments/dist/order.js 42.6 kB
release/woocommerce-payments/dist/payment-gateways-rtl.css 1.31 kB
release/woocommerce-payments/dist/payment-gateways.css 1.31 kB
release/woocommerce-payments/dist/payment-gateways.js 40.2 kB
release/woocommerce-payments/dist/payment-request-rtl.css 153 B
release/woocommerce-payments/dist/payment-request.css 153 B
release/woocommerce-payments/dist/payment-request.js 12.2 kB
release/woocommerce-payments/dist/product-details.js 919 B
release/woocommerce-payments/dist/settings-rtl.css 10.3 kB
release/woocommerce-payments/dist/settings.css 10.3 kB
release/woocommerce-payments/dist/settings.js 235 kB
release/woocommerce-payments/dist/subscription-edit-page.js 669 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal-rtl.css 519 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.css 519 B
release/woocommerce-payments/dist/subscription-product-onboarding-modal.js 19.4 kB
release/woocommerce-payments/dist/subscription-product-onboarding-toast.js 710 B
release/woocommerce-payments/dist/subscriptions-empty-state-rtl.css 117 B
release/woocommerce-payments/dist/subscriptions-empty-state.css 117 B
release/woocommerce-payments/dist/subscriptions-empty-state.js 18.4 kB
release/woocommerce-payments/dist/tos-rtl.css 230 B
release/woocommerce-payments/dist/tos.css 231 B
release/woocommerce-payments/dist/tos.js 20.9 kB
release/woocommerce-payments/dist/woopay-direct-checkout.js 2.06 kB
release/woocommerce-payments/dist/woopay-express-button-rtl.css 153 B
release/woocommerce-payments/dist/woopay-express-button.css 153 B
release/woocommerce-payments/dist/woopay-express-button.js 51.3 kB
release/woocommerce-payments/dist/woopay-rtl.css 4.18 kB
release/woocommerce-payments/dist/woopay.css 4.19 kB
release/woocommerce-payments/dist/woopay.js 70.9 kB
release/woocommerce-payments/includes/subscriptions/assets/css/plugin-page.css 622 B
release/woocommerce-payments/includes/subscriptions/assets/js/plugin-page.js 812 B
release/woocommerce-payments/vendor/automattic/jetpack-assets/build/i18n-loader.js 2.43 kB
release/woocommerce-payments/vendor/automattic/jetpack-assets/src/js/i18n-loader.js 1.01 kB
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-ajax.js 522 B
release/woocommerce-payments/vendor/automattic/jetpack-connection/dist/tracks-callables.js 581 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/babel.config.js 160 B
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.css 2.37 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.js 13.5 kB
release/woocommerce-payments/vendor/automattic/jetpack-identity-crisis/build/index.rtl.css 2.37 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/about.css 1.03 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-empty-state.css 291 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin-order-statuses.css 403 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/admin.css 3.6 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/checkout.css 299 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/modal.css 742 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/view-subscription.css 572 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/css/wcs-upgrade.css 411 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin-pointers.js 544 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/admin.js 9.4 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.js 6.8 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/jstz.min.js 3.83 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-coupon.js 544 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/meta-boxes-subscription.js 2.52 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.js 22.1 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/moment.min.js 11.6 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/payment-method-restrictions.js 1.29 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/admin/wcs-meta-boxes-order.js 502 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/payment-methods.js 355 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/single-product.js 429 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/view-subscription.js 1.38 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/frontend/wcs-cart.js 781 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/modal.js 1.1 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/assets/js/wcs-upgrade.js 1.27 kB
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.css 392 B
release/woocommerce-payments/vendor/woocommerce/subscriptions-core/build/index.js 3.05 kB

compressed-size-action

@vbelolapotkov vbelolapotkov force-pushed the update/translations-loading branch from 4c8a0ab to 355241b Compare January 19, 2024 15:07
@vbelolapotkov vbelolapotkov marked this pull request as ready for review January 19, 2024 15:39
@vbelolapotkov
Copy link
Collaborator Author

Note for the first reviewer: I think the code is not in the right place, but should work. Please focus on testing and validating solution at this point.

I'd appreciate the following recommendations:

  • the best place for this code.
  • how to log the process properly, I wasn't able to use Logger class.
  • how to test it.

Copy link
Contributor

@RadoslavGeorgiev RadoslavGeorgiev left a comment

Choose a reason for hiding this comment

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

Nice work, the code looks good, and works as advertised! 👌

Keep in mind that this is not a final review.

includes/class-wc-payments.php Outdated Show resolved Hide resolved
includes/class-wc-payments.php Outdated Show resolved Hide resolved
@vbelolapotkov
Copy link
Collaborator Author

vbelolapotkov commented Jan 26, 2024

@RadoslavGeorgiev I think it's ready for a final round of review and testing with fresh eyes before merging. FYI, it's not urgent, so can easily wait a bit longer than usual PRs.

Copy link
Contributor

@RadoslavGeorgiev RadoslavGeorgiev left a comment

Choose a reason for hiding this comment

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

A couple of comments for now, I'll test it thoroughly later today or on Monday.

@vbelolapotkov
Copy link
Collaborator Author

Notes on failing tests. None of the failures seem to be related to PR changes. More notes in slack: p1706873714162189-slack-CGGCLBN58

Copy link
Contributor

@RadoslavGeorgiev RadoslavGeorgiev left a comment

Choose a reason for hiding this comment

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

The changes look great, and translations are functioning. Thanks for working on this!

@vbelolapotkov
Copy link
Collaborator Author

Merging since failing checks are not related to this PR.

Fix for E2E tests is in #8123.
Compatibility tests failure is discussed in slack: p1707096486652309/1706873714.162189-slack-CGGCLBN58

@vbelolapotkov vbelolapotkov added this pull request to the merge queue Feb 5, 2024
Merged via the queue into develop with commit aa1e97d Feb 5, 2024
20 of 26 checks passed
@vbelolapotkov vbelolapotkov deleted the update/translations-loading branch February 5, 2024 09:32
@vbelolapotkov
Copy link
Collaborator Author

Testing instructions for 7.2.0 are updated: https://github.com/Automattic/woocommerce-payments/wiki/Release-testing-instructions-for-WC-Payments-7.2.0

No update for critical flows needed.

Nothing is changed in UI, plugin behavior, so not updating release notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants