Make WordPress Core

Ticket #27194: 27194.patch

File 27194.patch, 1.9 KB (added by maxcutler, 11 years ago)
  • src/wp-includes/class-wp-xmlrpc-server.php

     
    11301130                                                return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign a term to one of the given taxonomies.' ) );
    11311131
    11321132                                        $term_ids = $post_data['terms'][$taxonomy];
     1133                                        $terms[$taxonomy] = array();
    11331134                                        foreach ( $term_ids as $term_id ) {
    11341135                                                $term = get_term_by( 'id', $term_id, $taxonomy );
    11351136
  • tests/phpunit/tests/xmlrpc/wp/editPost.php

     
    309309        }
    310310
    311311        /**
     312         * @ticket 27194
     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         */
    314341        function test_add_enclosure_if_new() {