WordPress.org

Make WordPress Core


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

Try to preserve post IDs during import

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.