mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
XML-RPC: in wp_xmlrpc_server::wp_editTerm(), check ! empty when applying parent logic.
Adds unit tests. Props hrishiv90, markoheijnen, sam2kb. Fixes #21977. git-svn-id: https://develop.svn.wordpress.org/trunk@34580 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
90ad5546d5
commit
881808bb11
@ -1934,7 +1934,7 @@ class wp_xmlrpc_server extends IXR_Server {
|
||||
return new IXR_Error( 403, __( 'The term name cannot be empty.' ) );
|
||||
}
|
||||
|
||||
if ( isset( $content_struct['parent'] ) ) {
|
||||
if ( ! empty( $content_struct['parent'] ) ) {
|
||||
if ( ! $taxonomy['hierarchical'] )
|
||||
return new IXR_Error( 403, __( "This taxonomy is not hierarchical so you can't set a parent." ) );
|
||||
|
||||
|
||||
@ -92,9 +92,20 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase {
|
||||
$this->make_user_by_role( 'editor' );
|
||||
|
||||
$result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], array( 'taxonomy' => 'category', 'parent' => '', 'name' => 'test' ) ) );
|
||||
$this->assertInstanceOf( 'IXR_Error', $result );
|
||||
$this->assertEquals( 500, $result->code );
|
||||
$this->assertEquals( __('Empty Term'), $result->message );
|
||||
$this->assertNotInstanceOf( 'IXR_Error', $result );
|
||||
$this->assertTrue( $result );
|
||||
}
|
||||
|
||||
function test_parent_null() {
|
||||
$this->make_user_by_role( 'editor' );
|
||||
|
||||
$result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], array( 'taxonomy' => 'category', 'parent' => NULL, 'name' => 'test' ) ) );
|
||||
|
||||
$this->assertNotInstanceOf( 'IXR_Error', $result );
|
||||
$this->assertInternalType( 'boolean', $result );
|
||||
|
||||
$term = get_term( $this->child_term['term_id'], 'category' );
|
||||
$this->assertEquals( '0', $term->parent );
|
||||
}
|
||||
|
||||
function test_parent_invalid() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user