I am getting the following error message:

warning: Invalid argument supplied for foreach() in /home/webadmin/ecotropolis.com/html/drupal/modules/cck/content.module on line 1284.

on my front page, located at http://www.ecotropolis.com/drupal . How can I remove this without rebuilding my whole site?

Thanks,

Amy

Comments

grobemo’s picture

That error arises when the CCK module is expecting an array and finds nothing. Unfortunately, the error doesn't tell you much about which node is causing this. Our only clue at the moment is that it's something that appears on the front page, but not anywhere else.

Do you have any other nodes (besides node 3, the "Links" page) promoted to the front page?

Have you created any blocks that you've added to the front page?

Do you know what you did right before this error appeared? In particular, did you create or edit any content?

ajohnson@gci.net’s picture

Yes, I created a blog entry and made a menu for it. This was promoted to the front page. Then I created a menu item under primary links called Home, and made it point to node. Then I tried to get rid of the name of the person who made the blog entry by just deleting it on the edit page. Right about that time I started getting a statement about the page being unpublished. Then I deleted my blog entry, my home menu, and recreated my home menu.

I also had a GMap page that got deleted right in there, and it was promoted to the front page and activated in the Blocks section. I deleted it prior to deactivating it, which may have been a problem. Any clues?

grobemo’s picture

Nothing in what you said jumps out at me as responsible for the error, assuming that the Block has been deactivated. The deleted GMap page could be connected, but I don't understand exactly why it would do this.

After looking more carefully, I see that the page is trying to load a second, unpublished node, but it doesn't have the NID for it. That's causing the "n/a" on the front page, and I'll bet it's causing the CCK error. Weird.

I'd try deleting or republishing all unpublished content. It couldn't hurt to clear your cache (in admin/settings/performance), just in case.

ajohnson@gci.net’s picture

I tried deleting modules and clearing the cache. I even went so far as to run update.php . I need to move on, so since it is pretty new, I'm thinking of just rebuilding it. I'm reluctant though, because I don't understand the problem.

eddy147’s picture

Having the same problem, but only occurs on local site. Not on test site on a different server.

Deleted all content, generated new, cleared cache, problem still is there.

Looking at the line 1284, it expects $type['fields'], but looking at $type, it looks like it should be $type[$type_name]['fields'].

For instance the blog content type:

array(14) {
  ["blog"]=>
  array(18) {
    ["type"]=>
    string(4) "blog"
    ["name"]=>
    string(10) "Blog entry"
    ["module"]=>
    string(4) "blog"
    ["description"]=>
    string(78) "A <em>blog entry</em> is a single post to an online journal, or <em>blog</em>."
    ["help"]=>
    string(0) ""
    ["has_title"]=>
    string(1) "1"
    ["title_label"]=>
    string(5) "Title"
    ["has_body"]=>
    string(1) "1"
    ["body_label"]=>
    string(4) "Body"
    ["min_word_count"]=>
    string(1) "0"
    ["custom"]=>
    string(1) "0"
    ["modified"]=>
    string(1) "1"
    ["locked"]=>
    string(1) "1"
    ["orig_type"]=>
    string(4) "blog"
    ["url_str"]=>
    string(4) "blog"
    ["fields"]=>
    array(2) {
      ["field_video"]=>
      array(13) 
rolandreichmann’s picture

There is no value in the array for the front page. So the function foreach takes an emty array and get in error/warning.

Easy to change the code ans prevent foreach to work on an emty array.

in "modules/cck/content.module"

change from:

1283 else {
1284 foreach ($type['fields'] as $field) {

to:

1283 else if (count($type['fields']) > 0) {
1284 foreach ($type['fields'] as $field) {

brisbanett’s picture

i changed that line at it worked wala.. i lost so much hair trying to work out what went wrong...

now finally the red message is gone but =

I have

n/a in soft pink show up still
I think there are some comments floating somewhere in the system - how do I solve this my friend? I am a newbie...

eddy147’s picture

trackleft’s picture

link to solution, it isn't on drupal but it does work. This is a solution for the N/A error.

http://www.yald.com/how-to-fix-drupal-na-error

helvetius’s picture

I'd imported node and user data from another drupal site. Turned out that when I fixed the missing node.uid link both the "n/a" item and the foreach() error went away.

So, as per the link above.

The issue is a node record with a uid column for which there is no matching entry in the users table, so, access the back-end database via mysql (or whatever) and check:

select disctinct node.uid from node left join users on node.uid = users.uid where users.uid is null;

If that's not the empty set, then this is your issue.

Two options for curing are 1) if you want to keep the node data, enter a dummy user record with the appropriate uid(s). 2) delete the orphaned node records.

divbox’s picture

I altered the SQL as well to return title and node type to determine easier, for me at least, what nodes were safe to delete and which to assign to another uid. I also removed the distinct from the query to return all the rows affected.

SELECT node.uid, node.title, node.type
FROM node
LEFT JOIN users ON node.uid = users.uid
WHERE users.uid IS NULL 
seansreview.com’s picture

For some reason - and I'll have to investigate - when I installed the public booking module and its dependancies my front page user id changed to 3 instead of 1 (there is no userid 3)

to find it i used phpmysqladmin or your favorite database tool and looked at all nodes that where promoted. I noticed that the one page had a different user id. I updated it back to 1 and voilia.

May not be everybody's solution but the issues above didn't seem to work for me.

Thanks for the hints though. one of these posts made me think to look at the node table.

Thanks,
Sean

markosaurus’s picture

I also got this error because of a changed user_id, but mines was caused by me changing it manually.

I changed my super user id back to 1 and it was hunky-dory again.

nakeddesign’s picture

I was adding some new local menu tasks
/node/node%/schedule
/node/node%/print etc..

I started seeing the error on \cck\content.module on line 1284 after I created a local task to a pre-existing system path:
node/node%

Hope this helps somebody