-
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
Broken Deprecation on core/block
deletes templateLock
when false
#49159
Comments
Looking some more I think these (2918b80, #36264) are related in that the string/bool for the I also wonder if the deprecation migration for the even older version of the group block with the double-div might also be affected. |
Yeah, same problem with the second migration. Updated code also fixes it for that:
(Yeah, I know this could be written better but since it is just a proof of concept...) |
@Mamaduka Looking at it again today I think the fix in #49205 was incomplete since for the earlier migration the type is still wrong: gutenberg/packages/block-library/src/group/deprecated.js Lines 138 to 140 in b93fd88
This is what I mentioned in the comment above. |
Hi, @kraftner I saw the original comment, but I think changes weren't required for that deprecation. The deprecation attributes are a "snapshot" of block attributes at a (deprecation) creation time. Looking at the PR introducing deprecation #29335, you can see that the "templateLock" type is still a string. |
I am aware how they work, but looking at #36264 (where the type got changed) I got the impression that might have been an error itself. Or are you saying that the bug in #36264 means at that point it wasn't even possible to save Sorry if I am wrong, just double-checking. 😄 |
Oh, you're right. When the deprecation was created, it copied the attribute of the wrong type, which later got fixed for the block but not for the deprecation. I'll create a new PR later today or tomorrow. Thanks, @kraftner! |
Description
The latest deprecation migration for a
core/group
block discards thetemplateLock
set on that block if the value isn't one of the string values but the also validfalse
.Step-by-step reproduction instructions
templateLock
gets removed instantly turning this into:If you want to see a more real world flow:
core/group
block that doesn't have layout set but atemplateLock
value offalse
.There are two ways how to do this:
post_content
in the database so it looks like this:post_content
now looks like this:Screenshots, screen recording, code snippet
Video demonstrating the issue:
templateLock.webm
The problem seems to be the deprecation migration to add the default layout, specifically the fact that the
templateLock
attribute is wrongly defined as string only:gutenberg/packages/block-library/src/group/deprecated.js
Lines 52 to 54 in b7c693b
while it can also be bool:
gutenberg/packages/block-library/src/group/block.json
Lines 15 to 18 in b7c693b
This then leads to the bool attribute being dropped since it is considered invalid but any other string value like
all
does indeed survive:templateLock2.webm
This is further proven by the fact that adding this snippet does resolve the issue at hand:
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: