Make WordPress Core


Ignore:
Timestamp:
02/09/2015 10:53:40 PM (10 years ago)
Author:
boonebgorges
Message:

Don't parse empty 'tax_input' keys in edit_post().

This fixes a bug introduced in [31359] where saving a tax_input that contained
only whitespace would result in a random tag being erroneously added to the
post.

See #30615.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/admin/includesPost.php

    r31359 r31392  
    177177
    178178    /**
     179     * @ticket 30615
     180     */
     181    public function test_edit_post_should_not_create_terms_for_an_empty_tag_input_field() {
     182        $u = $this->factory->user->create( array( 'role' => 'editor' ) );
     183        wp_set_current_user( $u );
     184
     185        register_taxonomy( 'wptests_tax', array( 'post' ) );
     186        $t1 = $this->factory->term->create( array(
     187            'taxonomy' => 'wptests_tax',
     188            'name' => 'foo',
     189            'slug' => 'bar',
     190        ) );
     191
     192        $p = $this->factory->post->create();
     193
     194        $post_data = array(
     195            'post_ID' => $p,
     196            'tax_input' => array(
     197                'wptests_tax' => ' ',
     198            ),
     199        );
     200
     201        edit_post( $post_data );
     202
     203        $found = wp_get_post_terms( $p, 'wptests_tax' );
     204
     205        $this->assertEmpty( $found );
     206    }
     207
     208    /**
    179209     * @ticket 27792
    180210     */
Note: See TracChangeset for help on using the changeset viewer.