Skip to content

Comment Template: error occurs when retrieving comments #69392

@t-hamano

Description

@t-hamano

Description

Found in this comment: #69378 (comment)

It seems that the Comment Template block is no longer fetching comments in WordPress trunk.

The issue is related to this changeset in core: https://core.trac.wordpress.org/changeset/59899/

If I try reverting the changes in this file, the block will render correctly.

Step-by-step reproduction instructions

  • Use the latest WordPress trunk. If you are using wp-env, reset your environment.
  • Insert a Comment block into a post. This block contains a Comment Template block as a child.
  • A loading icon will be displayed persistently on the block.
  • You will see an error in the browser console.

Screenshots, screen recording, code snippet

Comment Template Block

Image

Browser Console Error

Image

PHP Error Log

Log
[03-Mar-2025 12:03:24 UTC] PHP Fatal error:  Uncaught TypeError: array_intersect_key(): Argument #1 ($array) must be of type array, null given in /var/www/html/wp-includes/rest-api.php:901
Stack trace:
#0 /var/www/html/wp-includes/rest-api.php(901): array_intersect_key(NULL, Array)
#1 /var/www/html/wp-includes/rest-api.php(960): _rest_array_intersect_key_recursive(NULL, Array)
#2 /var/www/html/wp-includes/class-wp-hook.php(324): rest_filter_response_fields(Object(WP_REST_Response), Object(WP_REST_Server), Object(WP_REST_Request))
#3 /var/www/html/wp-includes/plugin.php(205): WP_Hook->apply_filters(Object(WP_REST_Response), Array)
#4 /var/www/html/wp-includes/rest-api/class-wp-rest-server.php(462): apply_filters('rest_post_dispa...', Object(WP_REST_Response), Object(WP_REST_Server), Object(WP_REST_Request))
#5 /var/www/html/wp-includes/rest-api.php(459): WP_REST_Server->serve_request('/wp/v2/comments')
#6 /var/www/html/wp-includes/class-wp-hook.php(324): rest_api_loaded(Object(WP))
#7 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
#8 /var/www/html/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
#9 /var/www/html/wp-includes/class-wp.php(418): do_action_ref_array('parse_request', Array)
#10 /var/www/html/wp-includes/class-wp.php(818): WP->parse_request('')
#11 /var/www/html/wp-includes/functions.php(1342): WP->main('')
#12 /var/www/html/wp-blog-header.php(16): wp()
#13 /var/www/html/index.php(17): require('/var/www/html/w...')
#14 {main}
  thrown in /var/www/html/wp-includes/rest-api.php on line 901
[03-Mar-2025 12:03:24 UTC] PHP Fatal error:  Uncaught TypeError: array_intersect_key(): Argument #1 ($array) must be of type array, null given in /var/www/html/wp-includes/rest-api.php:901
Stack trace:
#0 /var/www/html/wp-includes/rest-api.php(901): array_intersect_key(NULL, Array)
#1 /var/www/html/wp-includes/rest-api.php(960): _rest_array_intersect_key_recursive(NULL, Array)
#2 /var/www/html/wp-includes/class-wp-hook.php(324): rest_filter_response_fields(Object(WP_REST_Response), Object(WP_REST_Server), Object(WP_REST_Request))
#3 /var/www/html/wp-includes/plugin.php(205): WP_Hook->apply_filters(Object(WP_REST_Response), Array)
#4 /var/www/html/wp-includes/rest-api/class-wp-rest-server.php(462): apply_filters('rest_post_dispa...', Object(WP_REST_Response), Object(WP_REST_Server), Object(WP_REST_Request))
#5 /var/www/html/wp-includes/rest-api.php(459): WP_REST_Server->serve_request('/wp/v2/comments')
#6 /var/www/html/wp-includes/class-wp-hook.php(324): rest_api_loaded(Object(WP))
#7 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
#8 /var/www/html/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
#9 /var/www/html/wp-includes/class-wp.php(418): do_action_ref_array('parse_request', Array)
#10 /var/www/html/wp-includes/class-wp.php(818): WP->parse_request('')
#11 /var/www/html/wp-includes/functions.php(1342): WP->main('')
#12 /var/www/html/wp-blog-header.php(16): wp()
#13 /var/www/html/index.php(17): require('/var/www/html/w...')
#14 {main}
  thrown in /var/www/html/wp-includes/rest-api.php on line 901
