-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Avoid stripping attributes via group block migration when no layout is specified #63837
Conversation
Size Change: -2 B (0%) Total Size: 1.76 MB
ℹ️ View Unchanged
|
layout?.inherit || | ||
( layout?.contentSize && layout?.type !== 'constrained' ), |
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 fix makes sense. The deprecation is eligible when only experimental layout values are present and not when layout values are missing.
Ref: #57544 (comment)
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
While playing with the code, I noticed that returning It's not a blocker for this fix, but it's probably worth investigating separately. ScreencastCleanShot.2024-07-23.at.11.35.08.mp4 |
Fixes #63820
What?
Fixes a group block deprecation/migration that's a little too far reaching, and is causing attribute values to be stripped from perfectly valid blocks.
Why?
When a deprecation is run, it uses the list of attributes in the deprecation to filter out extraneous attribute values on the incoming parsed block.
In this case, the group block has a deprecation and migration that can match valid group blocks because the
isEligible
function on the deprecation forces the deprecation to run wheneverlayout
is not defined. According to the group block's definition and layout support, it's perfectly valid not to setlayout
, a default value will be assumed.The problem is that the group block has some newer attributes (
allowedBlocks
andtemplateLock
) not included in the deprecation that are being stripped by the deprecation because of the wayisEligible
matches so easily.How?
I noticed that when
isEligible
matches because of the! layout
clause, it then triggers this early return in the migration:It returns the unmodified attributes (and without
templateLock
andallowedBlocks
because of the way deprecations work). I couldn't see much point to this code, so this PR fixes the issue by deleting it.It does leave me wondering if there is a purpose to the code being removed that I'm not seeing. It might be that in the original PR it seemed harmless so it flew under the radar during code review and these future problems were quite hard to anticipate.
Testing Instructions
Expected: the block is in
contentOnly
mode due to the attribute in the snippetScreenshots or screencast