Ticket #18840: get_pages_inexclusions_sql_optimisation.patch
File get_pages_inexclusions_sql_optimisation.patch, 1.3 KB (added by , 14 years ago) |
---|
-
post.php
3379 3379 $hierarchical = false; 3380 3380 $incpages = wp_parse_id_list( $include ); 3381 3381 if ( ! empty( $incpages ) ) { 3382 foreach ( $incpages as $incpage ) { 3383 if (empty($inclusions)) 3384 $inclusions = $wpdb->prepare(' AND ( ID = %d ', $incpage); 3385 else 3386 $inclusions .= $wpdb->prepare(' OR ID = %d ', $incpage); 3387 } 3382 // We have ints here as wp_parse_id_list() made sure of that. 3383 // So we just combine them in a subset and avoid the extra ->prepare(). 3384 // And we also shorten the query ALOT ;) (alots rule) 3385 $inclusions = ' AND ID IN ('.implode(', ', $incpages).')'; 3388 3386 } 3389 3387 } 3390 if (!empty($inclusions))3391 $inclusions .= ')';3392 3388 3393 3389 $exclusions = ''; 3394 3390 if ( !empty($exclude) ) { 3395 3391 $expages = wp_parse_id_list( $exclude ); 3396 3392 if ( ! empty( $expages ) ) { 3397 foreach ( $expages as $expage ) { 3398 if (empty($exclusions)) 3399 $exclusions = $wpdb->prepare(' AND ( ID <> %d ', $expage); 3400 else 3401 $exclusions .= $wpdb->prepare(' AND ID <> %d ', $expage); 3402 } 3393 // Same optimization as with $inclusions 3394 $exclusions = ' AND ID NOT IN ('.implode(', ', $expages).')'; 3403 3395 } 3404 3396 } 3405 if (!empty($exclusions))3406 $exclusions .= ')';3407 3397 3408 3398 $author_query = ''; 3409 3399 if (!empty($authors)) {