Drupal 6.14, acquia_prosper theme, skinr module enabled.

I'm using the Advanced Profile Kit -- and get this error when editing the panel (pane settings). Seems there is no "formatter" available in the drop-down list for this CCK text field? I'm unable to change the heading of the pane as a result and get the message "An illegal choice has been detected. Please contact the site administrator."

CommentFileSizeAuthor
#11 content_panels-589306-11.patch997 bytesmarkus_petrux
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

markus_petrux’s picture

Category: bug » support

It looks like the information stored by CCK related to this field has been somehow corrupted.

Make sure the module that implements the field is enabled.

I would suggest going to the Manage fields page of the corresponding content type, then edit the field settings and save. That should rebuild this data. Also, visit the "Display fields" page and repeat the operation. Make sure that field shows up in both pages.

BTW, the file content_field.inc should be located in cck/includes/panels/content_types, not in cck/includes/panels. If it is not a copy/paste issue while opening this request, then it seems your CCK installation is not correct.

schuster211’s picture

Version: 6.x-2.x-dev » 6.x-2.5

I may have truncated the warning message when pasting: here is the error:

warning: Invalid argument supplied for foreach() in /home/hoursch5/public_html/pride/sites/all/modules/cck/includes/panels/content_types/content_field.inc on line 166.

Thanks for looking at this issue. I tried your suggestions -- the CCK text module that implements this field is enabled. I took the steps you prescribed in "Manage Fields" and "Display Fields". The panel editing still gives the same warning. I also disabled all of CCK, deleted the module (but did not uninstall) unzipped a fresh copy and re-enabled CCK (back to 6.x-2.5 this time) to see if that was the bugaboo. Ran database update ... took a look in the database files themselves to see if there was anything wildly amiss (that the uninformed eye could spot anyway.)

These field were created as part of the Advanced Profile Kit install process using "import content" feature. Dunno if that's a clue. Still have the problem. Thank you again for your support.

markus_petrux’s picture

Status: Active » Postponed (maintainer needs more info)

Let's see. Line 166 in content_field.inc is the foreach loop in the following snippet.

  // Get all the information about our field.
  $field = content_fields($field_name);

  // Get information about all the field types on the site.
  $field_types = _content_field_types();

  // Get the information about the type that our field is.
  $type_info = $field_types[$field['type']];

  // Put the possible formatters for our type into an array.
  $options = array();
  foreach ($type_info['formatters'] as $formatter_name => $formatter) {
    $options[$formatter_name] = $formatter['label'];
  }

If $type_info['formatters'] is not an array, it is probably because:

a) $field = content_fields($field_name); returns data that is not correct.
b) $field_types = _content_field_types(); does not contain information about the field type.

So we need to see what these functions return. We can do this adding watchdog statemets as follows:

  $field = content_fields($field_name);
  watchdog('debug', '$field: '. var_export($field, TRUE), array(), WATCHDOG_DEBUG);
  $type_info = $field_types[$field['type']];
  watchdog('debug', '$type_info: '. var_export($type_info, TRUE), array(), WATCHDOG_DEBUG);

Then, please repeat the operation in panels that generates the error, then visit the Recent log entries report and copy/paste the results here.

schuster211’s picture

Ok. So I edited the content_field.inc script per your instruction (I think).

// Get all the information about our field.
  $field = content_fields($field_name);
  watchdog('debug', '$field: '. var_export($field, TRUE), array(), WATCHDOG_DEBUG);

  // Get information about all the field types on the site.
  $field_types = _content_field_types();

  // Get the information about the type that our field is.
  $type_info = $field_types[$field['type']];
  watchdog('debug', '$type_info: '. var_export($type_info, TRUE), array(), WATCHDOG_DEBUG);

  // Put the possible formatters for our type into an array.
  $options = array();
  foreach ($type_info['formatters'] as $formatter_name => $formatter) {
    $options[$formatter_name] = $formatter['label'];
  }

And looked in the log file after attempting the same operation as before.

Here's what I found:

Type debug
Date Monday, September 28, 2009 - 8:12am
User webmaster
Location http://www.foo.com/panels/ajax/configure/panel_context%3Auser_view%3Ause...
Referrer http://www.foo.com/admin/build/pages/nojs/operation/user_view/handlers/u...
Message $field: NULL
Severity debug

and

Details
Type debug
Date Monday, September 28, 2009 - 8:12am
User webmaster
Location http://www.foo.com/panels/ajax/configure/panel_context%3Auser_view%3Ause...
Referrer http://www.foo.com/admin/build/pages/nojs/operation/user_view/handlers/u...
Message $type_info: NULL
Severity debug

Plus

