Changeset 36277 for trunk/src/wp-includes/class-wp-comment-query.php
- Timestamp:
- 01/13/2016 04:00:36 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-comment-query.php
r36224 r36277 59 59 'limits' => '', 60 60 ); 61 62 /** 63 * SQL WHERE clause. 64 * 65 * Stored after the 'comments_clauses' filter is run on the compiled WHERE sub-clauses. 66 * 67 * @since 4.4.2 68 * @access protected 69 * @var string 70 */ 71 protected $filtered_where_clause; 61 72 62 73 /** … … 824 835 $groupby = isset( $clauses[ 'groupby' ] ) ? $clauses[ 'groupby' ] : ''; 825 836 837 $this->filtered_where_clause = $where; 838 826 839 if ( $where ) { 827 840 $where = 'WHERE ' . $where; … … 875 888 ); 876 889 877 $where_clauses = $this->sql_clauses['where']; 878 unset( 879 $where_clauses['parent'], 880 $where_clauses['parent__in'], 881 $where_clauses['parent__not_in'] 882 ); 890 /* 891 * The WHERE clause for the descendant query is the same as for the top-level 892 * query, minus the `parent`, `parent__in`, and `parent__not_in` sub-clauses. 893 */ 894 $_where = $this->filtered_where_clause; 895 $exclude_keys = array( 'parent', 'parent__in', 'parent__not_in' ); 896 foreach ( $exclude_keys as $exclude_key ) { 897 if ( isset( $this->sql_clauses['where'][ $exclude_key ] ) ) { 898 $clause = $this->sql_clauses['where'][ $exclude_key ]; 899 900 // Strip the clause as well as any adjacent ANDs. 901 $pattern = '|(?:AND)?\s*' . $clause . '\s*(?:AND)?|'; 902 $_where_parts = preg_split( $pattern, $_where ); 903 904 // Remove empties. 905 $_where_parts = array_filter( array_map( 'trim', $_where_parts ) ); 906 907 // Reassemble with an AND. 908 $_where = implode( ' AND ', $_where_parts ); 909 } 910 } 883 911 884 912 // Fetch an entire level of the descendant tree at a time. … … 890 918 } 891 919 892 $where = 'WHERE ' . implode( ' AND ', $where_clauses ). ' AND comment_parent IN (' . implode( ',', array_map( 'intval', $parent_ids ) ) . ')';920 $where = 'WHERE ' . $_where . ' AND comment_parent IN (' . implode( ',', array_map( 'intval', $parent_ids ) ) . ')'; 893 921 $comment_ids = $wpdb->get_col( "{$this->sql_clauses['select']} {$this->sql_clauses['from']} {$where} {$this->sql_clauses['groupby']} ORDER BY comment_date_gmt ASC, comment_ID ASC" ); 894 922
Note: See TracChangeset
for help on using the changeset viewer.