Make WordPress Core


Ignore:
Timestamp:
09/12/2015 06:53:56 PM (9 years ago)
Author:
wonderboymusic
Message:

In wp_insert_post(), when setting $post_author, use isset() instead of ! empty() to allow 0 to be passed as the value for $post_author.

Adds unit tests.

Props ericdaams, wonderboymusic.
Fixes #32585.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post-functions.php

    r34082 r34085  
    30433043    // These variables are needed by compact() later.
    30443044    $post_content_filtered = $postarr['post_content_filtered'];
    3045     $post_author = empty( $postarr['post_author'] ) ? $user_id : $postarr['post_author'];
     3045    $post_author = isset( $postarr['post_author'] ) ? $postarr['post_author'] : $user_id;
    30463046    $ping_status = empty( $postarr['ping_status'] ) ? get_default_comment_status( $post_type, 'pingback' ) : $postarr['ping_status'];
    30473047    $to_ping = isset( $postarr['to_ping'] ) ? sanitize_trackback_urls( $postarr['to_ping'] ) : '';
Note: See TracChangeset for help on using the changeset viewer.