[wp-trac] [WordPress Trac] #15941: Wordpress 3.0 Multisite Export tag/category filter

WordPress Trac wp-trac at lists.automattic.com
Tue Dec 21 22:57:09 UTC 2010


#15941: Wordpress 3.0 Multisite Export tag/category filter
----------------------------+----------------------------------
 Reporter:  nootron         |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Administration  |    Version:
 Severity:  major           |   Keywords:  export category term
----------------------------+----------------------------------
 Exporting wordpress posts by term (category or tag) appears to return zero
 items, even if there are existing posts in that category.

 To replicate:

 1.  Create a post.
 2.  Assign it to a category
 3.  Select Settings > Export
 4.  Choose the category from the dropdown filter
 5.  Export

 I have tracked the cause down to a logic bug in /wp-
 admin/includes/export.php, code block beginning on line #64

 {{{
         if ( $taxonomy && is_array( $taxonomy ) ) {
                 foreach ( $taxonomy as $term_id ) {
                         if ( $term_id != 'all' )
                                 $where .= $wpdb->prepare( "AND ID IN
 (SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id =
 %d) ", $term_id );
                 }
         }
 }}}

 This join is not properly joining the term_RELATIONSHIP_id but instead
 attempts to join on the primary key.

 This code appears to correct the bug and properly returns posts (and child
 attachments) that match the term:

 {{{
         if ( $taxonomy && is_array( $taxonomy ) ) {
                 foreach ( $taxonomy as $term_id ) {
                         if ( $term_id != 'all' )
                                 $where .= $wpdb->prepare( "AND ID IN
 (SELECT object_id FROM $wpdb->term_relationships
                 JOIN $wpdb->term_taxonomy ON
 $wpdb->term_relationships.term_taxonomy_id =
 $wpdb->term_taxonomy.term_taxonomy_id
                 WHERE $wpdb->term_taxonomy.term_id = %d) ", $term_id );

                                 /* Gets attachments */
                                 $where .= $wpdb->prepare( "OR ( post_type
 = 'attachment' AND post_parent IN ( SELECT object_id FROM
 wbur_term_relationships
                                 JOIN wbur_term_taxonomy ON
 wbur_term_relationships.term_taxonomy_id =
 wbur_term_taxonomy.term_taxonomy_id
                                 WHERE wbur_term_taxonomy.term_id = %d ))
 ", $term_id);
                 }
         }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/15941>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list