#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)
#3
follow-up:
↓ 4
@
11 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.
#4
in reply to:
↑ 3
@
11 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:
- Created a category with
ęąóżźć
as a name. - Put
$category = get_term_by( 'name', 'ęąóżźć', 'category' );
in a PHP file. - Made sure the file is encoded in UTF-8.
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 )
#5
follow-up:
↓ 6
@
11 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.
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.