CNR is giving a PHP Notice when adding new content with a reference to an existing node which has no back references:
"Notice: Undefined index: und in corresponding_node_references_insert() (line 30 of ...\sites\all\modules\cnr\corresponding_node_references.crud.inc)."
This doesn't seem to prevent the creation of the back reference, but the notice message is confusing to users.
I've fixed this locally by replacing
if ($referenced_node->{$away_field}[$lang][0]['nid'] == NULL) {
with
if (array_key_exists($lang, $referenced_node->{$away_field}) == FALSE || $referenced_node->{$away_field}[$lang][0]['nid'] == NULL) {
Comments
Comment #1
rfayI got the same error when adding referenced node:
Comment #2
damienmckennaJust ran into this.
Comment #3
AgaPe commentedthe same
Comment #4
czigor commentedThanks for the fix, gtill. Committed it.
Comment #5
ClaudeS-1 commentedFYI, getting the same, but from the update function instead of the insert function.
Using 7.x-4.x-dev from 2011-May-14
Am editing nodes which should have back-references to each other, but I think another language-related bug (http://drupal.org/node/1159304) is stopping it all from working.
Notice: Undefined index: und 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).
Comment #7
tiyberius commentedI'm using Drupal 7.8-dev and CNR 7.x-4.1, and I'm getting the error described in the original post. I followed gtill's directions ...
and the error went away. Looking at comment #4 in this issue (http://drupal.org/comment/reply/1148948#comment-4465060), I thought it had been committed, so I'm thinking that the original if() statement crept back into the latest release somehow?
Comment #8
czigor commentedIt is not in 4.1 yet but only in the dev.
Comment #10
Frederic wbase commentedfixe worked great, thx!
Comment #11
trgreen17 commentedBrilliant! Thanks so much for the tip. Works perfectly.
Tim
Comment #12
Frederic wbase commentedmaybe commit it to latest dev?
Comment #13
rv0 commentedI did it a bit differently..
I think the error originates when the field is empty, so of course it wont find index "und".
So instead of doing array_key_exists:
The && makes more sense to me than using ||
Comment #14
anybodyIs it possible to get this into a new stable? The problem still seems to exist and is only fixed in dev? So it's not usable in production even after 3 years!
After this long time it should be testet enough :)
Thanks a lot for the great module!