WordPress.org

Make WordPress Core

Changeset 6593


Ignore:
Timestamp:
01/10/08 21:27:08 (6 years ago)
Author:
westi
Message:

Ensure that we preserve GUIDs when importing from RSS. Fixes #5589 props peterjanes.

Location:
trunk
Files:
2 edited

Legend:

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

    r6472 r6593  
    7272            } 
    7373 
    74             preg_match('|<guid.+?>(.*?)</guid>|is', $post, $guid); 
     74            preg_match('|<guid.*?>(.*?)</guid>|is', $post, $guid); 
    7575            if ($guid) 
    7676                $guid = $wpdb->escape(trim($guid[1])); 
  • trunk/wp-includes/post.php

    r6592 r6593  
    953953    $defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID, 
    954954        'ping_status' => get_option('default_ping_status'), 'post_parent' => 0, 
    955         'menu_order' => 0, 'to_ping' =>  '', 'pinged' => '', 'post_password' => ''); 
     955        'menu_order' => 0, 'to_ping' =>  '', 'pinged' => '', 'post_password' => '', 
     956        'guid' => ''); 
    956957 
    957958    $postarr = wp_parse_args($postarr, $defaults); 
     
    987988        $post_type = 'post'; 
    988989 
    989     // Get the post ID. 
    990     if ( $update ) 
     990    // Get the post ID and GUID 
     991    if ( $update ) { 
    991992        $post_ID = (int) $ID; 
    992  
     993        $guid = get_post_field( 'guid', $post_ID ); 
     994    } 
     995     
    993996    // Create a valid post name.  Drafts are allowed to have an empty 
    994997    // post name. 
     
    10751078 
    10761079    // expected_slashed (everything!) 
    1077     $data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order' ) ); 
     1080    $data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'guid' ) ); 
    10781081    $data = stripslashes_deep( $data ); 
    10791082    $where = array( 'ID' => $post_ID ); 
     
    10981101    wp_set_post_tags( $post_ID, $tags_input ); 
    10991102 
     1103    $current_guid = get_post_field( 'guid', $post_ID ); 
     1104 
    11001105    if ( 'page' == $post_type ) { 
    11011106        clean_page_cache($post_ID); 
     
    11051110 
    11061111    // Set GUID 
    1107     if ( ! $update ) 
     1112    if ( !$update && '' == $current_guid ) 
    11081113        $wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post_ID ) ), $where ); 
    11091114 
     
    25442549 
    25452550    if ( $old_status != 'publish' && $new_status == 'publish' ) { 
    2546             // Reset GUID if transitioning to publish. 
     2551        // Reset GUID if transitioning to publish and it is empty 
     2552        if ( '' == get_the_guid($post->ID) ) 
    25472553            $wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) ); 
    2548             do_action('private_to_published', $post->ID);  // Deprecated, use private_to_publish 
     2554        do_action('private_to_published', $post->ID);  // Deprecated, use private_to_publish 
    25492555    } 
    25502556 
Note: See TracChangeset for help on using the changeset viewer.