WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#24665 closed defect (bug) (duplicate)

xml-rpc wp.newPost - A term with the name provided already exists.

Reported by: bigwolk Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5.1
Component: XML-RPC Keywords:
Focuses: Cc:

Description

Hi,
I'm creating posts using wp.newPost method via xml-rpc api. I published many posts on that way and there were no problems until now. For some reasons xml-rpc api send back message: "A term with the name provided already exists.". This message should be back only if there is a try to create new term with same name and slug. But if I'm creating post with terms which already exists wp should search if these terms exists and use their ids. It always works in this way. When I create this same post directly on wp it publish with no problems. A terms in post structure I'm sending to wp looks like:
$note = array('terms_names' => array('post_tag'=>array('tag1','0'),'category'=>array('some category')));

Change History (8)

comment:1 @markoheijnen2 years ago

I think you use the argument "term_names" for adding terms to a post. Since it is a hierarchical taxonomy you should probably use the argument "terms" instead of "terms_names". Passing ID's is saver.

I'm not sure why you get the error. Can you tell what exact arguments you use and if that term name exists multiple times? The code already tries to find the id's for the posts. See http://core.trac.wordpress.org/browser/trunk/wp-includes/class-wp-xmlrpc-server.php#L1173. But somehow in your case something goes wrong.

comment:2 @SergeyBiryukov2 years ago

  • Keywords reporter-feedback added

comment:3 follow-up: @bigwolk2 years ago

Thanks for your reply. I analyzed http://core.trac.wordpress.org/browser/trunk/wp-includes/class-wp-xmlrpc-server.php#L1173 and I found where problem is. Method get_term_by( 'name', $term_name, $taxonomy) on line 1178 don't manage with polish national signs like ęąóżźć. I don`t know how about other languages like german umlauts or others. For now only solution is use argument "terms" instead of "terms_names" as markoheijnen wrote. Thanks a lot.

Last edited 2 years ago by bigwolk (previous) (diff)

comment:4 in reply to: ↑ 3 @SergeyBiryukov2 years ago

Replying to bigwolk:

Method get_term_by( 'name', $term_name, $taxonomy) on line 1178 don't manage with polish national signs like ęąóżźć.

Might be related to #18625. Could not reproduce though:

  1. Created a category with ęąóżźć as a name.
  2. Put $category = get_term_by( 'name', 'ęąóżźć', 'category' ); in a PHP file.
  3. Made sure the file is encoded in UTF-8.
  4. get_term_by() returned the correct category object:
    stdClass Object
    (
        [term_id] => 205
        [name] => ęąóżźć
        [slug] => eaozzc
        [term_group] => 0
        [term_taxonomy_id] => 248
        [taxonomy] => category
        [description] => 
        [parent] => 0
        [count] => 0
    )
    

comment:5 follow-up: @bigwolk2 years ago

Hi Sergey. I'm sorry, I were wrong. It's not national signs, but there was an "&" sign in terms, that created this situation. Try to add term like "sound&system" or something like that.

comment:6 in reply to: ↑ 5 @SergeyBiryukov2 years ago

Replying to bigwolk:

It's not national signs, but there was an "&" sign in terms, that created this situation.

There's a ticket for that too: #24354.

comment:7 @bigwolk2 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #24354.

comment:8 @SergeyBiryukov2 years ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.