@@ -1893,4 +1893,59 @@ public function test_wp_trash_comment_only_top_level_notes_trigger_child_deletio
18931893 // Verify the sibling note is NOT trashed (no cascade since child is not top-level).
18941894 $ this ->assertSame ( '1 ' , get_comment ( $ sibling_note )->comment_approved );
18951895 }
1896+
1897+ /**
1898+ * Test wp_trash_comment deletes a note and it's descendants when EMPTY_TRASH_DAYS is set to 0.
1899+ */
1900+ public function test_wp_delete_comment_deletes_descendants_when_empty_trash_days_is_zero () {
1901+ // Set EMPTY_TRASH_DAYS to 0 to disable trashing.
1902+ define ( 'EMPTY_TRASH_DAYS ' , 0 );
1903+ $ parent_note = self ::factory ()->comment ->create (
1904+ array (
1905+ 'comment_post_ID ' => self ::$ post_id ,
1906+ 'comment_type ' => 'note ' ,
1907+ 'comment_parent ' => 0 ,
1908+ 'comment_approved ' => '1 ' ,
1909+ )
1910+ );
1911+
1912+ // Create child notes under the parent.
1913+ $ child_note_1 = self ::factory ()->comment ->create (
1914+ array (
1915+ 'comment_post_ID ' => self ::$ post_id ,
1916+ 'comment_type ' => 'note ' ,
1917+ 'comment_parent ' => $ parent_note ,
1918+ 'comment_approved ' => '1 ' ,
1919+ )
1920+ );
1921+
1922+ $ child_note_2 = self ::factory ()->comment ->create (
1923+ array (
1924+ 'comment_post_ID ' => self ::$ post_id ,
1925+ 'comment_type ' => 'note ' ,
1926+ 'comment_parent ' => $ parent_note ,
1927+ 'comment_approved ' => '1 ' ,
1928+ )
1929+ );
1930+
1931+ $ child_note_3 = self ::factory ()->comment ->create (
1932+ array (
1933+ 'comment_post_ID ' => self ::$ post_id ,
1934+ 'comment_type ' => 'note ' ,
1935+ 'comment_parent ' => $ parent_note ,
1936+ 'comment_approved ' => $ approved_status ,
1937+ )
1938+ );
1939+
1940+ // Trash the parent note.
1941+ wp_trash_comment ( $ parent_note );
1942+
1943+ // Verify that the parent note is actually deleted.
1944+ $ this ->assertNull ( get_comment ( $ parent_note ) );
1945+
1946+ // Verify that the child notes have also been deleted.
1947+ $ this ->assertNull ( get_comment ( $ child_note_1 ) );
1948+ $ this ->assertNull ( get_comment ( $ child_note_2 ) );
1949+ $ this ->assertNull ( get_comment ( $ child_note_3 ) );
1950+ }
18961951}
0 commit comments