diff --git a/wp-admin/upgrade-functions.php b/wp-admin/upgrade-functions.php index 057f3dd39a..02a1510119 100644 --- a/wp-admin/upgrade-functions.php +++ b/wp-admin/upgrade-functions.php @@ -147,13 +147,18 @@ function upgrade_130() { global $wpdb, $table_prefix; // Remove extraneous backslashes. - $posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt FROM $wpdb->posts"); + $posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts"); if ($posts) { foreach($posts as $post) { $post_content = addslashes(deslash($post->post_content)); $post_title = addslashes(deslash($post->post_title)); $post_excerpt = addslashes(deslash($post->post_excerpt)); - $wpdb->query("UPDATE $wpdb->posts SET post_title = '$post_title', post_content = '$post_content', post_excerpt = '$post_excerpt' WHERE ID = '$post->ID'"); + if ( empty($post->guid) ) + $guid = get_option('home') . '/' . get_permalink(); + else + $guid = $post->guid; + + $wpdb->query("UPDATE $wpdb->posts SET post_title = '$post_title', post_content = '$post_content', post_excerpt = '$post_excerpt', guid = '$guid' WHERE ID = '$post->ID'"); } } diff --git a/wp-includes/template-functions-links.php b/wp-includes/template-functions-links.php index dfe3ec3181..2ad98c60b7 100644 --- a/wp-includes/template-functions-links.php +++ b/wp-includes/template-functions-links.php @@ -26,65 +26,62 @@ function permalink_single_rss($file = '') { echo get_permalink(); } -function get_permalink($id=false) { - global $post, $wpdb; - global $querystring_start, $querystring_equal; +function get_permalink($id = false) { + global $post, $wpdb; - $rewritecode = array( - '%year%', - '%monthnum%', - '%day%', - '%hour%', - '%minute%', - '%second%', - '%postname%', - '%post_id%', - '%category%', - '%author%', - '%pagename%' - ); + $rewritecode = array( + '%year%', + '%monthnum%', + '%day%', + '%hour%', + '%minute%', + '%second%', + '%postname%', + '%post_id%', + '%category%', + '%author%', + '%pagename%' + ); - if ($id) { - $idpost = $wpdb->get_row("SELECT ID, post_date, post_name, post_status, post_author FROM $wpdb->posts WHERE ID = $id"); - } else { - $idpost = $post; - } + if ($id) { + $idpost = $wpdb->get_row("SELECT ID, post_date, post_name, post_status, post_author FROM $wpdb->posts WHERE ID = $id"); + } else { + $idpost = $post; + } - $permalink = get_settings('permalink_structure'); + $permalink = get_settings('permalink_structure'); - if ('' != $permalink) { - if ($idpost->post_status == 'static') { - $permalink = page_permastruct(); - } + if ('' != $permalink) { + if ($idpost->post_status == 'static') + $permalink = page_permastruct(); - $unixtime = strtotime($idpost->post_date); + $unixtime = strtotime($idpost->post_date); - $cats = get_the_category($idpost->ID); - $category = $cats[0]->category_nicename; - $authordata = get_userdata($idpost->post_author); - $author = $authordata->user_nicename; - - $rewritereplace = array( - date('Y', $unixtime), - date('m', $unixtime), - date('d', $unixtime), - date('H', $unixtime), - date('i', $unixtime), - date('s', $unixtime), - $idpost->post_name, - $idpost->ID, - $category, - $author, - $idpost->post_name, - ); - return get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink); - } else { // if they're not using the fancy permalink option - $permalink = get_settings('home') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$idpost->ID; - if ($idpost->post_status == 'static') { - $permalink .= $querystring_separator . "static=1"; - } - return $permalink; - } + $cats = get_the_category($idpost->ID); + $category = $cats[0]->category_nicename; + $authordata = get_userdata($idpost->post_author); + $author = $authordata->user_nicename; + $rewritereplace = + array( + date('Y', $unixtime), + date('m', $unixtime), + date('d', $unixtime), + date('H', $unixtime), + date('i', $unixtime), + date('s', $unixtime), + $idpost->post_name, + $idpost->ID, + $category, + $author, + $idpost->post_name, + ); + return get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink); + } else { // if they're not using the fancy permalink option + $permalink = get_settings('home') . '/' . get_settings('blogfilename') . '?p=' . $idpost->ID; + if ($idpost->post_status == 'static') + $permalink .= '&static=1'; + return $permalink; + } } function get_month_link($year, $month) {