Changeset 36357 for branches/4.4/src/wp-includes/class-wp-comment-query.php
- Timestamp:
- 01/20/2016 05:27:07 AM (9 years ago)
- Location:
- branches/4.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.4
-
branches/4.4/src/wp-includes/class-wp-comment-query.php
r35757 r36357 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 /** … … 817 828 $groupby = isset( $clauses[ 'groupby' ] ) ? $clauses[ 'groupby' ] : ''; 818 829 830 $this->filtered_where_clause = $where; 831 819 832 if ( $where ) { 820 833 $where = 'WHERE ' . $where; … … 868 881 ); 869 882 870 $where_clauses = $this->sql_clauses['where']; 871 unset( 872 $where_clauses['parent'], 873 $where_clauses['parent__in'], 874 $where_clauses['parent__not_in'] 875 ); 883 /* 884 * The WHERE clause for the descendant query is the same as for the top-level 885 * query, minus the `parent`, `parent__in`, and `parent__not_in` sub-clauses. 886 */ 887 $_where = $this->filtered_where_clause; 888 $exclude_keys = array( 'parent', 'parent__in', 'parent__not_in' ); 889 foreach ( $exclude_keys as $exclude_key ) { 890 if ( isset( $this->sql_clauses['where'][ $exclude_key ] ) ) { 891 $clause = $this->sql_clauses['where'][ $exclude_key ]; 892 893 // Strip the clause as well as any adjacent ANDs. 894 $pattern = '|(?:AND)?\s*' . $clause . '\s*(?:AND)?|'; 895 $_where_parts = preg_split( $pattern, $_where ); 896 897 // Remove empties. 898 $_where_parts = array_filter( array_map( 'trim', $_where_parts ) ); 899 900 // Reassemble with an AND. 901 $_where = implode( ' AND ', $_where_parts ); 902 } 903 } 876 904 877 905 // Fetch an entire level of the descendant tree at a time. … … 883 911 } 884 912 885 $where = 'WHERE ' . implode( ' AND ', $where_clauses ). ' AND comment_parent IN (' . implode( ',', array_map( 'intval', $parent_ids ) ) . ')';913 $where = 'WHERE ' . $_where . ' AND comment_parent IN (' . implode( ',', array_map( 'intval', $parent_ids ) ) . ')'; 886 914 $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" ); 887 915
Note: See TracChangeset
for help on using the changeset viewer.