Set GUID on upgrade. CURRENTLY NOT WORKING. For some reason the get_settings calls aren't working.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1605 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt 2004-09-05 02:41:01 +00:00
parent ed34ca04d8
commit c54f9a539f
2 changed files with 57 additions and 55 deletions

View File

@ -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'");
}
}

View File

@ -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) {