Changeset 34205
- Timestamp:
- 09/15/2015 04:22:34 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-comment-query.php
r33898 r34205 93 93 * Sets up the comment query, based on the query vars passed. 94 94 * 95 * @since 4.2.0 95 * @since 4.2.0 96 * @since 4.4.0 `$parent__in` and `$parent__not_in` were added. 96 97 * @access public 97 98 * … … 137 138 * Default: 'DESC'. 138 139 * @type int $parent Parent ID of comment to retrieve children of. Default empty. 140 * @type array $parent__in Array of parent IDs of comments to retrieve children for. Default empty. 141 * @type array $parent__not_in Array of parent IDs of comments *not* to retrieve children for. Default empty. 139 142 * @type array $post_author__in Array of author IDs to retrieve comments for. Default empty. 140 143 * @type array $post_author__not_in Array of author IDs *not* to retrieve comments for. Default empty. … … 487 490 } 488 491 492 // Parse comment parent IDs for an IN clause. 493 if ( ! empty( $this->query_vars['parent__in'] ) ) { 494 $where[] = 'comment_parent IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['parent__in'] ) ) . ' )'; 495 } 496 497 // Parse comment parent IDs for a NOT IN clause. 498 if ( ! empty( $this->query_vars['parent__not_in'] ) ) { 499 $where[] = 'comment_parent NOT IN ( ' . implode( ',', wp_parse_id_list( $this->query_vars['parent__not_in'] ) ) . ' )'; 500 } 501 489 502 // Parse comment post IDs for an IN clause. 490 503 if ( ! empty( $this->query_vars['post__in'] ) ) { -
trunk/tests/phpunit/tests/comment/query.php
r32911 r34205 1738 1738 $q->query_vars['meta_value'] = 'bar'; 1739 1739 } 1740 1741 /** 1742 * @ticket 33882 1743 */ 1744 public function test_parent__in() { 1745 $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); 1746 $c2 = $this->factory->comment->create( array( 1747 'comment_post_ID' => $this->post_id, 1748 'comment_approved' => '1', 1749 'comment_parent' => $c1, 1750 ) ); 1751 1752 $ids = new WP_Comment_Query( array( 1753 'comment_post_ID' => $this->post_id, 1754 'fields' => 'ids', 1755 'parent__in' => array( $c1 ) 1756 ) ); 1757 1758 $this->assertEqualSets( array( $c2 ), $ids->comments ); 1759 } 1760 1761 /** 1762 * @ticket 33882 1763 */ 1764 public function test_parent__in_commas() { 1765 $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); 1766 $c2 = $this->factory->comment->create( array( 1767 'comment_post_ID' => $this->post_id, 1768 'comment_approved' => '1' 1769 ) ); 1770 $c3 = $this->factory->comment->create( array( 1771 'comment_post_ID' => $this->post_id, 1772 'comment_approved' => '1', 1773 'comment_parent' => $c1, 1774 ) ); 1775 $c4 = $this->factory->comment->create( array( 1776 'comment_post_ID' => $this->post_id, 1777 'comment_approved' => '1', 1778 'comment_parent' => $c2, 1779 ) ); 1780 1781 $ids = new WP_Comment_Query( array( 1782 'comment_post_ID' => $this->post_id, 1783 'fields' => 'ids', 1784 'parent__in' => "$c1,$c2" 1785 ) ); 1786 1787 $this->assertEqualSets( array( $c3, $c4 ), $ids->comments ); 1788 } 1789 1790 /** 1791 * @ticket 33882 1792 */ 1793 public function test_parent__not_in() { 1794 $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); 1795 1796 $this->factory->comment->create( array( 1797 'comment_post_ID' => $this->post_id, 1798 'comment_approved' => '1', 1799 'comment_parent' => $c1, 1800 ) ); 1801 1802 $ids = new WP_Comment_Query( array( 1803 'comment_post_ID' => $this->post_id, 1804 'fields' => 'ids', 1805 'parent__not_in' => array( $c1 ) 1806 ) ); 1807 1808 $this->assertEqualSets( array( $c1 ), $ids->comments ); 1809 } 1810 1811 /** 1812 * @ticket 33882 1813 */ 1814 public function test_parent__not_in_commas() { 1815 $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); 1816 $c2 = $this->factory->comment->create( array( 1817 'comment_post_ID' => $this->post_id, 1818 'comment_approved' => '1' 1819 ) ); 1820 1821 $this->factory->comment->create( array( 1822 'comment_post_ID' => $this->post_id, 1823 'comment_approved' => '1', 1824 'comment_parent' => $c1, 1825 ) ); 1826 $this->factory->comment->create( array( 1827 'comment_post_ID' => $this->post_id, 1828 'comment_approved' => '1', 1829 'comment_parent' => $c2, 1830 ) ); 1831 1832 $ids = new WP_Comment_Query( array( 1833 'comment_post_ID' => $this->post_id, 1834 'fields' => 'ids', 1835 'parent__not_in' => "$c1,$c2" 1836 ) ); 1837 1838 $this->assertEqualSets( array( $c1, $c2 ), $ids->comments ); 1839 } 1740 1840 }
Note: See TracChangeset
for help on using the changeset viewer.