Make WordPress Core

Opened 12 months ago

Last modified 7 days ago

#63909 accepted defect (bug)

Automatic excerpts: support lists in addition to columns and groups

Reported by: jeherve Owned by: audrasjb
Priority: normal Milestone: 7.2
Component: Editor Version: 6.1
Severity: normal Keywords: has-patch has-unit-tests 2nd-opinion commit
Cc: Focuses:

Description

In #53604, we made some changes so when automatically generating an excerpt from post content, we would better consider content inside inner blocks. r51382 added support for two main wrappers used in Core to house inner blocks: columns and groups.

I would like to suggest adding support for another commonly used wrapper in core: lists. This way, content from lists would be pulled in excerpts when possible.

Change History (15)

This ticket was mentioned in PR #9704 on WordPress/wordpress-develop by @jeherve.


12 months ago
#1

In #53604, we made some changes so when automatically generating an excerpt from post content, we would better consider content inside inner blocks. r51382 added support for two main wrappers used in Core to house inner blocks: columns and groups.

This commit adds support for another commonly used wrapper in core: lists. This way, content from lists would be pulled in excerpts when possible.

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

#2 @SirLouen
11 months ago

  • Component Posts, Post TypesEditor

#3 @audrasjb
4 months ago

  • Keywords needs-testing added
  • Milestone Awaiting Review7.1

Good point. The propose PR looks good to me, milestoning it to 7.1.

#4 @audrasjb
4 months ago

  • Owner set to audrasjb
  • Status newaccepted

This ticket was mentioned in Slack in #core-test by gaisma22. View the logs.


4 months ago

#6 @gaisma22
4 months ago

  • Keywords needs-testing removed

Patch Testing Report

Patch Tested: https://github.com/WordPress/wordpress-develop/pull/9704

Environment

  • WordPress: 7.0-beta6-62085-src
  • PHP: 8.3.30
  • Server: nginx/1.29.7
  • Database: MySQL 8.4.8
  • Browser: Brave
  • OS: Ubuntu 24.04
  • Theme: Twenty Twenty-Five 1.4
  • MU Plugins: None
  • Plugins: None

Steps Taken

  1. Created a new post using a List block with three items.
  2. Published without a custom excerpt.
  3. Checked the generated excerpt via the REST API at /wp-json/wp/v2/posts/13. Before patch: excerpt.rendered was completely empty. List content was not pulled into the excerpt at all.
  4. Applied PR #9704 and created a new post with the same steps. Checked /wp-json/wp/v2/posts/15. After patch: List items appear correctly in the excerpt.

✅ Patch is solving the problem

Expected Result

When WordPress generates an automatic excerpt from a post using a List block, the list item content should be included in the generated excerpt.

Additional Notes

  1. Bug confirmed on WordPress 7.0-beta6. List block content was completely ignored when generating automatic excerpts.
  2. After the patch, list content is correctly extracted and included in the excerpt.
  3. Removing needs-testing as patch resolves the issue on WordPress 7.0-beta6-62085-src.

Screenshots/Screencast with results

Before Patch:
https://i.ibb.co/P7tcttk/before-excerpt.png

After Patch:
https://i.ibb.co/LXRLsr17/after-excerpt.png

#7 @adrianduffell
2 weeks ago

It looks like the PR has approval. Is it ready to commit?

This ticket was mentioned in Slack in #core-test by noruzzaman. View the logs.


2 weeks ago

#9 @huzaifaalmesbah
2 weeks ago

Test Report

Patch tested: https://github.com/WordPress/wordpress-develop/pull/9704

Environment

  • WordPress: 7.1-beta4-62899-src
  • Subdirectory: No
  • PHP: 8.3.32
  • Server: nginx/1.31.3
  • Database: mysqli (Server: 9.7.2 / Client: mysqlnd 8.3.32)
  • Browser: Chrome 150.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.5
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.3.0

Steps taken

  1. Started with a clean WordPress 7.1-beta4 installation.
  2. Created a new post.
  3. Added a List block.
  4. Entered three list items:
  • Test 1
  • Test 2
  • Test 3
  1. Published the post without setting a manual excerpt.
  2. Retrieved the post using the REST API endpoint (/wp-json/wp/v2/posts/<post-id>).
  3. Confirmed that before applying the patch, the automatically generated excerpt was empty:
"excerpt": {
"rendered": "",
"protected": false
}
  1. Applied PR #9704.
  2. Reloaded the same REST API endpoint.
  3. Confirmed that the automatically generated excerpt now includes the List block content:
"excerpt": {
"rendered": "\u003Cp\u003ETest 1 Test 2 Test 3\u003C/p\u003E\n",
"protected": false
}

✅ Patch is solving the problem.

Expected result

  • Content inside the List block should be included when WordPress automatically generates a post excerpt.
  • The generated excerpt should be available through the REST API instead of returning an empty string.

Screenshots/Screencast with results

Video Demonstration

This ticket was mentioned in Slack in #core-test by huzaifaalmesbah. View the logs.


2 weeks ago

#11 @wildworks
2 weeks ago

  • Version 5.86.1

The cause of this issue is a regression introduced by the refactoring of the List block using inner blocks. When Gutenberg PR 42711 was merged, the logic for excerpt_remove_blocks() should have been updated simultaneously, but this was overlooked.

My understanding is that since WordPress 6.1, list blocks have never appeared in excerpts. PR 9704 certainly fixes a bug, and I'm personally fine with it shipping in 7.1, but I think we should be aware that it changes the excerpt output behavior that has been the same for several years and also changes the default values of the excerpt_allowed_wrapper_blocks() and excerpt_allowed_blocks() filters.

#12 @wildworks
12 days ago

  • Keywords 2nd-opinion added

This ticket was mentioned in Slack in #core by adrianduffell. View the logs.


11 days ago

#14 @joedolson
11 days ago

  • Milestone 7.17.2

If I understand this correctly, list blocks did appear in excerpts prior to the refactor, and lists always appeared in excerpts prior to the block editor. However, for any *recent* generated excerpts, list items would be missing, and adding them could be a notable change for users.

While I still think that this change should be made, as it's more predictable, I don't think it should be made at the last minute before RC, so I'm going to punt this to 7.2.

#15 @wildworks
7 days ago

  • Keywords commit added

PR 9704 is ready to be committed, but I will commit it to trunk after the branch for 7.1 has been created.

Note: See TracTickets for help on using tickets.