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
+18
View File
@@ -1200,4 +1200,22 @@ class Tests_Post extends WP_UnitTestCase {
// Teardown
wp_set_current_user( $old_uid );
}
/**
* @ticket 32585
*/
public function test_wp_insert_post_author_zero() {
$post_id = $this->factory->post->create( array( 'post_author' => 0 ) );
$this->assertEquals( 0, get_post( $post_id )->post_author );
}
/**
* @ticket 32585
*/
public function test_wp_insert_post_author_null() {
$post_id = $this->factory->post->create( array( 'post_author' => null ) );
$this->assertEquals( $this->author_id, get_post( $post_id )->post_author );
}
}