WordPress.org

Make WordPress Core

Opened 4 weeks ago

Closed 3 weeks ago

#53604 closed defect (bug) (fixed)

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

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

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
4 weeks ago

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

#2 @aristath
4 weeks ago

  • Summary changed from Excerpt block doesn't handle innerBlocks for groups and nested columns to Excerpts don't handle `innerBlocks` for groups and nested columns properly
  • Version set to trunk

#3 @desrosj
4 weeks ago

  • Keywords needs-unit-tests added
  • Milestone changed from Awaiting Review to 5.9

Added some feedback on the PR.

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

#4 @aristath
4 weeks 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
4 weeks ago

  • Component changed from General to Formatting
  • Keywords needs-unit-tests added
  • Milestone changed from 5.9 to 5.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
4 weeks ago

  • Component changed from Formatting to Posts, Post Types

#7 @aristath
4 weeks ago

Thank you @desrosj! 👍

#8 @desrosj
4 weeks ago

  • Owner set to desrosj
  • Resolution set to fixed
  • Status changed from new to closed

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
4 weeks ago

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

Reopening for backport consideration.

#10 @jorbin
4 weeks 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
4 weeks 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.


4 weeks ago

Adds an excerpt_allowed_wrapper_blocks filter.

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

#13 @aristath
4 weeks 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
4 weeks ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

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

#15 @desrosj
3 weeks 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
3 weeks ago

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

#18 @SergeyBiryukov
3 weeks ago

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

#19 @jorbin
3 weeks ago

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

#20 @jorbin
3 weeks ago

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

#21 @jorbin
3 weeks 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
3 weeks ago

  • Keywords dev-reviewed added; dev-feedback removed

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

#23 @jorbin
3 weeks ago

  • Resolution set to fixed
  • Status changed from reopened to closed

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.