WordPress.org

Make WordPress Core

Ticket #11504: 11504.patch

File 11504.patch, 2.3 KB (added by hakre, 8 years ago)

Notices Patch

  • wp-admin/includes/post.php

     
    3737                if (!empty ( $post_data['post_author'] ) ) {
    3838                        $post_data['post_author'] = (int) $post_data['post_author'];
    3939                } else {
    40                         $post_data['post_author'] = (int) $post_data['user_ID'];
     40                        $post_data['post_author'] = isset($post_data['user_ID']) ? (int) $post_data['user_ID'] : 0;
    4141                }
    4242        }
    4343
     
    6464                $post_data['post_status'] = 'draft';
    6565        if ( isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate'] )
    6666                $post_data['post_status'] = 'private';
    67         if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( $post_data['post_status'] != 'private' ) )
     67        if ( isset($post_data['publish']) && ( '' != $post_data['publish'] ) && ( ( isset($post_data['post_status']) && $post_data['post_status'] != 'private' ) || !isset($post_data['post_status']) ) )
    6868                $post_data['post_status'] = 'publish';
    6969        if ( isset($post_data['advanced']) && '' != $post_data['advanced'] )
    7070                $post_data['post_status'] = 'draft';
    7171        if ( isset($post_data['pending']) && '' != $post_data['pending'] )
    7272                $post_data['post_status'] = 'pending';
    7373
    74         $previous_status = get_post_field('post_status',  isset($post_data['ID']) ? $post_data['ID'] : $post_data['temp_ID']);
     74        $previous_status = get_post_field('post_status',  isset($post_data['ID']) ? $post_data['ID'] : ( isset($post_data['temp_ID']) ? $post_data['temp_ID'] : null ) );
    7575
    7676        // Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published.
    7777        // Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts.
    78         if ( 'page' == $post_data['post_type'] ) {
     78        if ( isset($post_data['post_type']) && 'page' == $post_data['post_type'] ) {
    7979                $publish_cap = 'publish_pages';
    8080                $edit_cap = 'edit_published_pages';
    8181        } else {
     
    445445function wp_write_post() {
    446446        global $user_ID;
    447447
    448         if ( 'page' == $_POST['post_type'] ) {
     448        if ( 'page' == ( isset($_POST['post_type']) ? $_POST['post_type'] : null ) ) {
    449449                if ( !current_user_can( 'edit_pages' ) )
    450450                        return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this blog.' ) );
    451451        } else {