I get the following on a node generated in calendar & views (date-calendar) when event is more than one day:
"Invalid argument supplied for foreach() i /home/xxxx/public_html/modules/cck/theme/content-field.tpl.php"

Comments

lars toomre’s picture

I was getting the same problem about "Invalid argument supplied for foreach() i /home/xxxx/public_html/modules/cck/theme/content-field.tpl.php" earlier today. In preparation to upgrade to Drupal 7 (now that it is officially released), yesterday I started a long put-off upgrade to my websites including server, Drupal and other custom software. This thus far has included upgrading to Ubuntu 10.4, upgrading to PHP 5.3, upgrading to Drupal 6.20 and upgrading a number of modules including CCK. Yes, I know it is many changes all at once, but it all needs to get done...

As expected, there have been a number of PHP 5.3 issues tied to the pass variables by reference vis-a-vis by value issue. Some of those have been corrected. Others still need to be addressed. I originally thought the above issue was part of the variable by reference group of errors. However, it turns out to be a problem that has been introduced by version 6.x-2.9 of the module.

Reverting to 6.x-2.8 has caused all of my errors around this error to disappear. I hope this helps in resolving this particular issue. I am off to tackle other errors I am witnessing from the upgrades.

Cheers!!

hawkdrupal’s picture

Same problem, massive errors with 2.9, rolling back to 2.8 eliminated them.

Hans Lodder’s picture

Subscribe. Problem in line 35. Result: No image in blog.

Re-installing cck 2.8 solves the problem.

tbm13’s picture

Same here.

jtjones23’s picture

Subscribe

jenifertucker’s picture

Same thing just happened to me.

Invalid argument supplied for foreach() in .../modules/cck-6.x-2.9/theme/content-field.tpl.php on line 35.

Updated the module then went to work on Calendar when I noticed the error.

Also rolled back to earlier version as a quick fix for now as has worked for a number of other druplers.

Installation:

Drupal 6.20
Database PostgreSQL

boobaa’s picture

