Make WordPress Core

Changeset 9100


Ignore:
Timestamp:
10/08/2008 09:42:52 PM (16 years ago)
Author:
ryan
Message:

Try to preserve post IDs during import

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/import/wordpress.php

    r8957 r9100  
    431431
    432432            $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_excerpt', 'post_title', 'post_status', 'post_name', 'comment_status', 'ping_status', 'guid', 'post_parent', 'menu_order', 'post_type', 'post_password');
     433            $postdata['import_id'] = $post_ID;
    433434            if ($post_type == 'attachment') {
    434435                $remote_url = $this->get_tag( $post, 'wp:attachment_url' );
  • trunk/wp-includes/post.php

    r9083 r9100  
    13051305        'ping_status' => get_option('default_ping_status'), 'post_parent' => 0,
    13061306        'menu_order' => 0, 'to_ping' =>  '', 'pinged' => '', 'post_password' => '',
    1307         'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '');
     1307        'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0);
    13081308
    13091309    $postarr = wp_parse_args($postarr, $defaults);
     
    14501450        if ( isset($post_mime_type) )
    14511451            $data['post_mime_type'] = stripslashes( $post_mime_type ); // This isn't in the update
     1452        // If there is a suggested ID, use it if not already present
     1453        if ( !empty($import_id) ) {
     1454            $import_id = (int) $import_id;
     1455            if ( ! $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE ID = %d", $import_id) ) ) {
     1456                $data['ID'] = $import_id;
     1457            }
     1458        }
    14521459        if ( false === $wpdb->insert( $wpdb->posts, $data ) ) {
    14531460            if ( $wp_error )
Note: See TracChangeset for help on using the changeset viewer.