I've recreated this on a fresh install of 5.3, latest CCK (1.6-1).

  1. Create a CCK node type
  2. Create a Node Reference field
  3. Set Node Reference 'display fields' setting to 'Full Node'
  4. Create a node that references other nodes
  5. Delete a referenced node from its node/nid/edit page (NOTE: Do not remove it from the referenced node)
  6. You'll then get the error
  7. Deleted reference node leaves behind its DIV

The only way to fix it is to go back to the node that references and submit it, not exactly ideal...

Screenshot attached.

CommentFileSizeAuthor
394.gif18.47 KBbsuttis

Comments

bsuttis’s picture

I missed a step above, make sure Fieldgroup is enabled and the nodereference field is in a fieldgroup.

Hoping the problem would go away if I simply disabled fieldgroup, taking the nodereference field out of a fieldgroup prevented the error from showing. However, deleting a referenced node still causes the empty div wrapper to show until I resubmit the node holding the nodereference field. Hope that makes sense.

aterchin’s picture

i have a similar issue also, which gives me the error on the frontpage view. happens after creating a fieldgroup, whether i've assigned a field to it or not. i'll tab over on firefox and refresh my frontpage and there's the error.

had field groups for a usernode profile as well as my 'article' content type. still need to mess with it a little more.
seems like such an obvious problem that it would have been found by more than the handful i keep running into around drupal searches (so maybe its my setup somewhere, dont know). just adding my two cents here.

warning: Invalid argument supplied for foreach() in .../sites/all/modules/cck/fieldgroup.module on line 394.

bsuttis’s picture

Bump.

This error really throws a wrench into the workflow. Essentially I can't just delete a referenced node without first removing it from its parent node before deletion without causing the error. Is it possibly a matter of modifying hook_nodeapi to update the parent node on its reference node deletion, or is the issue deeper?

Anonymous’s picture

+1 Tracking

kenorb’s picture

Status: Active » Needs review

I've the same issue.

Followed similar nodes are passed to function fieldgroup_nodeapi() in fieldgroup.module