Getting the same error (internal reference #661), thus rolling back to 2.8 (which seems to work around the problem for the time being) and subscribing, though I'm not really sure it's really caused by the Views integration or something else.

frosty29’s picture

Title: Invalid argument supplied for foreach() in cck/theme/content-field.tpl.php » Invalid argument supplied for foreach() i /home/xxxx/public_html/modules/cck/theme/content-field.tpl.php

Same message here on two sites (Drupal 6.20), but seems Ok on another. Rolling back to CCK 2.8.

There's lots of these on the web! Not all from this release, surely?
http://www.google.com/search?q=Invalid+argument+supplied+for+foreach%28%...

frosty29’s picture

Title: Invalid argument supplied for foreach() i /home/xxxx/public_html/modules/cck/theme/content-field.tpl.php » Invalid argument supplied for foreach() in cck/theme/content-field.tpl.php

removed part path in title to assist search

yched’s picture

Title: Invalid argument supplied for foreach() i /home/xxxx/public_html/modules/cck/theme/content-field.tpl.php » Invalid argument supplied for foreach() in cck/theme/content-field.tpl.php

My guess is that those errors are caused by a stale cache registry.
#728472: Misnamed preprocessor functions renamed the theme preprocessor function for the content-field.tpl.php template, which needs a cache clear.
I should have included a dummy update function just to let update.php automatically flush the caches. Stupid. I'm still pondering whether this deserves rolling a 6.10 release just for that.

Meanwhile, simply go at 'admin/settings/performance' and hit the 'Clear cached data' button,
or run 'drush cc all' (if using drush).

iantresman’s picture

>simply go at 'admin/settings/performance' and hit the 'Clear cached data' button,

Worked for me. Thanks!

And it looks like I wouldn't have needed to clear the cache, if I'd remembered to do the database update at /update.php !

frosty29’s picture

Indeed it does seem to work after clearing cache. And that explains the issue I had - the first site I updated (which was fine, but very simple CCK usage) I would have run update.php to see if it was needed. It did nothing - so I didn't bother to run it on the next site, which consequently played up, I didn't think of this difference at the time of the issue.
So - maybe I will have to review my practises and run update regardless on every module change? I must say I don't like clearing caches if I don't have to, however.

Tino’s picture

Same problem here.
Running update after upgrade didn't do the trick.

Upgraded to 6.x-2.9 yesterday and today I noticed a lot of these errors in the logs.
I also got complaints from customers that certain content (CCK) was not displayed anymore...

So glad I found this post! Indeed, after clearing cache, it all worked again.

Maybe this hint should be mentioned in the release notes of 6.x-2.9...
Thanks!

yched’s picture

Status: Active » Fixed

Right, updated the release note.

Let's close this issue. Thanks to everyone who reported back, and sorry for the trouble.

jenifertucker’s picture

Status: Fixed » Needs review

#6 is my previous posting.

I did clear the cache and ran update after upgrading CCK but I still get the error:

warning: Invalid argument supplied for foreach() in .../modules/cck-6.x-2.9/theme/content-field.tpl.php on line 35.

Therefore haven't upgraded to 6.x-2.9 as this is still an issue for me.

benkewell’s picture

Having the same issue on my website.
After doing a few test, it seems to be template_preprocess_content_field not being called after update to 6.x-2.9

Don't know why clearing cache on "admin/settings/performance" don't work,
but go to "admin/build/modules" and save the form again do the trick for me.

arua13l’s picture

Cleared cache, it worked for me. Thank you!

yched’s picture

@JeniferTucker : it seems you're the only one reporting that now - dare I ask that you give it another shot ?

stallberg’s picture

I had the same problems as in #15. A mulivalue CCK-Field for fileupload produced the trouble while other single fields were no problem. Clearing all caches didn't help at all. I had to downgrade CCK and ended up importing the whole backup of the database. (MySQL-Datenbank 5.0.91, PHP 5.2.17)

On my local environement (MySQL-Datenbank 5.1.37, PHP 5.3.0) I had the similar problems at first, but in the end (I played in a backup of the datebase, so I don't really know what helped) there seems to be no more problems.

jim kirkpatrick’s picture

It appears the issue goes away for me when clearing the cache, too <SNIP - was talking rubbish here!>

patrickroma’s picture

I got the same problem on 6.x-2.8... Clearing cache doesn't help at all... My Drupal Core is 6.20...

Edit:

I agree with #8, there are really a lot of these errors out there!

jim kirkpatrick’s picture

It might be worth summarising my <snip> from #20 in case is sheds any light.

We had two code bases pointing at the same database via different subdomains... That's bad, I know and now corrected - but it was a hangover from development. Anyway, it appeared whichever site I cleared the cache on got no errors, but the other one got them. E.g. Clear on www.example.com, then dev.example.com got them. And vice-versa.

So could it be that the people getting this have their sites accessible by www and without, or by another subdomian? Why should the domain matter in rebuilding caches for CCK? If it does, that's gotta be a bug.

Or maybe this is a red herring, just throwing it in the mix...

cafuego’s picture

Clearing the cache made the problem go away for me.

What also seemed to work (without flushing the cache) was editing line 28 of content-field.tpl.php like so:

--- a/cck/theme/content-field.tpl.php	2011-02-11 13:29:52.000000000 +1000
+++ b/cck/theme/content-field.tpl.php	2011-02-11 13:33:36.000000000 +1000
@@ -25,7 +25,7 @@
  * @see template_preprocess_content_field()
  */
 ?>
-<?php if (!$field_empty) : ?>
+<?php if (!empty($field_empty)) : ?>
 <div class="field field-type-<?php print $field_type_css ?> field-<?php print $field_name_css ?>">
   <?php if ($label_display == 'above') : ?>
     <div class="field-label"><?php print t($label) ?>:&nbsp;</div>
jenifertucker’s picture

Thanks yched ... gave it another shot as asked and no error messages being reported.

Xagarsan’s picture

Cleared cache, it worked for me too. Thank you!

tchurch’s picture

Clearing cache worked for me too.

dmatamales’s picture

I had to clear cache twice in a row to fix the issue. If you're still experiencing this after clearing your cache, it may be worth a shot to clear it out a few times in a row.

tarzadon’s picture

subscribe

Peter Bowey’s picture

At last a real solution!
#23 worked for me!
The usual PHP E notice problem is getting old!
I refuse to write code that needs E notice disabled...