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.


git-svn-id: https://develop.svn.wordpress.org/trunk@34085 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2015-09-12 18:53:56 +00:00
parent ad20c3db4a
commit db3a7133f2
2 changed files with 19 additions and 1 deletions
+1 -1
View File
@@ -3042,7 +3042,7 @@ function wp_insert_post( $postarr, $wp_error = false ) {
// These variables are needed by compact() later.
$post_content_filtered = $postarr['post_content_filtered'];
$post_author = empty( $postarr['post_author'] ) ? $user_id : $postarr['post_author'];
$post_author = isset( $postarr['post_author'] ) ? $postarr['post_author'] : $user_id;
$ping_status = empty( $postarr['ping_status'] ) ? get_default_comment_status( $post_type, 'pingback' ) : $postarr['ping_status'];
$to_ping = isset( $postarr['to_ping'] ) ? sanitize_trackback_urls( $postarr['to_ping'] ) : '';
$pinged = isset( $postarr['pinged'] ) ? $postarr['pinged'] : '';