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

BUG: Infinite loop when using excerpt highlighting with posts that use blocks that print an excerpt #3695

Closed
1 task done
JakePT opened this issue Oct 10, 2023 · 0 comments · Fixed by #3867
Closed
1 task done
Assignees
Labels
bug Something isn't working
Milestone

Comments

@JakePT
Copy link
Contributor

JakePT commented Oct 10, 2023

Describe the bug

When we add highlighting to an excerpt, we do so with the get_the_excerpt filter, and in our callback we get the full post content and apply the the_content filter to it.

$text = get_the_content( '', false, $post );
$text = apply_filters( 'the_content', $text );

The problem is that if the post contains a Query Loop block with a Post Excerpt block, or any other block that uses the_excerpt(), an infinite loop will occur.

As per a comment, our callback "reproduces wp_trim_excerpt filter", but it appears to be out of date. The latest version of wp_trim_excerpt() in core appears to use excerpt_remove_blocks(), which excludes the query loop blocks from the excerpt, which would avoid the issue. We will need to do something similar.

Steps to Reproduce

  1. Enable Excerpt highlighting.
  2. Create a Post with a Query Loop block and a Post Excerpt block inside the Post Template block.
  3. Search for that post. A timeout or memory limit error should occur.

Screenshots, screen recording, code snippet

No response

Environment information

No response

WordPress and ElasticPress information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@JakePT JakePT added the bug Something isn't working label Oct 10, 2023
@felipeelia felipeelia modified the milestones: 5.0.0, 5.1.0 Oct 17, 2023
@JakePT JakePT assigned felipeelia and unassigned JakePT Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants