mirror of
git://develop.git.wordpress.org/
synced 2025-02-24 16:43:06 +01:00
XML-RPC: In wp.editPost, Remove all terms in a taxonomy when an empty array is explicitly passed.
props jstraitiff, maxcutler. fixes #26686. git-svn-id: https://develop.svn.wordpress.org/trunk@27554 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
890b809bb9
commit
f4cc32fac9
@ -1131,6 +1131,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign a term to one of the given taxonomies.' ) );
|
||||
|
||||
$term_ids = $post_data['terms'][$taxonomy];
|
||||
$terms[ $taxonomy ] = array();
|
||||
foreach ( $term_ids as $term_id ) {
|
||||
$term = get_term_by( 'id', $term_id, $taxonomy );
|
||||
|
||||
|
@ -308,6 +308,33 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase {
|
||||
$this->assertContains( $term_id, $term_ids );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 26686
|
||||
*/
|
||||
function test_clear_categories_on_edit() {
|
||||
$editor_id = $this->make_user_by_role( 'editor' );
|
||||
|
||||
$post_id = $this->factory->post->create( array( 'post_author' => $editor_id ) );
|
||||
$term_id = $this->factory->category->create();
|
||||
$this->factory->term->add_post_terms( $post_id, $term_id, 'category', true );
|
||||
$term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' );
|
||||
$this->assertContains( $term_id, $term_ids );
|
||||
|
||||
$new_post_content = array(
|
||||
'ID' => $post_id,
|
||||
'post_title' => 'Updated',
|
||||
'terms' => array(
|
||||
'category' => array()
|
||||
)
|
||||
);
|
||||
$result = $this->myxmlrpcserver->wp_editPost( array( 1, 'editor', 'editor', $post_id, $new_post_content ) );
|
||||
$this->assertNotInstanceOf( 'IXR_Error', $result );
|
||||
$this->assertEquals( 'Updated', get_post( $post_id )->post_title );
|
||||
|
||||
$term_ids = wp_list_pluck( get_the_category( $post_id ), 'term_id' );
|
||||
$this->assertNotContains( $term_id, $term_ids );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 23219
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user