WordPress.org

Make WordPress Core

Changeset 9357


Ignore:
Timestamp:
10/26/08 17:05:56 (5 years ago)
Author:
ryan
Message:

Preserve attachment IDs during import. Props mtdewvirus. fixes #7972

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r9349 r9357  
    22462246        'ping_status' => get_option('default_ping_status'), 'post_parent' => 0, 
    22472247        'menu_order' => 0, 'to_ping' =>  '', 'pinged' => '', 'post_password' => '', 
    2248         'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => ''); 
     2248        'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0); 
    22492249 
    22502250    $object = wp_parse_args($object, $defaults); 
     
    23422342        $wpdb->update( $wpdb->posts, $data, array( 'ID' => $post_ID ) ); 
    23432343    } else { 
     2344        // If there is a suggested ID, use it if not already present 
     2345        if ( !empty($import_id) ) {  
     2346            $import_id = (int) $import_id;  
     2347            if ( ! $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE ID = %d", $import_id) ) ) {  
     2348                $data['ID'] = $import_id;  
     2349            }  
     2350        }  
     2351 
    23442352        $wpdb->insert( $wpdb->posts, $data ); 
    23452353        $post_ID = (int) $wpdb->insert_id; 
Note: See TracChangeset for help on using the changeset viewer.