Exporting by category bug
-
I think I found a bug and was hoping to get some feedback and/or help.
Specifically, when exporting posts by category in WP 3.0 and above, I am getting an export file that does not match the known contents of a particular category.
I snooped around and found this code block:
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 code chunk is from wp-admin/includes/export.php and is used when exporting content in WordPress 3.0 and above. It seems to be matching posts based on an incorrect WHERE clause. The clause needs to select term_id, not term_taxonomy_id. As term_id is not available in the term_relationships table, a JOIN is needed as well.
A revised SQL query:
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
- The topic ‘Exporting by category bug’ is closed to new replies.