Make WordPress Core

Changeset 34580


Ignore:
Timestamp:
09/26/2015 05:30:34 AM (9 years ago)
Author:
wonderboymusic
Message:

XML-RPC: in wp_xmlrpc_server::wp_editTerm(), check ! empty when applying parent logic.

Adds unit tests.

Props hrishiv90, markoheijnen, sam2kb.
Fixes #21977.

Location:
trunk
Files:
2 edited

Legend:

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

    r34579 r34580  
    19351935        }
    19361936
    1937         if ( isset( $content_struct['parent'] ) ) {
     1937        if ( ! empty( $content_struct['parent'] ) ) {
    19381938            if ( ! $taxonomy['hierarchical'] )
    19391939                return new IXR_Error( 403, __( "This taxonomy is not hierarchical so you can't set a parent." ) );
  • trunk/tests/phpunit/tests/xmlrpc/wp/editTerm.php

    r25002 r34580  
    9393
    9494        $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], array( 'taxonomy' => 'category', 'parent' => '', 'name' => 'test' ) ) );
    95         $this->assertInstanceOf( 'IXR_Error', $result );
    96         $this->assertEquals( 500, $result->code );
    97         $this->assertEquals( __('Empty Term'), $result->message );
     95        $this->assertNotInstanceOf( 'IXR_Error', $result );
     96        $this->assertTrue( $result );
     97    }
     98
     99    function test_parent_null() {
     100        $this->make_user_by_role( 'editor' );
     101
     102        $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', $this->child_term['term_id'], array( 'taxonomy' => 'category', 'parent' => NULL, 'name' => 'test' ) ) );
     103
     104        $this->assertNotInstanceOf( 'IXR_Error', $result );
     105        $this->assertInternalType( 'boolean', $result );
     106
     107        $term = get_term( $this->child_term['term_id'], 'category' );
     108        $this->assertEquals( '0', $term->parent );
    98109    }
    99110
Note: See TracChangeset for help on using the changeset viewer.