Skip to content

Comments Pagination Next: Remove the link filter from the right hook - #85244

Merged
aaronrobertshaw merged 3 commits into
trunkfrom
fix/comments-pagination-next-filter-hook
Oct 21, 2026
Merged

aaronrobertshaw merged 3 commits into
trunkfrom
fix/comments-pagination-next-filter-hook

Conversation

@aaronrobertshaw

@aaronrobertshaw aaronrobertshaw commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

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_attributes but removes it from next_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 to next_comments_link_attributes.

Testing Instructions

  1. In Settings > Discussion, turn on "Break comments into pages" with 2 comments per page, oldest first.
  2. Add 4 comments to a post. Use a block theme whose single template has the Comments block.
  3. Add this to a plugin or functions.php:
add_action( 'wp_footer', function () {
	var_dump( has_filter( 'next_comments_link_attributes' ) );
} );
  1. View the post. Trunk prints bool(true). This branch prints bool(false).

Use of AI Tools

Claude Code wrote the fix. I reviewed it.

@aaronrobertshaw aaronrobertshaw added [Type] Bug An existing feature does not function as intended [Package] Block library /packages/block-library labels Oct 20, 2026
@aaronrobertshaw aaronrobertshaw self-assigned this Oct 20, 2026
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>

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 props-bot label to refresh.

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 0aae616 trunk % Change
timeToFirstByte 55.7 ms +15.62% -4.04% 55.1 ms +5.08% -5.08% 1.09%
largestContentfulPaint 92 ms +10.87% -4.35% 88 ms +4.55% -2.27% 4.55%
lcpMinusTtfb 35.2 ms +10.37% -2.56% 32.9 ms +7.6% -1.52% 6.99%
wpBeforeTemplate 30.76 ms +14.95% -7.18% 28.71 ms +5.36% -3.27% 7.14%
wpTemplate 21.55 ms +6.03% -3.9% 21.33 ms +5.44% -2.06% 1.03%
wpTotal 51.83 ms +14.68% -4.34% 51.16 ms +5.9% -4.65% 1.31%
wpMemoryUsage 7.65 MB +0% -0% 7.61 MB +0% -0% 0.46%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 0aae616 trunk % Change
timeToFirstByte 46.25 ms +6.7% -2.92% 46.3 ms +9.29% -1.62% -0.11%
largestContentfulPaint 100 ms +4% -0% 100 ms +4% -0% 0%
lcpMinusTtfb 54.8 ms +1.64% -1.92% 53.75 ms +1.77% -3.16% 1.95%
wpBeforeTemplate 26.68 ms +10.12% -3.26% 26.24 ms +8.77% -1.22% 1.68%
wpTemplate 16.35 ms +3.24% -1.35% 17.04 ms +1.64% -4.52% -4.05%
wpTotal 43.12 ms +7.51% -2.71% 43.16 ms +9.94% -1.55% -0.09%
wpMemoryUsage 6.34 MB +0% -0% 6.30 MB +0% -0% 0.57%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 0aae616 trunk % Change
mediaProcessingJpeg 397.77 ms +2.58% -0.45% 398.62 ms +1.22% -0.23% -0.21%
mediaProcessingAvif 6117.7 ms +0.23% -0.13% 6146.82 ms +0.86% -0.15% -0.47%
mediaProcessingJpegToAvif 4230.46 ms +0.05% -0.04% 4243.34 ms +0.34% -0.03% -0.3%

media-upload

Metric 0aae616 trunk % Change
jpegUploadProcessing 1958.92 ms +0.46% -1.28% 1922.67 ms +0.8% -0.19% 1.89%
pngUploadProcessing 179.2 ms +31.68% -7.94% 178.69 ms +33.09% -3.54% 0.29%
largeJpegUploadProcessing 1939.26 ms +0.43% -0.31% 1918.86 ms +0.35% -0.53% 1.06%
multipleImageUploadProcessing 2016.6 ms +1.35% -0.49% 2046.57 ms +0.72% -2.52% -1.46%

post-editor