Type debug
Date Monday, September 28, 2009 - 8:12am
User webmaster
Location http://www.foo.com/panels/ajax/configure/panel_context%3Auser_view%3Ause...
Referrer http://www.foo.com/admin/build/pages/nojs/operation/user_view/handlers/u...
Message $field: NULL
Severity debug

and

Type debug
Date Monday, September 28, 2009 - 8:12am
User webmaster
Location http://www.foo.com/panels/ajax/configure/panel_context%3Auser_view%3Ause...
Referrer http://www.foo.com/admin/build/pages/nojs/operation/user_view/handlers/u...
Message $type_info: NULL
Severity debug

So it seems that NULL is stored where something else should be -- but why I wonder?

markus_petrux’s picture

It could be because $field_name does not containt a valid field name. We could see this using the same method as above:

  $field_name = $form_state['subtype_name'];
  watchdog('debug', '$field_name: '. var_export($field_name, TRUE), array(), WATCHDOG_DEBUG);

The value of $field_name should look something like 'field_xxx'.

Regarless of the value of $field_name there seems to be something wrong in the panel. The list of fields available for the panel is generated using content_types() and _content_field_types() in function content_content_field_content_type_content_types() and those function retrive the data from the same place as the code we're looking at now. so if there's data when the list of field is passed to panels, then I do not understand why this data is not available from the settings form of the ctools content type.

This is really strange, because CCK panels integration seems to work elsewher, so I'm not sure how to proceed from here.

Maybe you need to run update.php? clear caches?

schuster211’s picture

The field name may be the problem. Looks a bit funny with the 'uprofile:' bit appended to it.

Details
Type debug
Date Monday, September 28, 2009 - 9:33am
User webmaster
Location http://www.foofoo.com/panels/ajax/configure/panel_context%3Auser_view%3A...
Referrer http://www.foofoo.com/admin/build/pages/nojs/operation/user_view/handler...
Message $field_name: 'uprofile:field_about_me'

markus_petrux’s picture

hmm... so it seems that you were using an old version of CCK Panels integration. One that was using the content type name and field name to key the ctools content types. This approach was not really accurate because fields can be shared between several content types, and so it was changed. Here's the issue:

#505278: Panels 3 and multiple node type fields.

Since there were issues with the old name, merlinofchaos suggested a patch that we applied to content_field.inc (see latest patch in that issue). However, it seems that workaround only fixes the ctools content type names during render. But here you're trying to edit the field settings, and maybe that conversion hack is not applied in this case.

So I would suggest removing the field from the panel, and then added back. The new version of the field will come with the new name, and that should fix this issue, hopefully.

markus_petrux’s picture

Status: Postponed (maintainer needs more info) » Needs review

hmm... looking back at the fixes we made for backward compatibility, it seems we did nothing for the settings form. Here's a mini-patch that could possibly fix this:

   // Extract the field name from the panels content type subtype.
   $field_name = $form_state['subtype_name'];
+
+  // Previous versions of CCK included the content type as part of the subtype.
+  // This allows those to continue to sort of work.
+  if (strpos($field_name, ':') !== FALSE) {
+    list($content_type, $field_name) = explode(':', $field_name, 2);
+  }

   // Get all the information about our field.
   $field = content_fields($field_name);
markus_petrux’s picture

Title: warning: Invalid argument supplied for foreach() in path/to/sites/all/modules/cck/includes/panels/content_field.inc on line 166 » warning: Invalid argument supplied for foreach() in includes/panels/content_types/content_field.inc on line 166
Category: support » bug
dddave’s picture

Where do I have to put this code to test it? What needs to be replaced?

markus_petrux’s picture

FileSize
997 bytes

Patch for CCK2 attached.

dddave’s picture

I can confirm that this fixes the problems with APK. No more error message and now the "Field Formatter" field has an entry and also a dropdown. Hurray!

Anything else that needs to be tested?

markus_petrux’s picture

Status: Needs review » Fixed

Ok, thanks for the feedback. I have committed this patch to CCK2 and CCK3.

Hopefully this fixes all issues related to that change in the names of exposed CTools content types related to CCK fields.

However, it would still be nice if the new names where generated for the APK default panel. Related issue: #589518: Remove and re-add CCK fields on variant

venusrising’s picture

This really screwed up my site too. I spent hours manually disabling modules via Phpmyadmin and now my custom profile I created is missing fileds I added that were grouped together. Does anyone have an idea how to fix this. I have read the above post but they seem just a bit different.

venusrising’s picture

Status: Fixed » Active

I built my own profile and this is I now have missing fields etc.

markus_petrux’s picture

Status: Active » Fixed

@venusrising: If the patch in #11 does not fix your issue, then please open a separate report with as much information as possible to reproduce the problem.

schuster211’s picture

This worked for me. Thanks! Brilliant work!

Status: Fixed » Closed (fixed)

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