[03-Mar-2025 12:03:24 UTC] PHP Fatal error:  Uncaught TypeError: array_intersect_key(): Argument #1 ($array) must be of type array, null given in /var/www/html/wp-includes/rest-api.php:901
Stack trace:
#0 /var/www/html/wp-includes/rest-api.php(901): array_intersect_key(NULL, Array)
#1 /var/www/html/wp-includes/rest-api.php(960): _rest_array_intersect_key_recursive(NULL, Array)
#2 /var/www/html/wp-includes/class-wp-hook.php(324): rest_filter_response_fields(Object(WP_REST_Response), Object(WP_REST_Server), Object(WP_REST_Request))
#3 /var/www/html/wp-includes/plugin.php(205): WP_Hook->apply_filters(Object(WP_REST_Response), Array)
#4 /var/www/html/wp-includes/rest-api/class-wp-rest-server.php(462): apply_filters('rest_post_dispa...', Object(WP_REST_Response), Object(WP_REST_Server), Object(WP_REST_Request))
#5 /var/www/html/wp-includes/rest-api.php(459): WP_REST_Server->serve_request('/wp/v2/comments')
#6 /var/www/html/wp-includes/class-wp-hook.php(324): rest_api_loaded(Object(WP))
#7 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
#8 /var/www/html/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
#9 /var/www/html/wp-includes/class-wp.php(418): do_action_ref_array('parse_request', Array)
#10 /var/www/html/wp-includes/class-wp.php(818): WP->parse_request('')
#11 /var/www/html/wp-includes/functions.php(1342): WP->main('')
#12 /var/www/html/wp-blog-header.php(16): wp()
#13 /var/www/html/index.php(17): require('/var/www/html/w...')
#14 {main}
  thrown in /var/www/html/wp-includes/rest-api.php on line 901
[03-Mar-2025 12:03:24 UTC] PHP Fatal error:  Uncaught TypeError: array_intersect_key(): Argument #1 ($array) must be of type array, null given in /var/www/html/wp-includes/rest-api.php:901
Stack trace:
#0 /var/www/html/wp-includes/rest-api.php(901): array_intersect_key(NULL, Array)
#1 /var/www/html/wp-includes/rest-api.php(960): _rest_array_intersect_key_recursive(NULL, Array)
#2 /var/www/html/wp-includes/class-wp-hook.php(324): rest_filter_response_fields(Object(WP_REST_Response), Object(WP_REST_Server), Object(WP_REST_Request))
#3 /var/www/html/wp-includes/plugin.php(205): WP_Hook->apply_filters(Object(WP_REST_Response), Array)
#4 /var/www/html/wp-includes/rest-api/class-wp-rest-server.php(462): apply_filters('rest_post_dispa...', Object(WP_REST_Response), Object(WP_REST_Server), Object(WP_REST_Request))
#5 /var/www/html/wp-includes/rest-api.php(459): WP_REST_Server->serve_request('/wp/v2/comments')
#6 /var/www/html/wp-includes/class-wp-hook.php(324): rest_api_loaded(Object(WP))
#7 /var/www/html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
#8 /var/www/html/wp-includes/plugin.php(565): WP_Hook->do_action(Array)
#9 /var/www/html/wp-includes/class-wp.php(418): do_action_ref_array('parse_request', Array)
#10 /var/www/html/wp-includes/class-wp.php(818): WP->parse_request('')
#11 /var/www/html/wp-includes/functions.php(1342): WP->main('')
#12 /var/www/html/wp-blog-header.php(16): wp()
#13 /var/www/html/index.php(17): require('/var/www/html/w...')
#14 {main}
  thrown in /var/www/html/wp-includes/rest-api.php on line 901

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

Labels

Core REST API TaskTask for Core REST API efforts[Block] Comment TemplateAffects the Comment Template Block[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions