Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#53604 closed defect (bug) (fixed)

Excerpts don't handle `innerBlocks` for groups and nested columns properly

Reported by: aristath Owned by: desrosj
Priority: normal Milestone: 5.8
Component: Posts, Post Types Version: 5.8
Severity: normal Keywords: has-patch has-unit-tests commit fixed-major dev-reviewed
Cc: Focuses:

Description (last modified by aristath)

See https://github.com/WordPress/gutenberg/issues/33154 for details.

When generating a post excerpt, we run the content through
excerpt_remove_blocks. That function doesn't currently handle innerBlocks for groups properly, as well as deeply-nested columns, resulting in empty excerpts.

Change History (23)

#1 @aristath
5 years ago

  • Description modified (diff)
  • Keywords has-patch added
  • Summary Excerpt block doesn't render group block innerBlocksExcerpt block doesn't handle innerBlocks for groups and nested columns

#2 @aristath
5 years ago

  • Summary Excerpt block doesn't handle innerBlocks for groups and nested columnsExcerpts don't handle `innerBlocks` for groups and nested columns properly
  • Versiontrunk

#3 @desrosj
5 years ago

  • Keywords needs-unit-tests added
  • Milestone Awaiting Review5.9

Added some feedback on the PR.

It would also be nice to get some unit tests added here.

#4 @aristath
5 years ago

  • Keywords needs-unit-tests removed

Added some feedback on the PR.

Feedback addressed

It would also be nice to get some unit tests added here.

Tests added :)

#5 @desrosj
5 years ago

  • Component GeneralFormatting
  • Keywords needs-unit-tests added
  • Milestone 5.95.8

Thanks @aristath!

Just to pull in some context here, @aristath mentioned on the PR that it's desired to have this in 5.8.

Moving to 5.8 to consider.

#6 @desrosj
5 years ago

  • Component FormattingPosts, Post Types

#7 @aristath
5 years ago

Thank you @desrosj! 👍

#8 @desrosj
5 years ago

  • Owner set to desrosj
  • Resolutionfixed
  • Status newclosed

In 51348:

Posts: Prevent an empty excerpt when groups and nested column blocks are present.

This improves the logic within excerpt_remove_blocks() to better handle innerBlocks. This prevents an empty excerpt from being returned when core/columns, core/column, and core/group blocks are present.

This issue has been surfaced in the Query Loop block, where excerpts can be set to display.

Props aristath.
Fixes #53604.

#9 @desrosj
5 years ago

  • Keywords has-unit-tests commit dev-feedback fixed-major added; needs-unit-tests removed

Reopening for backport consideration.

#10 @jorbin
5 years ago

@desrosj brought up in the code review including a filter and I feel like this is the right move. I don't think we should wait for 5.9 as it is going to make it more difficult for people that build custom blocks if we don't have it now.

#11 @desrosj
5 years ago

@aristath would you be able to create a follow up PR adding a filter? I'll wait to backport until after the filter is in.

This ticket was mentioned in PR #1479 on WordPress/wordpress-develop by aristath.


5 years ago
#12

Adds an excerpt_allowed_wrapper_blocks filter.

Trac ticket: https://core.trac.wordpress.org/ticket/53604

#13 @aristath
5 years ago

@aristath would you be able to create a follow up PR adding a filter? I'll wait to backport until after the filter is in.

Of course. Filter added in https://github.com/WordPress/wordpress-develop/pull/1479

#14 @desrosj
5 years ago

  • Resolution fixed
  • Status closedreopened

Never actually reopened this one. Reviewing the filter patch now.

#15 @desrosj
5 years ago

In 51375:

Posts: Allow the list of wrapper blocks to be filtered.

This introduces the excerpt_allowed_wrapper_blocks filter for controlling which blocks should be considered wrapper blocks.

Wrapper blocks and their nested contents are not stripped by excerpt_remove_blocks(), allowing their contents to appear in generated excerpts.

Follow up to [51348].

Props aristath, jorbin.
See #53604.

#16 @desrosj
5 years ago

@jorbin Can you review [51375] for backport when you have a chance?

#18 @SergeyBiryukov
5 years ago

There's a "warppers" typo in the filter description, looks good to backport otherwise.

#19 @jorbin
5 years ago

Typo fixed, we should be good to backport all 3 together.

#20 @jorbin
5 years ago

[51378] didn't show up, but that is where the typo is fixed.

#21 @jorbin
5 years ago

In 51379:

Fix merge info.

[51378] contained merge info it shouldn't and accidentally a line of code from one of those commits that another one had changed.

See #53604.
Unprops jorbin.

#22 @desrosj
5 years ago

  • Keywords dev-reviewed added; dev-feedback removed

[51378] and [51379] look good to backport.

#23 @jorbin
5 years ago

  • Resolutionfixed
  • Status reopenedclosed

In 51382:

Posts: Prevent an empty excerpt when groups and nested column blocks are present.

This improves the logic within excerpt_remove_blocks() to better handle innerBlocks. This prevents an empty excerpt from being returned when core/columns, core/column, and core/group blocks are present.

This issue has been surfaced in the Query Loop block, where excerpts can be set to display.

This introduces the excerpt_allowed_wrapper_blocks filter for controlling which blocks should be considered wrapper blocks.

Wrapper blocks and their nested contents are not stripped by excerpt_remove_blocks(), allowing their contents to appear in generated excerpts.

Backports [51348], [51375], [51378], and [51379] to the 5.8 branch.

Fixes #53604.
Props aristath, jorbin, SergeyBiryukov, desrosj.
Unprops jorbin.

Note: See TracTickets for help on using tickets.