Skip to content
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

Reinstate correct cover block attributes for deprecations #15449

Merged
merged 5 commits into from May 6, 2019

Conversation

talldan
Copy link
Contributor

@talldan talldan commented May 6, 2019

Description

Fixes #15441

The incorrect attributes were specified in the deprecated.js file for the cover block. It looks like the attributes for the button block were accidentally pasted into the file instead of the attributes for the cover block.

How has this been tested?

  1. Roll back to a past version of Gutenberg (I used 5.2)
  2. Created a new post with a cover block and save it
  3. Roll forwards to the latest version of Gutenberg
  4. Open up the post created in step 2.
  5. Observe that the cover block fails validation
  6. Checkout this branch and reload the post
  7. Observe that the block works again.

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.

Copy link
Member

@gziolo gziolo left a comment

I must have copied those attributes from the wrong file... 😅 I will test this PR as soon as I get to my desktop 👍

We will need to add integration test for this deprecated versions of block, similar to what I do in #15268.

@talldan
Copy link
Contributor Author

talldan commented May 6, 2019

Thanks @gziolo. I still have the block markup, so I can add an integration test. I'll just break for some lunch and then add one. 👍

@gziolo
Copy link
Member

gziolo commented May 6, 2019

Thanks @gziolo. I still have the block markup, so I can add an integration test. I'll just break for some lunch and then add one. 👍

It would be awesome. When you have HTML markup, you just need to put it in the proper folder following the pattern used for other files. Then you run npm run fixtures:regenerate and 3 remaining files will get generated :)

@talldan talldan requested review from aduth, nerrad and ntwb as code owners May 6, 2019
@talldan
Copy link
Contributor Author

talldan commented May 6, 2019

@gziolo I've added one for the latest deprecation, but there are a couple of older ones still. Is it worth going back through all the past deprecations for the cover block and adding those too? If so, would the idea be to add the markup to the same core__cover__deprecated file, or create new files (core__cover__deprecated_1, core__cover__deprecated_2)?

@gziolo
Copy link
Member

gziolo commented May 6, 2019

@gziolo I've added one for the latest deprecation, but there are a couple of older ones still. Is it worth going back through all the past deprecations for the cover block and adding those too? If so, would the idea be to add the markup to the same core__cover__deprecated file, or create new files (core__cover__deprecated_1, core__cover__deprecated_2)?

In #15268 @ellatrix suggested to include new file per deprecation entry, so let's try to do it here as well. I think, you will have to use core__cover__deprecated-1.html. Well, the existing names aren't consistent but it is closer to how file names are handled in general.

@talldan talldan force-pushed the fix/cover-block-deprecated-attributes branch from a5b3f52 to 379efb0 Compare May 6, 2019
@@ -0,0 +1,3 @@
<!-- wp:cover {"url":"https://cldup.com/uuUqE_dXzy.jpg","id":35} -->
<div class="wp-block-cover has-background-dim" style="background-image:url(https://cldup.com/uuUqE_dXzy.jpg)"><p class="wp-block-cover-text"><strong>Cover Block</strong></p></div>
Copy link
Member

@gziolo gziolo May 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you copy one of the existing images encoded with data:*. I think @jorgefilipecosta updated all urls to avoid network calls in tests or something like that.

@talldan
Copy link
Contributor Author

talldan commented May 6, 2019

@gziolo Wasn't straightforward getting markup for the older deprecations, just about managed it. 😄

I've added those fixtures the way we discussed. If another deprecation is added, all someone has to do is add a core__cover__deprecated-4.html file and regenerate.

🤞 the tests pass.

@@ -0,0 +1,3 @@
<!-- wp:cover {"url":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==","id":34,"className":"wp-block-cover-image"} -->
Copy link
Member

@gziolo gziolo May 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look it gets converted properly.

Copy link
Contributor Author

@talldan talldan May 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Managed to figure this one out as well. Had to add:

		supports: {
			className: false,
		},

So that the change in class name from wp-block-cover-image to wp-block-cover works correctly.

Also added a migration function so that the inner text content is converted to a paragraph block.

@@ -0,0 +1,3 @@
<!-- wp:cover {"url":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==","id":34} -->
<div class="wp-block-cover has-background-dim" style="background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==)"><div class="wp-block-cover__inner-container"></div></div>
Copy link
Member

@gziolo gziolo May 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<strong>Cover Block</strong> is missing in the output.

Copy link
Contributor Author

@talldan talldan May 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now resolved by adding a migration function.

gziolo
gziolo approved these changes May 6, 2019
Copy link
Member

@gziolo gziolo left a comment

Awesome work @talldan. Now, I think it's essential to keep all deprecations covered with integration tests to ensure they don't regress in the future. Thanks for fixing all bugs down the road :)

@gziolo gziolo merged commit d137b09 into master May 6, 2019
1 check passed
@gziolo gziolo deleted the fix/cover-block-deprecated-attributes branch May 6, 2019
sbardian pushed a commit to sbardian/gutenberg that referenced this issue Jul 29, 2019
…15449)

* Reinstate correct cover block attributes for deprecations

* Add fixtures for deprecated cover block

* Add fixtures for all deprecations of cover block

* Upgrade second deprecation to migrate to inner blocks version of cover block

* Fix oldest cover block deprecation
dd32 pushed a commit to dd32/gutenberg that referenced this issue Sep 27, 2019
…15449)

* Reinstate correct cover block attributes for deprecations

* Add fixtures for deprecated cover block

* Add fixtures for all deprecations of cover block

* Upgrade second deprecation to migrate to inner blocks version of cover block

* Fix oldest cover block deprecation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Cover [Type] Bug An existing feature is broken.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants