I'm having problems getting this to work when different languages are involved.

I've got a "product" node with language en-US.
And "product manual" nodes which are language neutral.

When I update the product, with references to one of the product-manuals, I get this error:

Notice: Undefined index: en-US in corresponding_node_references_update() (line 154 of /httpdocs/sites/all/modules/cnr/corresponding_node_references.crud.inc).
Warning: Invalid argument supplied for foreach() in corresponding_node_references_update() (line 154 of /httpdocs/sites/all/modules/cnr/corresponding_node_references.crud.inc).

The back-references don't get created.
I've tested with various language combinations, and it only works when both nodes are in the same language.

Please advise is this is fixable; it would be ideal to be able to link various nodes with various languages.

Comments

czigor’s picture

Status: Active » Fixed

Thanks for the report. Fix is now in the dev branch. Please test.

ClaudeS-1’s picture

Still getting the same error, with the dev version from May 14.

May have lots of cases to deal with?
e.g.
en-US node linking to en manual
en node linking to en-US manual
en-US node linking to neutral manual
etc. etc.

czigor’s picture

You have to wait until the date of dev version gets updated to 19 May. That might take as much as 12 hours.

Alternatively you can download the latest version from the repository.

ClaudeS-1’s picture

Now I get this error:

Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of /httpdocs/includes/entity.inc).

followed by these, which may or may not be related:

Notice: Trying to get property of non-object in file_field_presave() (line 221 of /httpdocs/modules/file/file.field.inc).
Notice: Undefined property: stdClass::$uri in file_save() (line 575 of /httpdocs/includes/file.inc).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '' for key 2: INSERT INTO {file_managed} (filesize, status, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => 0 [:db_insert_placeholder_1] => 1 [:db_insert_placeholder_2] => 1305896230 ) in drupal_write_record() (line 6776 of /httpdocs/includes/common.inc)

The error disappears, and I can save the node fine, if I disable the CNR module.

czigor’s picture

Could you give the steps to reproduce?

ClaudeS-1’s picture

I've done some more thorough testing, and am no longer getting that error. I noticed that the mandatory PDF for the product manual was missing (not sure how), but that must have been causing the problem.

However, in my testing, I've noticed some strange behaviour.

Product A is en-US.
Manual 1 is en-US.
Manual 2 is en.
Manual 3 is en.

Linking A to 2 behaves as expected (a corresponding reference is added in manual 2, linking back to product A)
I edit A to point to 3 instead. Works fine.
I then edit A to point to 1 instead. Works fine.
I then edit A to point to 2 only. But the links between A-1 remain, and never disappear from now on.

If I link A to 1 and 2, that's fine.
Then if I link A to No Manuals, the link to 2 disappears, but the link to 1 still remains.

I tried this with Product B (en), linking to en and en-US manuals, but couldn't get the same behaviour.

czigor’s picture

Thanks for the testing!

I followed the steps you described but could not reproduce. I have an idea, though, what might cause the problem. I think it should not happen if you initially set up your site with the most recent cnr dev version, only if you upgraded from the buggy version.

If your product->manual nodereference field is called 'pm' then there is a db table called field_data_field_pm. In this table look for the rows that have the nid of your product A in the column 'entity_id'. All these rows should have the 'language' set to en-US (ie. the language of A). The problem is caused by the rows with other 'language' values.

I do not know how to stop the problem once it is there. If you delete these bad rows manually, they come back. You can try deleting these rows AND clearing all the cache tables, maybe that helps. Deleting and recreating the nodes that have these inappropriate rows surely helps, I don't know if that's an option for you.

Hope that helps. If you find the solution, please post it here.

ClaudeS-1’s picture

Thanks for the feedback - it's not an option for me to create nodes again, but there must be a DB edit to upgrade nodes that were created before your fix... would be interesting to know the exact details of the change to the DB since the buggy version.

I went through the DB and removed any rows featuring the problem product/manual (including the revisions tables), and cleared the cache - I accidentally removed a PDF file to manual association, which meant I had to delete the manual node, but haven't spotted the problem occurring again.

I did spot this one problem when I deleted the node for the en-US manual I was testing with - could be the related to the initial bug (but not yet fixed in deletion), or could be because I accidentally deleted the link to the mandatory PDF file:

Notice: Undefined index: en-US in corresponding_node_references_delete() (line 229 of /var/www/vhosts/s353270069.onlinehome.info/httpdocs/sites/all/modules/cnr/corresponding_node_references.crud.inc).

I'll get back to you if I spot any bugs re-occurring.

Status: Fixed » Closed (fixed)

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