I have a node with 2 "not mandatory" node references, when both are informed, all is ok, the 2 views blocks one for each reference is shown. But, when one reference is missing (remember are not mandatory) I receive this exception:
* warning: Invalid argument supplied for foreach() in /home/fechas/public_html/modules/ReferencedByFilter/ReferencedByFilter.module on line 126.
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ) LIMIT 0, 20' at line 1 query: SELECT node.nid FROM node node WHERE (node.status = '1') AND (node.type IN ('bandas')) AND (node.nid in () ) LIMIT 0, 20 in /home/fechas/public_html/includes/database.mysql.inc on line 172.
The problem is in line 126
foreach ($node->$referencing_field as $referenced) {
because $node hasn't one of the $referencing_field
Don't know how to patch, think could be done with some "inarray" check but not experienced in this matter.
Could someone take a look at this?
thanks
Gustavo
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | ReferencedByFilter.patch | 1.09 KB | adminfor@inforo.com.ar |
Comments
Comment #1
adminfor@inforo.com.ar commentedComment #2
adminfor@inforo.com.ar commentedhi, somebody there?
Comment #3
hedb commentedNot really,
I would like to turn over this module + dependantDropDown to either someone
or mark them unactive or something like this.
Reason:
Drupal development comes and goes for me.
Another Reason:
The CVS system + the delicate coordination between it and the project page
ar too uncomprehansable for me.
So i can't just keep as a side thingy - just checking in bugs.
hed
Comment #4
adminfor@inforo.com.ar commentedhed,
I've solved this bug using my poor php knowledge. Before entering in this foreach (line 126), I check for the existence of the "node reference" key in the node array. When the node reference is not mandatory, sometimes may exist and sometimes not. Without node reference, the "where and" for the views has to return no values (nid<0 for example); without this "trick" condition, the view is going to return all the nodes that meet the other conditions.
This patch works and is in my production site, don't know If there is any other more elegant solution instead of the "nid<0"
thanks and regards
Gustavo
Comment #5
adminfor@inforo.com.ar commentedComment #6
adminfor@inforo.com.ar commentedthis patch worked fine for me for the last 6 weeks. Don't know if somebody else applied it.
I guess it should be ported.
Regards,
Gustavo
Comment #7
amitaibu@Gustavo,
I think this should fix your issue.
http://drupal.org/cvs?commit=119902
Comment #8
MediaMunkey commentedHi, I've been having the same problem with this error appearing when the node reference field doesn't have a value.
Gustavo, your patch worked great to fix the issue.
Amitaibu, your fix didn't seem to do anything at all for me. Perhaps my situation is different.
I am using the view as a block which reaches into the node on the page to list nodes the node on the page references.
Effectively I have added Gustavo's patch to the already patched module.
Is there not a better way to combine them more effectively then having to have 2 'if' statements to deduce whether to display any nodes?
I'm no coder, so I don't really know. The combination seems to work well for the moment though.
Comment #9
MediaMunkey commentedComment #10
amitaibu@MediaMunkey,
You marked fix - is it working properly for you?
Comment #11
MediaMunkey commentedActually I remarked it 'active'.
It is working for me yes, but only after the addition of Gustavo's code.
Comment #12
amitaibu@MediaMunkey,
1. The error you get is in what line? (you can paste the error message here)?
2. Try again to download the module, I want to make sure you grabbed the latest release - (Note the message in the module's front page regarding the change in the existing Views.)
Comment #13
amitaibuI was able to reproduce, and committed a fix - http://drupal.org/cvs?commit=120489
Comment #14
MediaMunkey commentedYour fix seems to have done the trick. I'm not getting any errors anymore.
Cheers Amitaibu. Thanks Gustavo for your temporary fix as well.
Comment #15
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.