WP 3.0.1 export by category bugged

  • 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
  • You did not specify a blog address or reason for posting when you created this topic.

    This support forum is for blogs hosted at WordPress.com. If your question is about a self-hosted WordPress blog then you’ll find help at the WordPress.org forums.

    If you don’t understand the difference between WordPress.com and WordPress.org, you may find this information helpful.

    If you forgot to include a link to your blog, you can reply and include it below. It’ll help people to answer your question.

    This is an automated message.

  • The topic ‘WP 3.0.1 export by category bugged’ is closed to new replies.