Metric 0aae616 trunk % Change
serverResponse 418.34 ms +5.28% -10.64% 407.98 ms +6.44% -5.76% 2.54%
firstPaint 499.22 ms +9.53% -31.64% 430.29 ms +23.9% -34.82% 16.02%
domContentLoaded 1140.83 ms +3.37% -1.95% 1160.83 ms +1.92% -2.06% -1.72%
loaded 1142 ms +3.37% -1.92% 1162.1 ms +1.92% -2.05% -1.73%
firstContentfulPaint 499.22 ms +9.53% -31.64% 512.08 ms +4.11% -40.79% -2.51%
firstBlock 3379.39 ms +1.61% -1.42% 3475.37 ms +2.64% -1.53% -2.76%
type 18.94 ms +3.54% -2.16% 20.46 ms +2.59% -4.11% -7.43%
typeWithoutInspector 19.58 ms +3.12% -1.58% 19.78 ms +2.53% -3.84% -1.01%
typeWithTopToolbar 24.88 ms +12.42% -5.27% 24.05 ms +4.03% -0.71% 3.45%
typeContainer 9.52 ms +10.4% -5.36% 8.65 ms +4.86% -3.24% 10.06%
focus 124.59 ms +3.28% -5.92% 123.49 ms +7.29% -3.55% 0.89%
firstFocus 319.56 ms +0% -0% 243.8 ms +0% -0% 31.07%
selectAll 599.81 ms +1.47% -2.29% 565.3 ms +5.17% -2.7% 6.1%
listViewOpen 84.87 ms +7.03% -3.68% 77.79 ms +17.32% -4.36% 9.1%
inserterOpen 42.4 ms +21.75% -3.96% 41.57 ms +8.78% -9.29% 2%
inserterHover 12.78 ms +8.22% -7.12% 12.86 ms +5.91% -6.84% -0.62%
inserterSearch 8.95 ms +2.12% -6.82% 8.82 ms +1.81% -8.16% 1.47%
loadPatterns 661.32 ms +4.35% -2.41% 726.39 ms +0.95% -5.29% -8.96%
wpTotal 407.54 ms +5.04% -11% 397.35 ms +6.53% -5.9% 2.56%
wpMemoryUsage 14.66 MB +0% -0% 14.63 MB +0% -0% 0.23%
wpDbQueries 55 +0% -1.82% 55 +0% -1.82% 0%

site-editor

Metric 0aae616 trunk % Change
serverResponse 488.1 ms +6.17% -4.29% 495.82 ms +11.18% -4.06% -1.56%
firstPaint 294.97 ms +9.11% -23.68% 295.58 ms +9.06% -10.49% -0.21%
domContentLoaded 1295.97 ms +0.69% -1.17% 1299.64 ms +0.77% -1.68% -0.28%
loaded 1297.08 ms +0.71% -1.17% 1301 ms +0.77% -1.71% -0.3%
firstContentfulPaint 526.47 ms +1.25% -3.53% 521.3 ms +2.47% -4.37% 0.99%
firstBlock 4919.53 ms +0.36% -0.84% 4888.48 ms +1.59% -0.6% 0.64%
type 18.26 ms +4.27% -0.93% 21.34 ms +2.44% -4.17% -14.43%
navigate 128.67 ms +11.36% -4.73% 132.38 ms +16.38% -2.14% -2.8%
loadPatterns 1293.58 ms +5.63% -2.29% 1274.29 ms +4.55% -4.34% 1.51%
loadPages 999.39 ms +5.15% -3.16% 1020.98 ms +2.16% -1.59% -2.11%
wpTotal 478.57 ms +6.13% -4.48% 486.16 ms +11.28% -4.26% -1.56%
wpMemoryUsage 12.70 MB +0% -0% 12.66 MB +0% -0% 0.29%
wpDbQueries 44 +2.27% -0% 44 +2.27% -0% 0%

900ab3b Run

🏁 Flaky tests

Some 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 /test/e2e/specs/editor/various/core-settings.spec.js, passed after 1 failed attempt.
Error: expect(received).toStrictEqual(expected) // deep equality

- Expected  - 1
+ Received  + 1

  Array [
    "rewrite_rules",
-   "SERIALIZED DATA",
+   "",
  ]
    at forEach (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/core-settings.spec.js:46:26)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/core-settings.spec.js:43:35
keeps the blocks selected after dropping a multi-selection in /test/e2e/specs/editor/various/draggable-blocks.spec.js, passed after 1 failed attempt.
TypeError: Cannot read properties of null (reading 'y')
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/draggable-blocks.spec.js:824:57
    at dragSelectionBelowLanding (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/draggable-blocks.spec.js:823:3)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/draggable-blocks.spec.js:908:3
