Closed (duplicate)
Project:
Content Construction Kit (CCK)
Version:
6.x-2.2
Component:
General
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Feb 2009 at 18:25 UTC
Updated:
16 Apr 2009 at 06:49 UTC
I saw this reported for 5.x, not sure what is causing it 6.x
warning: Invalid argument supplied for foreach() in
/Library/WebServer/Documents/drupal/sites/all/modules/cck/content.module on line 1270.
Comments
Comment #1
yched commentedThose issues are extremely hard to track down, and are generally caused by 3rd party modules that build invalid nodes.
We've been doing our best to protect cck against those error cases, but if some still show up, there's not much that can be said or done without knowing exactly when and with which node types this happens.
Except disabling all non-cck contrib modules and re-enabling them one by one to see when the error reappears, I have little advice to give...
Comment #2
agerson commentedI disabled everything except for the root cck module and I still get the error:
warning: Invalid argument supplied for foreach() in /Library/WebServer/Documents/drupal/sites/all/modules/cck/content.module on line 1270.
Comment #3
markus_petrux commentedHave you tried CCK 6.x-2.2?
Comment #4
agerson commentedI just updated to 2.2 and I still get the same error. Its only when logged in as admin. Stranger then that, I have q=node/1 set to be the page displayed when I go to the root /drupal directory in a web browser. I use Login Destination. If I got to http://www.mysite.com/drupal/?q=node/1 I do not get the error, but if I go to http://www.mysite.com/drupal/ which forwards me to http://www.mysite.com/drupal/?q=node/1 I get the error.
Comment #5
blue.moon commentedMaybe its because of this, I think module_invoke does not return associative array, does it?
if it returns array then try this.,
else it is wrong approach to call foreach() on string.
Comment #6
Ether commentedsubscribe
Comment #7
markus_petrux commentedThose that have this problem, please try with CCK 2.2 and specify which line the error is refering to. The one in #2 and in original post is 1270, which an empty line in 2.2, so it's hard to tell where the error happens.
Comment #8
Ether commentedInvalid argument supplied for foreach() in \sites\all\modules\cck\content.module on line 1278.
Have this when trying to post comment and Embed and Attachments modules from File Framework are enabled. Using version 2.2, drupal 6.10
Comment #9
markus_petrux commentedMarked this issue as a dup: #429044: warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\eResepi\modules\cck\content.module on line 1278.
@Ether: Thanks.
Well, line 1278 in CCK 2.2 lives in _content_field_invoke_default():
The notice means
$type['fields']is not an array, but I tried to analize what could be causing this attribute to be undefined and I couldn't.It comes from content_types(), and that one gets it from
$info = _content_type_info();. If$info['content types']is not set, then $type['fields'] should be an empty array (no notice should be generated in this case). If$info['content types']is set, it comes either from a) content cache, o b) built. And here it is hard to see what could be causing malfunction without further debugging.I would try to print_r() structures here and there and then see where the problem is.
Hard to tell...
Comment #10
agerson commentedSame error foe me in 2.2
warning: Invalid argument supplied for foreach() in /Library/WebServer/Documents/drupal/sites/all/modules/cck/content.module on line 1278.
Comment #11
agerson commentedprint_r($type['fields']); prints:
"Array ( )"
echo $type_name; prints:
"page"
Comment #12
markus_petrux commentedOk, this is a dup of #319042: foreach() on empty array
Please, read the whole issue. Same error and all cases ended up being caused by something wrong not related to CCK. Probably, the node type assigned to the node is not there or something similar.