Repository navigation
Comments Pagination Next: Remove the link filter from the right hook - #85244
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Updated as activity occurs, without notifying anyone named here. Add the ⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
🏁 Flaky testsSome tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information. Regression: updating a specific option will only change its value and will not corrupt others in
|
The block added its link attributes filter to next_comments_link_attributes but removed it from next_posts_link_attributes, so the filter stayed attached for the rest of the page load. Remove it from the hook it was added to, and add a test.
f72a2e1 to
900ab3b
Compare
|
I ended up removing the unit test here as overkill. If you'd rather test via automated test you can check out the prior commit instead of manually testing via the PR test instructions. |
andrewserong
left a comment
There was a problem hiding this comment.
The removal matches the add_filter call, and with manual testing I'm seeing bool(false) logged 👍
I think this is fine without the unit test, it's unlikely to regress now that the names match.
LGTM!
What?
Comments Next Page now removes its link attributes filter after it renders the link.
Why?
The block adds a filter to
next_comments_link_attributesbut removes it fromnext_posts_link_attributes. So the filter is never removed.It stays attached for the rest of the page load and runs on every later
get_next_comments_link()call. The Comments Previous Page block already uses the same hook for both calls.How?
Change the
remove_filter()hook tonext_comments_link_attributes.Testing Instructions
functions.php:bool(true). This branch printsbool(false).Use of AI Tools
Claude Code wrote the fix. I reviewed it.