Changeset 1605

Show
Ignore:
Timestamp:
09/05/04 02:41:01 (4 years ago)
Author:
saxmatt
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/upgrade-functions.php

    r1601 r1605  
    148148 
    149149    // Remove extraneous backslashes. 
    150     $posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt FROM $wpdb->posts"); 
     150    $posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts"); 
    151151    if ($posts) { 
    152152        foreach($posts as $post) { 
     
    154154            $post_title = addslashes(deslash($post->post_title)); 
    155155            $post_excerpt = addslashes(deslash($post->post_excerpt)); 
    156             $wpdb->query("UPDATE $wpdb->posts SET post_title = '$post_title', post_content = '$post_content', post_excerpt = '$post_excerpt' WHERE ID = '$post->ID'"); 
     156            if ( empty($post->guid) ) 
     157                $guid = get_option('home') . '/' . get_permalink(); 
     158            else 
     159                $guid = $post->guid; 
     160 
     161            $wpdb->query("UPDATE $wpdb->posts SET post_title = '$post_title', post_content = '$post_content', post_excerpt = '$post_excerpt', guid = '$guid' WHERE ID = '$post->ID'"); 
    157162        } 
    158163    } 
  • trunk/wp-includes/template-functions-links.php

    r1557 r1605  
    2727} 
    2828 
    29 function get_permalink($id=false) { 
    30     global $post, $wpdb; 
    31     global $querystring_start, $querystring_equal; 
    32  
    33     $rewritecode = array( 
    34         '%year%', 
    35         '%monthnum%', 
    36         '%day%', 
    37     '%hour%', 
    38     '%minute%', 
    39     '%second%', 
    40         '%postname%', 
    41         '%post_id%', 
    42         '%category%', 
    43     '%author%', 
    44         '%pagename%' 
    45     ); 
    46  
    47     if ($id) { 
    48         $idpost = $wpdb->get_row("SELECT ID, post_date, post_name, post_status, post_author FROM $wpdb->posts WHERE ID = $id"); 
    49     } else { 
    50         $idpost = $post; 
    51     } 
    52  
    53     $permalink = get_settings('permalink_structure'); 
    54  
    55     if ('' != $permalink) { 
    56         if ($idpost->post_status == 'static') { 
    57             $permalink = page_permastruct(); 
    58         } 
    59  
    60         $unixtime = strtotime($idpost->post_date); 
    61  
    62         $cats = get_the_category($idpost->ID); 
    63         $category = $cats[0]->category_nicename; 
    64         $authordata = get_userdata($idpost->post_author); 
    65     $author = $authordata->user_nicename; 
    66  
    67         $rewritereplace = array( 
    68                                 date('Y', $unixtime), 
    69                                 date('m', $unixtime), 
    70                                 date('d', $unixtime), 
    71                                 date('H', $unixtime), 
    72                                 date('i', $unixtime), 
    73                                 date('s', $unixtime), 
    74                                 $idpost->post_name, 
    75                                 $idpost->ID, 
    76                                 $category, 
    77                 $author, 
    78                                 $idpost->post_name, 
    79                                 ); 
    80         return get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink); 
    81     } else { // if they're not using the fancy permalink option 
    82         $permalink = get_settings('home') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$idpost->ID; 
    83         if ($idpost->post_status == 'static') { 
    84             $permalink .=  $querystring_separator . "static=1"; 
    85         } 
    86     return $permalink; 
    87     } 
     29function get_permalink($id = false) { 
     30    global $post, $wpdb; 
     31 
     32    $rewritecode = array( 
     33        '%year%', 
     34        '%monthnum%', 
     35        '%day%', 
     36        '%hour%', 
     37        '%minute%', 
     38        '%second%', 
     39        '%postname%', 
     40        '%post_id%', 
     41        '%category%', 
     42        '%author%', 
     43        '%pagename%' 
     44    ); 
     45 
     46    if ($id) { 
     47        $idpost = $wpdb->get_row("SELECT ID, post_date, post_name, post_status, post_author FROM $wpdb->posts WHERE ID = $id"); 
     48    } else { 
     49        $idpost = $post; 
     50    } 
     51 
     52    $permalink = get_settings('permalink_structure'); 
     53 
     54    if ('' != $permalink) { 
     55        if ($idpost->post_status == 'static') 
     56            $permalink = page_permastruct(); 
     57 
     58        $unixtime = strtotime($idpost->post_date); 
     59 
     60        $cats = get_the_category($idpost->ID); 
     61        $category = $cats[0]->category_nicename; 
     62        $authordata = get_userdata($idpost->post_author); 
     63        $author = $authordata->user_nicename; 
     64        $rewritereplace =  
     65        array( 
     66            date('Y', $unixtime), 
     67            date('m', $unixtime), 
     68            date('d', $unixtime), 
     69            date('H', $unixtime), 
     70            date('i', $unixtime), 
     71            date('s', $unixtime), 
     72            $idpost->post_name, 
     73            $idpost->ID, 
     74            $category, 
     75            $author, 
     76            $idpost->post_name, 
     77        ); 
     78        return get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink); 
     79    } else { // if they're not using the fancy permalink option 
     80        $permalink = get_settings('home') . '/' . get_settings('blogfilename') . '?p=' . $idpost->ID; 
     81        if ($idpost->post_status == 'static') 
     82            $permalink .=  '&static=1'; 
     83        return $permalink; 
     84    } 
    8885} 
    8986