Module Error for some content types but not for others The Error


  warning: array_keys() [function.array-keys]: The first argument should be an array in /home/vermontbiz/webapps/vermontbiz/modules/int_meta/int_meta_cck.module on line 39.
  warning: Invalid argument supplied for foreach() in /home/vermontbiz/webapps/vermontbiz/modules/int_meta/int_meta_cck.module on line 39. 


The Code

function function int_meta_cck_int_meta($op, &amp;$arg) {
  switch ($op) {
    case 'load': {
      if (!empty($arg-&gt;int_meta)) {
        $supported = int_meta_cck_supported($arg-&gt;type);
        foreach ($arg-&gt;int_meta as $key =&gt; $tag) {
          if (in_array($tag-&gt;field, $supported)) {
            $parts = explode('.', $tag-&gt;field);
            if (isset($arg-&gt;{$parts[0]})) {
             foreach ($arg-&gt;{$parts[0]} as $tmp) {
               $arg-&gt;int_meta[$key]-&gt;values[] = $tmp[$parts[1]];
              }
            }
          }
        }
      }
    } 
    break;

    case 'fields': {
      return int_meta_cck_supported($arg);
    }
    break;
  }
}

function int_meta_cck_supported($arg) {
  $fields = array();
  if (!empty($arg)) {
    $type = content_types($arg);
    if (!empty($type)) {
      foreach ($type['fields'] as $name =&gt; $info) {

      //**Error below takes place in the line below but doesn't effect all content**

        foreach (array_keys($info['widget']['default_value'][0]) as $col) {
          $fields[] = $name . '.' . $col;
        }
      }
    }
  } 
return $fields; }


My question is why does the line give an error to some content types but not others?

The two content types.
You're making an assumption and that is that

$info['widget']['default_value'][0]


Will always be an array. My guess is that for some fields (depending on configuration) that $info['widget']['default_value'][0] will be either NULL, FALSE or a scalar value.