Closed (outdated)
Project:
Relevant Content
Version:
5.x-1.3
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
7 Nov 2008 at 22:56 UTC
Updated:
12 Feb 2020 at 00:17 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
bribiz commentedI'm also have the same error in 5.x version. This error occurs on the page that is attempting to display the CCK field. Let me know if I can assist further.
Comment #2
nicholasthompsonInteresting...
Although I think this is slightly different. My errors were in CCK's content.module whereas yours are inside my module.
Cheers for bringing this up though!
Comment #3
geverest commentedI'm having the exact same issue, in that the error is coming from the Relevant Content module cck function.
One of my users is reporting the issue and it seems it might be happening from using the preview without saving and then trying to add content to another cck field. Although I am unable to duplicate it.
On the other hand, to fix it, I simply remove all of the entries my user has placed in the taxonomy field and enter one single term into the taxonomy field (I require at least one entry) and save. At that point the problem goes away and I can do anything I want to the page.
Comment #4
Anonymous (not verified) commentedI'm seeing foreach errors as well but for line 226 of the relevant content CCK module. Subscribing.
Update: I noticed that I only get the foreach error when the relevant content field is enabled to display one the teaser which I'm displaying in a view I created. When I click through to the node there are no errors. For the moment I have hidden the relevant content field from the teaser view which is at http://learnbythedrop.com/drops.
Update 2: I have narrowed down the instances when the error occurs even further. It appears that the error is being thrown when a node is displayed that has no relevant posts associated with it. I'm seeing the error thrown on the post at http://learnbythedrop.com/drop/70. It just so happens that the teaser for the same post was shown in the view that I reference earlier.
Comment #5
dropchew commentedHi there, I had the same error as nicholasThompson, in cck instead of relevant content.
warning: Invalid argument supplied for foreach() in D:\xampp\htdocs\demo\sites\all\modules\cck\content.module on line 1270. This error repeats for each return results.
I notice this only happens when I tried to display as teasers. Where'as when displaying as full nodes, I get a whole "page not available/The connection to the server was reset while the page was loading" error. It working fine when displaying as title and title link.
Drupal 6.6
CCK 2.1 and latest dev (2008-Dec-04)
Relevant content 6.14 and latest dev (2008-Nov-07)
Comment #6
nicholasthompsonPossibly related to #346576: hook_content_is_empty() is not implemented
Comment #7
dan_aka_jack commentedHi there,
I was getting the following error:
As awakenedvoice mentioned in comment #4, it seems that the error is generated when a node has a unique tag (i.e. a tag which is only applied to the current node). I did a bit of tinkering and it turns out that the variable
$element['items']['#item']is null when the error occurs. So I've added a quickifstatement to test if the$element['items']['#item']variable is set before continuing with theforeachstatement.This is what lines 227 to 230 in
relevant_content_cck.modulecurrently looks like in version 6.x-1.4 of the module:I have replaced the code above with the following code:
i.e. I've simply wrapped the
foreachloop in anifstatement.My modification seems to have fixed the problem for me. I haven't yet noticed any side-effects.
Comment #8
my.wahyu commentedI have been activied All CCK MODUL 28 Feb 2009, here .. is my module
Comment #9
rbgrn commentedSame error, different line number, not sure if it makes a difference.
This is with D6.10 and latest CCK
warning: Invalid argument supplied for foreach() in /sites/all/modules/relevant_content/relevant_content_cck/relevant_content_cck.module on line 226.
is the full path of where drupal is installed, I just edited it for my own security.
If I get the error on a node, then I get no relevant content. If I get the error in the admin screens somewhere, then most things still work, I just see this error in red. This is definitely a bug.
Comment #10
rbgrn commentedI tried wrapping the foreach in the if statement provided above and that got rid of the error. I recommend that patch.
Comment #11
asb commentedHi,
I'm getting those errors with version 5.x-1.3:
Has someone already tried applying the patch to the D5 version?
Thanks & greetings, -asb
Comment #12
skizzo commentedI see the error on line 226 (as reported in #4) using CCK 6.x-2.x-dev built on 2009-04-24
warning: Invalid argument supplied for foreach() in /var/www/drupal/sites/all/modules/relevant_content/relevant_content_cck/relevant_content_cck.module on line 226.Comment #13
spython commentedThe bug is still there, even after the patch as described in #7.
If I select the field output as title or full node, it works, if I select to display it as teaser, it's broken.
Comment #14
asb commentedSimilar/duplicate issues: 354459 (D5) & 451726 (D6).
Greetings, -asb
Comment #15
icenogle commentedIt didn't work for me either, but I got it working with this:
instead of:
This hasn't been extensively tested, but PHP booleans don't always work out the way you expect them to.
Comment #16
mp commentedi got these errors when activating both
warning: Invalid argument supplied for foreach() in path_to_drupal_root_directory\includes\form.inc on line 1200.
warning: Invalid argument supplied for foreach() in path_to_drupal_root_directory\includes\form.inc on line 1200.
i added a field to a cck type and all runs fine, but when i tryed to add the existing relevant content field to another cck field i get this one
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 ') SELECT vid, nid, FROM content_type_investmentproperty' at line 1 query: INSERT INTO content_field_relcontent (vid, nid, ) SELECT vid, nid, FROM content_type_investmentproperty in path_to_drupal_root_directory\sites\all\modules\cck\includes\content.admin.inc on line 1527.
i´m using the newest D6 version
Comment #17
mp commentedand another one when adding a existing "relevant content" to a cck
user warning: Unknown column 'delta' in 'where clause' query: DELETE FROM content_field_relcontent WHERE delta >= 1 in path_to_drupal_root_directory\sites\all\modules\cck\includes\content.admin.inc on line 1492.
Comment #18
dakku commentedyup same here:
Invalid argument supplied for foreach() in /var/www/html/{foo}/relevant_content/relevant_content_cck/relevant_content_cck.module on line 226.
gonna wrap in an IF statement as suggested here:
http://drupal.org/node/331625#comment-1204192
Comment #19
calshei1 commentedI also used the patch, seems to be working just fine now.
Comment #20
tseven commentedHere is a simple patch for 5.x-1.3. It may work for other versions. I wrapped each foreach in an if (!empty($items)) statement.
Works for me.
Hope this makes it into the code.
Comment #21
asb commentedHi,
thank you the patch; with "-p0" option the patch applies cleanly on D5.
On D6 it fails ("Hunk #1 FAILED at 96. ... Hunk #2 FAILED at 208")
Greetings, -asb
Comment #22
asb commentedHi again,
any progress on this issue?
Thanks & greetings, -asb
Comment #23
.............................................. commentedthanks, this finally solved this problem for me.
Comment #24
metastate commentedI had several of the following errors in my server log:
PHP Fatal error: Call to undefined function relevant_content_cck_content_is_empty() in .../sites/all/modules/cck/content.module on line 906I think the error was being triggered when new content was being created, with a new taxonomy term (using tags).
Applied the fix suggested in comment #7, ran a couple tests, error seems to have gone away for now.
Comment #25
echoz commentedRunning Drupal 6.16 + Relevant Content v6.x-1.4
There's 3 issues in the queue for "Invalid argument supplied for foreach" errors, on different files. I think they're all related to the cck field. I just installed the module and after adding a cck field, saving the first screen, I get an Invalid argument supplied for foreach on form.inc line 1207. It is unclear to me from reading through these 3 issues what, if any are the correct fix for the form.inc error. I did not see that the dev version addressed this.
I am thrilled to find this awesome module, and hope to be able to use the cck feature. Any clarification?
Comment #26
metastate commentedActually, even after I used the fix suggested in #7, the site was still throwing the error. Didn't have time to troubleshoot further. I decided to make my own related content block with Views in the end.
Tutorial I used as a starting point: http://drupaleasy.com/blogs/ryanprice/2008/06/using-views-2-drupal-6-cre... (good tips in the comments too, I found #26 and #48 really helpful)
Comment #27
echoz commentedThat's what I did (sorry for not posting this), also written about here - http://drupal.org/node/65375
Comment #28
drurian commentedI got errors in 6.x-1.4 version, so I updated to latest dev version and the errors seem to have gone away.
Comment #29
nicholasthompsonClosing this as D5 and 6 are not support anymore + a fix for D7 for a similar bug has been committed.