refuses the drop and uploads nothing in /test/e2e/specs/editor/various/single-file-placeholder-drop.spec.js, passed after 1 failed attempt.
Error: expect(received).toHaveLength(expected)

Expected length: 0
Received length: 1
Received array:  [{"_links": {"about": [{"href": "http://localhost:8889/wp-json/wp/v2/types/attachment"}], "author": [{"embeddable": true, "href": "http://localhost:8889/wp-json/wp/v2/users/1"}], "collection": [{"href": "http://localhost:8889/wp-json/wp/v2/media"}], "curies": [{"href": "https://api.w.org/{rel}", "name": "wp", "templated": true}], "replies": [{"embeddable": true, "href": "http://localhost:8889/wp-json/wp/v2/comments?post=223"}], "self": [{"href": "http://localhost:8889/wp-json/wp/v2/media/223", "targetHints": {"allow": ["GET", "POST", "PUT", "PATCH", "DELETE"]}}], "wp:attached-to": [{"embeddable": true, "href": "http://localhost:8889/wp-json/wp/v2/posts/222", "id": 222, "post_type": "post"}]}, "alt_text": "", "author": 1, "caption": {"rendered": ""}, "class_list": ["post-223", "attachment", "type-attachment", "status-inherit", "hentry", "entry"], "comment_status": "open", "date": "2026-10-21T04:25:15", "date_gmt": "2026-10-21T04:25:15", "description": {"rendered": "<p class=\"attachment\"><a href='http://localhost:8889/wp-content/uploads/2026/10/62257423-aeb2-4fa9-941c-407d48a602fb.png'><img loading=\"lazy\" decoding=\"async\" width=\"10\" height=\"10\" src=\"http://localhost:8889/wp-content/uploads/2026/10/62257423-aeb2-4fa9-941c-407d48a602fb.png\" class=\"attachment-medium size-medium\" alt=\"\" style=\"width:100%;height:100%;max-width:10px;\" /></a></p>
"}, "featured_media": 0, "filename": "62257423-aeb2-4fa9-941c-407d48a602fb.png", "filesize": 80, "guid": {"rendered": "http://localhost:8889/wp-content/uploads/2026/10/62257423-aeb2-4fa9-941c-407d48a602fb.png"}, "id": 223, "link": "http://localhost:8889/?attachment_id=223", "media_details": {"file": "2026/10/62257423-aeb2-4fa9-941c-407d48a602fb.png", "filesize": 80, "height": 10, "image_meta": {"alt": "", "aperture": "0", "camera": "", "caption": "", "copyright": "", "created_timestamp": "0", "credit": "", "focal_length": "0", "iso": "0", "keywords": [], "orientation": "0", "shutter_speed": "0", "title": ""}, "sizes": {}, "width": 10}, "media_type": "image", "meta": [], "mime_type": "image/png", "modified": "2026-10-21T04:25:15", "modified_gmt": "2026-10-21T04:25:15", "ping_status": "closed", "post": 222, "slug": "62257423-aeb2-4fa9-941c-407d48a602fb", "source_url": "http://localhost:8889/wp-content/uploads/2026/10/62257423-aeb2-4fa9-941c-407d48a602fb.png", "status": "inherit", "template": "", "title": {"rendered": "62257423-aeb2-4fa9-941c-407d48a602fb"}, "type": "attachment"}]
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/single-file-placeholder-drop.spec.js:71:45

900ab3b Run

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.
@aaronrobertshaw
aaronrobertshaw force-pushed the fix/comments-pagination-next-filter-hook branch from f72a2e1 to 900ab3b Compare October 21, 2026 04:07
@aaronrobertshaw

Copy link
Copy Markdown
Contributor Author

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 andrewserong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@aaronrobertshaw
aaronrobertshaw merged commit c01a2a3 into trunk Oct 21, 2026
129 checks passed
@aaronrobertshaw
aaronrobertshaw deleted the fix/comments-pagination-next-filter-hook branch October 21, 2026 04:55
@github-actions github-actions Bot added this to the Gutenberg 24.4 milestone Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block library /packages/block-library [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants