This is a really specific problem that occurs on sites with multiple languages and cck nodereferences.
When you use the node service to save a node that has a nodereference and is in a different language than the default language, you get an error.

I came across this problem by using the deployment module.
Both sites have two languages, dutch and french. With dutch as the default language.
When I deployed a french node with a node reference to an other french node it failed with the error:
%name: this post can't be referenced.

This error is generated by nodereference_field in nodereference.module
It generates a list of possible nodereferences (_nodereference_potential_references)
by executing the query

SELECT DISTINCT n.nid, n.title AS node_title, n.type AS node_type 
FROM {node} n 
WHERE (n.language ='nl' OR n.language ='' OR n.language IS NULL) 
  AND ( (n.type = '%s' OR n.type = '%s') 
  AND (n.nid IN (%d)) )ORDER BY n.title, n.type

In the first WHERE part the current language is used. In this case dutch: (n.language ='nl' OR n.language ='' OR n.language IS NULL)
But because the referenced node is in french, no results are found. This results in the error.

I think it is better to set the current active language to the language of the node that is going to be saved.
So I added

global $language;
$languages = language_list();
$language = isset($languages[$edit['language']]) ? $languages[$edit['language']] : $language;

to node_service_save. This solved the problem.

Comments

johannesdr’s picture

Status: Active » Needs review
StatusFileSize
new647 bytes

Here is a patch for my suggested change.

Status: Needs review » Needs work

The last submitted patch, services-956848.patch, failed testing.

johannesdr’s picture

Status: Needs work » Needs review
StatusFileSize
new643 bytes

Removed windows formatting

Status: Needs review » Needs work

The last submitted patch, services-956848.patch, failed testing.

wmostrey’s picture

StatusFileSize
new643 bytes

Re-upload.

wmostrey’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, services-956848_0.patch, failed testing.

johannesdr’s picture

Status: Needs work » Needs review
StatusFileSize
new616 bytes

re-upload, changed patch path

Status: Needs review » Needs work

The last submitted patch, services-956848.patch, failed testing.

johannesdr’s picture

StatusFileSize
new825 bytes

re-upload

johannesdr’s picture

Status: Needs work » Needs review
wmostrey’s picture

Status: Needs review » Reviewed & tested by the community

Passed the last test and I can confirm it to work as advertised.

kylebrowning’s picture

Status: Reviewed & tested by the community » Fixed

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.