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/tests/phpunit/tests/post.php

    r34001 r34085  
    12011201        wp_set_current_user( $old_uid );
    12021202    }
     1203
     1204    /**
     1205     * @ticket 32585
     1206     */
     1207    public function test_wp_insert_post_author_zero() {
     1208        $post_id = $this->factory->post->create( array( 'post_author' => 0 ) );
     1209
     1210        $this->assertEquals( 0, get_post( $post_id )->post_author );
     1211    }
     1212
     1213    /**
     1214     * @ticket 32585
     1215     */
     1216    public function test_wp_insert_post_author_null() {
     1217        $post_id = $this->factory->post->create( array( 'post_author' => null ) );
     1218
     1219        $this->assertEquals( $this->author_id, get_post( $post_id )->post_author );
     1220    }
    12031221}
Note: See TracChangeset for help on using the changeset viewer.