-
Notifications
You must be signed in to change notification settings - Fork 815
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
Subscriptions Block: Stop saving localized attributes defaults in the block content #16361
Subscriptions Block: Stop saving localized attributes defaults in the block content #16361
Conversation
Thank you for the great PR description! When this PR is ready for review, please apply the E2E results is available here (for debugging purposes): https://jetpack-e2e-dashboard.herokuapp.com/pr-16361 Scheduled Jetpack release: August 4, 2020. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, and works as advertised. At some point we should remove the shortcode implementation, but that's for another PR 🚢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to need a rebase to fix those unrelated test failures, I'm afraid. Thank you!
When a block is created in English and the site switched to a second langauge before the block is migrated, the block will be deemed invalid. This change will attempt to fall back to English defaults for the placeholder text in the saved shortcode that causes the invalidation. This will not change migrated attributes only the generated content from the deprecated block save function. It also will only cover blocks first created in English and using default text. If the block was created in a second language, there is no means to determine the language and therefore the default text for that translation to fall back to.
e93e8d5
to
58d11ef
Compare
Rebase ✅ |
Caution: This PR has changes that must be merged to WordPress.com |
This one was rebased already. D46159-code has been updated with new files. |
extensions/blocks/subscriptions/deprecated/v3/get-subscriptions-shortcode.js
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tests well for me. 👍
r211582-wpcom |
Fixes #15776
Changes proposed in this Pull Request:
The Subscriptions block has two attributes with localized default values which are saved in the block content as shortcode attributes. Changing the site language will break the block validation, because the strings are saved in the previous language, while the validator expects them to be in the new language.
In this PR we stop adding those attributes to the shortcode if they are the same as the default (haven't been changed by the user).
The shortcode will take care of those missing attributes by using its own defined defaults.
Note
There have been two deprecated versions added. The first handles the normal migration when the language hasn't changed. The second almost identical one, allows for the placeholder text, if left to default values, to fall back to the known English version of the text. It does not change the attribute values just the generated content from the deprecated save so the block isn't invalidated.
Unfortunately, this will only be able to solve the case when the block was created in English, the site switched to a new language and then the block loaded in the editor again afterwards. If the block was created in a non-English language then the site switched to English, we don't know what the original default text should be so can't fallback to it.
Migrating the block and saving the post before changing the language would fix it.
Repro steps:
Working steps:
Does this pull request change what data or activity we track or use?
No.
Testing instructions:
E.g.
/wp-admin/options-general.php
, and make sure you also install the new language pack in/wp-admin/update-core.php
.Proposed changelog entry for your changes: