From 0286950f683c5b30114601187d7b33bdb7455cb6 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Wed, 25 Nov 2026 15:15:18 -0800 Subject: [PATCH] REST API: Drop redundant absint() calls on comment post and parent IDs. The comments schema declares `post` and `parent` as integers with a minimum of 0, so the request values are already non-negative integers by the time `create_item()` and `update_item()` read them. Follow-up to [65750]. See #66635. Claude-Session: https://claude.ai/code/session_018vwYjSfCMNDQ1rP5mWYfTM --- .../endpoints/class-wp-rest-comments-controller.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php index 3bb44059052eb..8cea8567f1c0a 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php @@ -732,7 +732,7 @@ public function create_item( $request ) { } if ( 'note' === $request['type'] && $request['parent'] ) { - $parent_check = $this->check_note_parent( absint( $request['parent'] ), absint( $request['post'] ) ); + $parent_check = $this->check_note_parent( $request['parent'], $request['post'] ); if ( is_wp_error( $parent_check ) ) { return $parent_check; @@ -854,7 +854,7 @@ public function create_item( $request ) { */ $existing = get_comments( array( - 'post_id' => absint( $request['post'] ), + 'post_id' => $request['post'], 'parent' => $request['parent'], 'user_id' => get_current_user_id(), 'type' => 'reaction', @@ -1045,7 +1045,7 @@ public function create_item( $request ) { if ( null !== $reaction_key ) { $matching = get_comments( array( - 'post_id' => absint( $request['post'] ), + 'post_id' => $request['post'], 'parent' => $request['parent'], 'user_id' => get_current_user_id(), 'type' => 'reaction', @@ -1245,8 +1245,8 @@ public function update_item( $request ) { } if ( 'note' === $comment->comment_type ) { - $post_id = isset( $request['post'] ) ? absint( $request['post'] ) : (int) $comment->comment_post_ID; - $parent_id = isset( $request['parent'] ) ? absint( $request['parent'] ) : (int) $comment->comment_parent; + $post_id = isset( $request['post'] ) ? $request['post'] : (int) $comment->comment_post_ID; + $parent_id = isset( $request['parent'] ) ? $request['parent'] : (int) $comment->comment_parent; $is_moving = $post_id !== (int) $comment->comment_post_ID; if ( $parent_id && ( $is_moving || $parent_id !== (int) $comment->comment_parent ) ) {