-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix: Excerpt limit is overruled (#48403) #48598
base: trunk
Are you sure you want to change the base?
Conversation
REST_REQUEST constant was mistakenly quoted, which caused the condition to always evaluate to true. And the conditional logic should be AND, not OR.
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @tmanhollan! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
Thanks for the quick pull request and initial report. This PR did fix the issue of the |
Thank you, @skorasaurus, you're right. I think there are two problems: primarily, the condition is not being evaluated in the correct context. It should be inside the callback; in the outer scope I think it's happening before I'm making that revision now. But I don't think |
Outer scope happens before the constant is set.
Thanks; with your latest commit, the post_excerpt block was now working again within the editor although someone else had caught it and fixed it (#48654) but they didn't wrap it up in a callback. I haven't checked yet if their commit, already merged into trunk fixes all of these issues. |
Query loop block: (using #48654) excerpt_length hook is set to 50 for #48598 as of https://github.com/WordPress/gutenberg/blob/21367410f67674fd5ecfe9d0280c42c62d81daf4/packages/block-library/src/post-excerpt/index.php excerpt_length hook is set to 50 excerpt_length hook is set to 50 |
I think I see the problem in the front end. It's not loaded via REST like it is in the editor, so the condition in the filter is not satisfied (the only reason it was originally is that the condition always returned true because of the quoted constant). I think we need another excerpt_length filter applied in |
The filter that is conditional upon REST_REQUEST does not apply when the block content is rendered in the front end. This added filter serves the same purpose when rendering the block for the front end.
Ok I think this last revision makes the front end and editor consistent and excerpts that are not part of a block obey the value returned by the excerpt_length hook. excerpt_length hook is set to 50 excerpt_length hook is set to 50 |
(For anyone new coming to this: even though the original issue #48403 is closed; this should be kept open to determine whether this is an improvement of #48654; also see review at #44964 (review) in #44964 |
I am not able to do the code review, I am not confident I would get it right since I caused the bugs last time. |
What?
REST_REQUEST constant was mistakenly quoted, which caused the condition to always evaluate to true. And the conditional logic should be AND, not OR.
Why?
Issue #48403 describes the problem. Excerpt length is overridden always, rather than just in the editor as intended.
How?
Fixes the conditional logic so implementations of excerpt_length filter hook will only be overridden in the block editor.
Testing Instructions
Testing Instructions for Keyboard
n/a
Screenshots or screencast
n.a