Make WordPress Core

Ticket #11504: 11504.4.diff

File 11504.4.diff, 2.5 KB (added by nacin, 15 years ago)

int cast added back in, also refreshed against trunk r12602

  • post.php

     
    3131        if ( isset($post_data['trackback_url']) )
    3232                $post_data['to_ping'] = $post_data['trackback_url'];
    3333
     34        if ( !isset($post_data['user_ID']) )
     35                $post_data['user_ID'] = $GLOBALS['user_ID'];
     36
    3437        if (!empty ( $post_data['post_author_override'] ) ) {
    3538                $post_data['post_author'] = (int) $post_data['post_author_override'];
    3639        } else {
     
    6467                $post_data['post_status'] = 'draft';
    6568        if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] )
    6669                $post_data['post_status'] = 'private';
    67         if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( $post_data['post_status'] != 'private' ) )
     70        if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( !isset($post_data['post_status']) || $post_data['post_status'] != 'private' ) )
    6871                $post_data['post_status'] = 'publish';
    6972        if ( isset($post_data['advanced']) && '' != $post_data['advanced'] )
    7073                $post_data['post_status'] = 'draft';
    7174        if ( isset($post_data['pending']) && '' != $post_data['pending'] )
    7275                $post_data['post_status'] = 'pending';
    7376
    74         $previous_status = get_post_field('post_status',  isset($post_data['ID']) ? $post_data['ID'] : $post_data['temp_ID']);
     77        if ( isset( $post_data['ID'] ) )
     78                $post_id = $post_data['ID'];
     79        elseif ( isset( $post_data['temp_ID'] ) )
     80                $post_id = $post_data['temp_ID'];
     81        else
     82                $post_id = false;
     83        $previous_status = $post_id ? get_post_field( 'post_status', $post_id ) : false;
    7584
    7685        // Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published.
    7786        // Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts.
    78         if ( 'page' == $post_data['post_type'] ) {
     87        if ( isset( $post_data['post_type'] ) && 'page' == $post_data['post_type'] ) {
    7988                $publish_cap = 'publish_pages';
    8089                $edit_cap = 'edit_published_pages';
    8190        } else {
     
    446455function wp_write_post() {
    447456        global $user_ID;
    448457
    449         if ( 'page' == $_POST['post_type'] ) {
     458        if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) {
    450459                if ( !current_user_can( 'edit_pages' ) )
    451460                        return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this blog.' ) );
    452461        } else {
     
    454463                        return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this blog.' ) );
    455464        }
    456465
    457 
    458466        // Check for autosave collisions
    459467        $temp_id = false;
    460468        if ( isset($_POST['temp_ID']) ) {