Make WordPress Core

Ticket #7599: 7599.diff

File 7599.diff, 1.8 KB (added by ryan, 18 years ago)
  • wp-includes/query.php

     
    10461046                }
    10471047
    10481048                if ( !empty($q['category__not_in']) ) {
    1049                         $ids = get_objects_in_term($q['category__not_in'], 'category');
    1050                         if ( is_wp_error( $ids ) )
    1051                                 return $ids;
    1052                         if ( is_array($ids) && count($ids > 0) ) {
    1053                                 $out_posts = "'" . implode("', '", $ids) . "'";
    1054                                 $whichcat .= " AND $wpdb->posts.ID NOT IN ($out_posts)";
     1049                        if ( $wpdb->supports_subqueries() ) {
     1050                                $cat_string = "'" . implode("', '", $q['category__not_in']) . "'";
     1051                                $whichcat .= " AND $wpdb->posts.ID NOT IN (SELECT $wpdb->term_relationships.object_id FROM $wpdb->term_relationships WHERE $wpdb->term_relationships.term_taxonomy_id IN ($cat_string) )";
     1052                        } else {
     1053                                $ids = get_objects_in_term($q['category__not_in'], 'category');
     1054                                if ( is_wp_error( $ids ) )
     1055                                        return $ids;
     1056                                if ( is_array($ids) && count($ids > 0) ) {
     1057                                        $out_posts = "'" . implode("', '", $ids) . "'";
     1058                                        $whichcat .= " AND $wpdb->posts.ID NOT IN ($out_posts)";
     1059                                }
    10551060                        }
    10561061                }
    10571062
  • wp-includes/wp-db.php

     
    924924        }
    925925
    926926        /**
     927         * Whether of not the database version supports sub-queries.
     928         *
     929         * @since 2.7
     930         *
     931         * @return bool True if sub-queries are supported, false if version does not
     932         */
     933        function supports_subqueries() {
     934                return ( version_compare(mysql_get_server_info($this->dbh), '4.1.0', '>=') );
     935        }
     936
     937        /**
    927938         * Retrieve the name of the function that called wpdb.
    928939         *
    929940         * Requires PHP 4.3 and searches up the list of functions until it reaches