Make WordPress Core

Changeset 27554


Ignore:
Timestamp:
03/15/2014 05:08:40 AM (11 years ago)
Author:
nacin
Message:

XML-RPC: In wp.editPost, Remove all terms in a taxonomy when an empty array is explicitly passed.

props jstraitiff, maxcutler.
fixes #26686.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

    r27553 r27554  
    11321132
    11331133                    $term_ids = $post_data['terms'][$taxonomy];
     1134                    $terms[ $taxonomy ] = array();
    11341135                    foreach ( $term_ids as $term_id ) {
    11351136                        $term = get_term_by( 'id', $term_id, $taxonomy );
  • trunk/tests/phpunit/tests/xmlrpc/wp/editPost.php

    r25002 r27554  
    310310
    311311    /**
     312     * @ticket 26686
     313     */
     314    function test_clear_categories_on_edit() {
     315        $editor_id = $this->make_user_by_role( 'editor' );
     316
     317        $post_id = $this->factory->post->create( array( 'post_author'  => $editor_id ) );
     318        $term_id = $this->factory->category->create();
     319        $this->factory->term->add_post_terms( $post_id, $term_id, 'category', true );
     320        $term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' );
     321        $this->assertContains( $term_id, $term_ids );
     322
     323        $new_post_content = array(
     324            'ID' => $post_id,
     325            'post_title' => 'Updated',
     326            'terms' => array(
     327                'category' => array()
     328            )
     329        );
     330        $result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $new_post_content ) );
     331        $this->assertNotInstanceOf( 'IXR_Error', $result );
     332        $this->assertEquals( 'Updated', get_post( $post_id )->post_title );
     333
     334        $term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' );
     335        $this->assertNotContains( $term_id, $term_ids );
     336    }
     337
     338    /**
    312339     * @ticket 23219
    313340     */
Note: See TracChangeset for help on using the changeset viewer.