Make WordPress Core

Ticket #61798: 61798.patch

File 61798.patch, 820 bytes (added by iflairwebtechnologies, 8 months ago)

Fixed: #61798 Not possible to assign author to unowned post in the primary edit form

  • src/wp-includes/post.php

    diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php
    index 993056ff2c..fb737f9a62 100644
    a b function wp_untrash_post( $post_id = 0 ) { 
    38593859        delete_post_meta( $post_id, '_wp_trash_meta_status' );
    38603860        delete_post_meta( $post_id, '_wp_trash_meta_time' );
    38613861
    3862         $post_updated = wp_update_post(
    3863                 array(
    3864                         'ID'          => $post_id,
    3865                         'post_status' => $post_status,
    3866                 )
     3862        $args = array(
     3863                'ID'          => $post_id,
     3864                'post_status' => $post_status,
    38673865        );
    38683866
     3867        $post_author_id = get_post_field( 'post_author', $post_id );
     3868
     3869        if ( !( (bool) get_user_by( 'id', $post_author_id ) ) ) {
     3870                $args['post_author'] = get_current_user_id();
     3871        }
     3872
     3873        $post_updated = wp_update_post( $args );
     3874
    38693875        if ( ! $post_updated ) {
    38703876                return false;
    38713877        }