stdClass Object ( [body] => [readmore] => [content] => Array ( [body] => Array ( [#value] => [#weight] => 0 ) ) )
stdClass Object ( [body] => [readmore] => [content] => Array ( [body] => Array ( [#value] => [#weight] => 0 ) ) )
...

My fix is:

        $visible = FALSE;
	if (is_array($group['fields'])) {
        foreach ($group['fields'] as $field_name => $field) {
          if (isset($node->content[$field_name])) {
            $node->content[$group_name][$field_name] = $node->content[$field_name];
            if ($node->content[$field_name]['#access'] && !empty($node->content[$field_name]['#value'])) {
              $visible = TRUE;
            }
            unset($node->content[$field_name]);
          }
        }
	} // end: if

Instead of:

        $visible = FALSE;
        foreach ($group['fields'] as $field_name => $field) {
          if (isset($node->content[$field_name])) {
            $node->content[$group_name][$field_name] = $node->content[$field_name];
            if ($node->content[$field_name]['#access'] && !empty($node->content[$field_name]['#value'])) {
              $visible = TRUE;
            }
            unset($node->content[$field_name]);
          }
        }
bsuttis’s picture

The above appears to remove the error messages, but my node's are still left with the deleted reference node's div remnants.

emilyf’s picture

Same problem. Subscribing.

artis’s picture

Add me to the list.

njehlen’s picture

subscribing

shooommmm’s picture

Hi everyone,

I have the same problem:

warning: Invalid argument supplied for foreach() in /home/newmill/public_html/sites/all/modules/cck/fieldgroup.module on line 394.

Can someone help ?

Thanks,

Hanly

cwittusen’s picture

I have the same problem as well and it doesn't seem like someone has a solution to it yet?

kshahan’s picture

I also have same problem. Came up when I added advanced profile module. Struggling to find a fix..seems like my website has slowed down as a result.

Kerry
http://www.writingmate.com

ps. I'm searching to see if anyone is interested to work on writingmate as a co-developer. Please contact me if interested.

geek-merlin’s picture

similar problem here

pcs305’s picture

Same problem, Subscribing

quiptime’s picture

I think you can test this node.module hack

Quick fix: http://drupal.org/node/164499#comment-656606

I think that fix the probleme with the error
warning: Invalid argument supplied for foreach() in .../sites/all/modules/cck/fieldgroup.module on line 394.

I had the same problem with drupal 5.7 and many contributed modules.

pcs305’s picture

After applying the fix to node.module, the
warning: Invalid argument supplied for foreach() in .../sites/all/modules/cck/fieldgroup.module on line 394.
still shows up.

I'm tracing back in the log and it's starting to look like Advanced Profile module or Panels2 that caused the start of these messages.
Not 100% on that though.

benansell’s picture

I think I have the same problem; definitely have the same symptoms. I cannot directly trace back the root cause to a deleted referenced node. However, I am experiencing this error message when I get a teaser list of nodes back from Search module working in concert with Taxonomy.

The node type in question does have some node reference fields defined to display within a fieldset when viewed in a teaser list view. They are defined to display within tabs in a 'full view'.

Subscribing ..... Is there an an ETA on having a fix?

If fix isn't any time soon, is there a set of steps that can be taken to get rid of the error messages for the time being until the root cause is addressed?

Thx!

yched’s picture

Status: Needs review » Fixed

Fixed in D5 and D6 branches. We now test if node_load() returned a valid node before attempting to display it.

ariana’s picture

I upgraded to the development snapshot from 3-24-08 and I'm still getting this same error.. the fix didn't seem to work for me. Did anyone else try it??

yched’s picture

Then you need to be more specific about exactly where and when you see the errors. Maybe it's unrelated to the issue in the thread.

bsuttis’s picture

Using the latest dev snapshot, the problem I first posted is fixed from my testing. Thanks much.

pcs305’s picture

Version: 5.x-1.6-1 » 5.x-1.x-dev

After upgrading to the latest dev, the messages seems to be gone! I will give it 24 hours to make sure.
Thanks for the fix yched.

EDIT:
It's been more than 24 Hours now, and the messages are gone. And I had hundreds of them per day!
Thanks for the Fix.

ariana’s picture

Sorry about my lack of specificity..
I get the error only when viewing usernodes. 1 of my usernodes throws no error, but all the rest do, and even that one that wasn't did once.. so I'm thoroughly confused!
One of the children of the usernodes (node profile) has a group set up.

Changing line 394 to: if (!empty($group['fields'])) foreach ($group['fields'] as $field_name => $field) {
gets rid of the error messages, but there are still these red empty divs that are showing as unpublished nodes, in firebug it shows:
div id="node-" class="node node-unpublished"

EgonO’s picture

same problem here. the error displays on the frontpage. using 5.x-1.6-1

subscribed ;)

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

yngens’s picture

I started to have this error since I added usernode as a recommended part of Advanced Profile. I have:

PHP version 5.2.5
MySQL version 5.0.45-community

joehenriod’s picture

Status: Closed (fixed) » Active

I also am getting this error, I have Advanced Profile

jason.fisher’s picture

Experiencing this with 5.7, using cck, nodeprofile, usernode.

moonray’s picture

Same problem which persists after updating to 5.x-1.7 (which purportedly has this fixed).

jrbeeman’s picture

Status: Active » Needs review

This issue is occurring for me, as well, using the 5.x-1.7 release. I was able to get rid of the error messages by wrapping the foreach() on line line 394 of fieldgroup.module with a simple if()... see below for the resulting code block. My only concern is that I don't know the underlying code well enough to know if the issue is deeper than this.

if (count($group['fields'])) {
  foreach ($group['fields'] as $field_name => $field) {
    if (isset($node->content[$field_name])) {
      $node->content[$group_name][$field_name] = $node->content[$field_name];
      if ($node->content[$field_name]['#access'] && !empty($node->content[$field_name]['#value'])) {
        $visible = TRUE;
      }
      unset($node->content[$field_name]);
    }
  }
}
bascostbudde’s picture

subscribing.

My tracing gets me to the point that the nodeapi hook is called with something that is not really a node. Will post back when more info.

[edit] confirmed: when node_view is called with something that is not a node object, the arriving call at fieldgroup_nodeapi chokes.

In my case, this is the result of using too wide a query in a custom module.

oschirok’s picture

subscribe too, having issue with nodeprofile and nodefamily

MGParisi’s picture

testing #30

MGParisi’s picture

Status: Needs review » Closed (duplicate)
reed.richards’s picture

+1

kdavis005’s picture

Subscribe..

m_freeman2004’s picture

Version: 5.x-1.x-dev » 5.x-1.10

Hi. I'm getting the above error on my site, leading to "Page not found" errors on all nodes. Recently upgraded from drupal 5.2 to 5.15 which is when the problem started. Using CCK 5.15-1.10 with Views and Panels2 if that helps. Anyone else getting this issue? Please help... :) M.

Anonymous’s picture

I am also having the same error message and a lot of blank nodes showing up the above fix in #30 gets rid of the error message but there are still lots of blank nodes showing up. The error came up after I upgraded Drupal to 5.17.

Anonymous’s picture

Again that gets rid of the error but I am getting page not found left and right but when I search for the node in phpmyadmin the node and node revision both exist.

mofdi2’s picture

in CCK filedgroup.module

replace
lign 394:
foreach ($group['fields'] as $field_name => $field) {
with:
if (!empty($group['fields'])) foreach ($group['fields'] as $field_name => $field) {

Anonymous’s picture

Subscribing

P.S.:

not using Panels here

pbucalo’s picture

Subscribing