Make WordPress Core


Ignore:
Timestamp:
02/09/2006 10:03:48 AM (20 years ago)
Author:
ryan
Message:

Allow draft pages. Use post_type for object types. Reserve post_status strictly for status. fixes #1820

File:
1 edited

Legend:

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

    r3373 r3510  
    3333    if ( $wp_current_db_version < 3308 )
    3434        upgrade_160();
     35
     36    if ( $wp_current_db_version < 3506 )
     37        upgrade_210();
    3538
    3639    $wp_rewrite->flush_rules();
     
    324327                add_post_meta($object->ID, '_wp_attached_file', $meta['file']);
    325328        }
     329    }
     330}
     331
     332function upgrade_210() {
     333    global $wpdb, $table_prefix, $wp_current_db_version;
     334
     335    // Update status and type.
     336    $posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
     337   
     338    if ( ! empty($posts) ) foreach ($posts as $post) {
     339        $status = $post->post_status;
     340        $type = 'post';
     341
     342        if ( 'static' == $status ) {
     343            $status = 'publish';
     344            $type = 'page';
     345        } else if ( 'attachment' == $status ) {
     346            $status = 'inherit';
     347            $type = 'attachment';   
     348        }
     349       
     350        $wpdb->query("UPDATE $wpdb->posts SET post_status = '$status', post_type = '$type' WHERE ID = '$post->ID'");
    326351    }
    327352}
Note: See TracChangeset for help on using the changeset viewer.