[wp-trac] [WordPress Trac] #60806: Remove query alteration from build_comment_query_vars_from_block

WordPress Trac noreply at wordpress.org
Tue Mar 19 12:43:06 UTC 2024


#60806: Remove query alteration from build_comment_query_vars_from_block
--------------------------+-----------------------------
 Reporter:  Cybr          |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  6.0
 Severity:  major         |   Keywords:  needs-patch
  Focuses:                |
--------------------------+-----------------------------
 In the function `build_comment_query_vars_from_block()`, `set_query_var(
 'cpage', ... )` is called. This alters the query in unexpected ways.

 The function is called via blocks `core/comment-template`, `core/comments-
 pagination-next`, and `core/comments-pagination-numbers`.

 None of these blocks rely on `cpage` internally or indirectly. Adjusting
 `cpage` was probably vestigial of the initial development of the comment
 blocks.

 This bug causes the canonical URL to be incorrect for singular posts (when
 not using an SEO plugin). As a result, all these sites' singular content
 will be misindexed or, at worst, deindexed. Some 200 plugins are also
 [https://wpdirectory.net/search/01HS8Y1Q22Z8BEPAXFZM7PX4G7 affected by
 this issue].

 This only happens when comment pagination is turned on.

 This bug was only discovered recently because blocks had to be parsed
 before `wp_head()` for it to become a canonical URL issue, which is
 happening because of FSE and other custom block implementations.

 Discovery: https://wordpress.org/support/topic/the-seo-framework-adds-
 noindex-to-posts-with-multiple-comment-pages-%e2%9a%a0%ef%b8%8f/
 Slack thread:
 https://wordpress.slack.com/archives/C02RQBWTW/p1710771272739539?thread_ts=1710709493.297079&cid=C02RQBWTW

 I was requested to resolve this upstream via Gutenberg, but this is a more
 pertinent issue with Core. `build_comment_query_vars_from_block()` is also
 not part of Gutenberg but was created during its merger with WP 6.0.

 I propose to remove using `set_query_var()` altogether in the method. No
 functionality changes are apparent, but it resolves all aforementioned
 issues. PR will follow soon.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60806>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list