Ticket #16854: 16854.patch
File 16854.patch, 1.9 KB (added by , 14 years ago) |
---|
-
wp-includes/query.php
2261 2261 if ( empty($q['author']) || ($q['author'] == '0') ) { 2262 2262 $whichauthor = ''; 2263 2263 } else { 2264 $q['author'] = (string)urldecode($q['author']); 2265 $q['author'] = addslashes_gpc($q['author']); 2266 if ( strpos($q['author'], '-') !== false ) { 2267 $eq = '!='; 2268 $andor = 'AND'; 2269 $q['author'] = explode('-', $q['author']); 2270 $q['author'] = (string)absint($q['author'][1]); 2264 if ( is_array( $q['author'] ) ) { 2265 $author_array = $q['author']; 2271 2266 } else { 2272 $eq = '='; 2273 $andor = 'OR'; 2267 // String values have to be sanitized and turn into an array 2268 $q['author'] = (string)urldecode($q['author']); 2269 $q['author'] = addslashes_gpc($q['author']); 2270 $author_array = preg_split('/[,\s]+/', $q['author']); 2274 2271 } 2275 $author_array = preg_split('/[,\s]+/', $q['author']);2272 2276 2273 $_author_array = array(); 2277 foreach ( $author_array as $key => $_author ) 2278 $_author_array[] = "$wpdb->posts.post_author " . $eq . ' ' . absint($_author); 2279 $whichauthor .= ' AND (' . implode(" $andor ", $_author_array) . ')'; 2274 $op = 'NOT IN'; 2275 foreach ( $author_array as $key => $_author ) { 2276 if ( 'NOT IN' == $op ) { 2277 if ( strpos($_author, '-') === false ) { 2278 // A single non-negative author switches the query 2279 // from NOT IN to IN 2280 $_author_array = array( absint( $_author ) ); 2281 $op = 'IN'; 2282 } else { 2283 // Add to the NOT IN array 2284 $_author_array[] = absint( $_author ); 2285 } 2286 } else { 2287 // Once the query becomes IN, we can skip NOT IN authors 2288 if ( strpos($_author, '-') === false ) { 2289 $_author_array[] = absint( $_author ); 2290 } 2291 } 2292 } 2293 2294 $whichauthor .= " AND $wpdb->posts.post_author $op (" . implode(',', $_author_array) . ")"; 2280 2295 unset($author_array, $_author_array); 2281 2296 } 2282 2297