-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Block patterns with 6.1 format markup throwing console errors in 6.0 sites #45179
Comments
Thanks for reporting this @WildeWebMarketing. I think this is covered by this existing issue, so going to close this one for now. |
Actually this one looks slightly different to the one I linked, so reopening until that is confirmed. |
@WildeWebMarketing are you able to confirm which version of WP you are using when you see these errors, and whether you have the Gutenberg plugin installed and enabled and which version. Also, have you enable the Gutenberg plugin at any point and then disabled it? or copied content from a site that may be running a newer version of WP/Gutenberg? |
I'm using WordPress Version 6.0.3. I do not have the Gutenberg plugin installed and it was not installed at any point. No content from external sites. I appreciate your attention to this @glendaviesnz |
@glendaviesnz I have also checked multiple installations on different servers and the problem is present in those as well. |
@WildeWebMarketing looks like an issue with block patterns. We will try and work out why these incompatible patterns are being pulled into 6.0.3 sites. |
Update:
Since this is affecting WP 6.0.x where patterns are fetched remotely in core, as a short-term fix, this pattern has been unpublished so that it won't show up in the pattern inserter. It appears to be the only one of the "remotely fetched by default" patterns that was throwing errors in WP 6.0 as far as I could tell from my test site. Longer-term, @noisysocks suggested that one way to solve it could be if patterns in the pattern directory had a Thanks @tellyworth for the assistance, and just pinging @ryelle for visibility. |
Awesome, thank you! Errors are gone. |
I think this would get tricky because of the Gutenberg plugin + WP core combinations possible. Would it be possible for the inserter to somehow check for validation errors at the client side, and prevent rendering those? |
Technically yes. To do this you'd recurse through the tree of |
Oh, that's an interesting idea. I quite like that as a longer-term solution to ensuring that patterns don't break the UI. It'd be good for us to ensure that we're still logging something to the console for patterns that break in themes, so that theme developers can investigate and update patterns as needed (and know which ones are broken). I suppose a challenge with this idea is that it would only really help us for WordPress 6.2 and beyond — for WordPress 6.0, any patterns for later versions will still throw an error in the UI. I think that's one of the reasons I quite liked the idea of a minimum version in the API of the pattern directory. If we had it that a default API response included patterns compatible with 6.0, then we could potentially introduce a param to be passed with the request in subsequent WP releases, that told the pattern directory to return patterns that support a newer WP release? Given the timing of 6.1 and that the final RC is about to come out, whichever fix we go with appears to be pretty tricky to roll out 🤔 |
There was a suggestion in this comment #43395 (comment) about a new debugging constant for theme developers, could help here too — when "
I don't think that would really help older versions either though, because we haven't been tracking gutenberg versions for the existing patterns. 🤔 Maybe we could add some temporary post meta (via a sandbox) to any problem-patterns that are being loaded in WP (was it just this one?) and use the passed |
This is a long standing known issue and I also believe a minimum version field is needed. Do you find any problems by checking only against WP? That means that all the patterns in PD should have been created at most the current stable WP version and not with GB. What do you think? |
That's not the pattern directory environment, though. Since it's part of the w.org multisite, it runs WP trunk and the latest Gutenberg release. At launch, we needed GB because the Creator needed some unstable APIs to work. I'm not sure if that's still the case, so we could possibly disable GB on the Directory site, but it will still run WP trunk. |
In WordPress/pattern-directory#536 I added a check for the requesting site's WP version, and any pattern tagged with a higher version number will not be returned in the API response. I've also re-published the Link in Bio pattern with a minimum version of 6.1, so if you're on 6.1+ you should now see that pattern in the "Featured" category in the editor (the API result is locally cached, so it might take an hour to show up). If you're still on 6.0, the pattern won't show up (even if you have Gutenberg installed). Pattern versions are added manually, so I still see this as a short-term fix, with client-side validation as a more effective fix. |
I'm closing this issue as the reported pattern has been fixed and this is something that needs to be handled in Pattern Directory, which is quite convoluted as explained in this PD PR: WordPress/pattern-directory#536. |
In a fresh 6.0.3 site without GB plugin installed, some patterns with 6.1 format markup, like this one, are being pulled into the editor in the background and causing block invalidation errors as the 6.0 version of the editor does not recognise the markup.
Clicking edit for a post was taking longer than usual to get to the editing screen. Opened up the inspect console and there are lots of validation errors, like:
Block
validation: Block validation failed forcore/button
({name: 'core/button', icon: {…}, keywords: Array(1), attributes: {…},providesContext:
{…}, …}).generated by
savefunction:
<div
class="wp-block-button has-custom-width wp-block-button__width-100">Watch mylatest videos</a></div>
Content
retrieved from post body:class="wp-block-button has-custom-width wp-block-button__width-100"><a class="wp-block-button__link wp-
element-button">Watch my latest `videosThe text was updated successfully, but these errors were encountered: