Commit 6694230e824 for woocommerce

commit 6694230e82407c1903aed1c4a5da12a9cff499b2
Author: Moeini <a.moeny@gmail.com>
Date:   Sun Oct 25 16:25:37 2026 +0330

    Fix parent review auto-approval when replying to unapproved reviews (#65944)

diff --git a/plugins/woocommerce/changelog/65944-fix-36619-review-reply-auto-approve-parent b/plugins/woocommerce/changelog/65944-fix-36619-review-reply-auto-approve-parent
new file mode 100644
index 00000000000..c2873c766b5
--- /dev/null
+++ b/plugins/woocommerce/changelog/65944-fix-36619-review-reply-auto-approve-parent
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix parent review auto-approval when replying to an unapproved review from the admin product reviews screen.
diff --git a/plugins/woocommerce/src/Internal/Admin/ProductReviews/Reviews.php b/plugins/woocommerce/src/Internal/Admin/ProductReviews/Reviews.php
index 9b61688086d..e1d1c780dd7 100644
--- a/plugins/woocommerce/src/Internal/Admin/ProductReviews/Reviews.php
+++ b/plugins/woocommerce/src/Internal/Admin/ProductReviews/Reviews.php
@@ -343,7 +343,7 @@ class Reviews {
 		if ( ! empty( $_POST['approve_parent'] ) ) {
 			$parent = get_comment( $comment_parent );

-			if ( $parent && '0' === $parent->comment_approved && $parent->comment_post_ID === $comment_post_ID ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
+			if ( $parent && '0' === $parent->comment_approved && (int) $parent->comment_post_ID === $comment_post_ID ) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase
 				if ( ! current_user_can( 'edit_comment', $parent->comment_ID ) ) {
 					wp_die( -1 );
 				}
diff --git a/plugins/woocommerce/tests/php/src/Internal/Admin/ProductReviews/ReviewsTest.php b/plugins/woocommerce/tests/php/src/Internal/Admin/ProductReviews/ReviewsTest.php
index 1039ba0f047..e72f882d711 100644
--- a/plugins/woocommerce/tests/php/src/Internal/Admin/ProductReviews/ReviewsTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/Admin/ProductReviews/ReviewsTest.php
@@ -10,6 +10,8 @@ use ReflectionException;
 use stdClass;
 use WC_Unit_Test_Case;
 use WP_Comment;
+use WPDieException;
+use WPAjaxDieContinueException;

 /**
  * Tests for the admin reviews handler.
@@ -712,4 +714,72 @@ test2</p></div>',
 		$this->assertSame( 'http://' . WP_TESTS_DOMAIN . '/wp-admin/edit.php?post_type=product&page=product-reviews', Reviews::get_reviews_page_url() );
 	}

+	/**
+	 * @testdox `handle_reply_to_review` approves the parent review when replying to an unapproved review.
+	 *
+	 * @covers \Automattic\WooCommerce\Internal\Admin\ProductReviews\Reviews::handle_reply_to_review()
+	 *
+	 * @return void
+	 */
+	public function test_handle_reply_to_review_approves_unapproved_parent_review(): void {
+		$admin_id = $this->factory()->user->create( array( 'role' => 'administrator' ) );
+		wp_set_current_user( $admin_id );
+
+		$product_id = $this->factory()->post->create(
+			array(
+				'post_type'   => 'product',
+				'post_status' => 'publish',
+			)
+		);
+
+		$parent_review_id = $this->factory()->comment->create(
+			array(
+				'comment_post_ID'  => $product_id,
+				'comment_type'     => 'review',
+				'comment_approved' => '0',
+			)
+		);
+
+		$nonce = wp_create_nonce( 'replyto-comment' );
+
+		$request = array(
+			'action'                      => 'replyto-comment',
+			'mode'                        => 'detail',
+			'_ajax_nonce-replyto-comment' => $nonce,
+			'comment_post_ID'             => $product_id,
+			'comment_ID'                  => $parent_review_id,
+			'content'                     => 'Thank you for your review!',
+			'comment_type'                => 'comment',
+			'approve_parent'              => 1,
+			'_wp_unfiltered_html_comment' => wp_create_nonce( 'unfiltered-html-comment' ),
+		);
+
+		$_POST    = $request;
+		$_REQUEST = array_merge( $_REQUEST, $request ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
+
+		add_filter( 'wp_doing_ajax', '__return_true' );
+
+		$reviews = wc_get_container()->get( Reviews::class );
+
+		try {
+			$reviews->handle_reply_to_review();
+		} catch ( WPAjaxDieContinueException $e ) {
+			unset( $e );
+		} catch ( WPDieException $e ) {
+			unset( $e );
+		} catch ( \Throwable $e ) {
+			// WP_Ajax_Response::send() may fail when headers are already sent in the test environment.
+			unset( $e );
+		}
+
+		remove_filter( 'wp_doing_ajax', '__return_true' );
+
+		$parent = get_comment( $parent_review_id );
+
+		$this->assertSame( '1', $parent->comment_approved );
+
+		wp_set_current_user( 0 );
+		$_POST = array();
+	}
+
 }