-
Notifications
You must be signed in to change notification settings - Fork 383
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
Fix block validation errors caused by amp-fit-text deprecation #6872
Conversation
Plugin builds for d6f2460 are ready 🛎️!
|
Here's the definition of the problematic block pattern in Twenty Seventeen: https://github.com/WordPress/wordpress-develop/blob/2bbe1b7f40bda13fc6625aad6e3f1c0913566b39/src/wp-content/themes/twentyseventeen/inc/block-patterns.php#L145-L179 I think it may be causing problems because |
This, I think, is caused by the fact that the
Here's a docs fragment that explains how deprecations are handled (the emphasis at the end is mine):
It seems that adding our deprecation to the end of the list is reasonable since it will run after all core deprecations are executed (and thus hopefully cleaning up the mess that's not really AMP-related). Then I did a quick test to see if the console error you noticed has anything to do with the plugin. I've deactivated the AMP plugin, and then pasted an offending block markup from Twenty Seventeen pattern into a post content in the code editor mode: <!-- wp:paragraph {"style":{"typography":{"fontSize":21,"lineHeight":"2.5"}}} -->
<p style="font-size:21px;line-height:2.5"><p style="font-size:21px"><a href="#">' . __( 'Branding', 'twentyseventeen' ) . ' →</a><br><a href="#">' . __( 'Web Design', 'twentyseventeen' ) . ' →</a><br><a href="#">' . __( 'Web Development', 'twentyseventeen' ) . ' →</a></p></p>
<!-- /wp:paragraph --> After saving the post and refreshing, I received the same console error as reported above: And this has made me wonder even more as it appears that the It looks like the What I don't know is if this PR actually fixes the issue or just somehow masks it. |
✅ QA Passed. After changes, No longer able to reproduce block validation errors for paragraph block in "Twenty Seventeen" theme is active in WordPress 5.9 Also, It is migrating paragraph block using |
Summary
I noticed that the deprecation of
amp-fit-text
(#5729) started causing block validation errors to show up when the Twenty Seventeen theme is active as of WordPress 5.8.3 and 5.9. In 5.9 when I open the block inserter and select the Patterns tab and select Twenty Seventeen from the dropdown, I get these errors in the console:And the Services pattern shows those errors in the preview:
In WordPress 5.8.3 I see these errors and even more just when I open the editor without even opening the block inserter, with many mentioning
<amp-fit-text>
explicitly:I have no idea why this would be happening since the
isEligible
function for ouramp-fit-text
deprecation definition is returningfalse
. Nevertheless, I did notice that we were adding up six identical copies of our deprecation definition as the filter is being applied multiple times it seems. I found that ensuring the definition is only added once will prevent the errors from happening. I also found that usingpush
instead ofunshift
also fixes the issue. Since ouramp-fit-text
deprecation should be relatively rare, I decided to usepush
as well.Any insights into why this is happening and why the fix works would be much appreciated!
For reference, here is a paragraph block using
amp-fit-text
:This should still be migrated successfully as follows:
Checklist