Make WordPress Core

Ticket #6492: uuid.diff

File uuid.diff, 3.0 KB (added by Otto42, 16 years ago)

UUID patch example

  • wp-admin/includes/upgrade.php

     
    9393        // First post
    9494        $now = date('Y-m-d H:i:s');
    9595        $now_gmt = gmdate('Y-m-d H:i:s');
    96         $first_post_guid = get_option('home') . '/?p=1';
     96        $first_post_guid = $wpdb->get_var('SELECT UUID()');
    9797        $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, guid, comment_count, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'))."', '', '".$wpdb->escape(__('Hello world!'))."', '0', '".$wpdb->escape(_c('hello-world|Default post slug'))."', '$now', '$now_gmt', '$first_post_guid', '1', '', '', '')");
    9898        $wpdb->query( "INSERT INTO $wpdb->term_relationships (`object_id`, `term_taxonomy_id`) VALUES (1, 1)" );
    9999
     
    101101        $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".$wpdb->escape(__('Mr WordPress'))."', '', 'http://wordpress.org/', '$now', '$now_gmt', '".$wpdb->escape(__('Hi, this is a comment.<br />To delete a comment, just log in and view the post&#039;s comments. There you will have the option to edit or delete them.'))."')");
    102102
    103103        // First Page
    104         $first_post_guid = get_option('home') . '/?page_id=2';
     104        $first_post_guid = $wpdb->get_var('SELECT UUID()');
    105105        $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, guid, post_status, post_type, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(_c('about|Default page slug'))."', '$now', '$now_gmt','$first_post_guid', 'publish', 'page', '', '', '')");
    106106}
    107107endif;
  • wp-includes/post.php

     
    13011301                clean_post_cache($post_ID);
    13021302
    13031303        // Set GUID
    1304         if ( !$update && '' == $current_guid )
    1305                 $wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post_ID ) ), $where );
     1304        if ( !$update && '' == $current_guid ) {
     1305                // get a UUID
     1306                $uuid = $wpdb->get_var('SELECT UUID();');
     1307                $wpdb->update( $wpdb->posts, array( 'guid' => $uuid ), $where );
     1308        }
    13061309
    13071310        $post = get_post($post_ID);
    13081311