If a user creates/registers a new account with a multigroup in the content profile page, they receive the following error messages :-

Invalid argument supplied for foreach() in /<my-site-path>/modules/cck/content.module on line 926.

and :-

array_keys() [<a href='function.array-keys'>function.array-keys</a>]: The first argument should be an array in /<my-site-path>/modules/cck/content.module on line 926.

I am using content_profile-6-1.x-1.x-dev (as of 13th Jan 2010).

Reading this (and many other!) articles, and putting 2 and 2 together, I realised I recently upgraded CCK to cck-6.x-3.x-dev.tar.gz on Dec 29th. I rolled back to cck-6.x-2.6.tar and the problem went away.

It seems that CCK Multigroup cck-6.x-3.x-dev.tar.gz does not work with content profile during a new user registration initiated by the user. I have about 5 different versions of 6.x.3 (different dated versions up to and including to 26th January 2010 - the latest dev I can find) and none of them work. Only when I use a 6.x.2x branch - where multi-groups are not a feature - is all the data captured on the profile page that was entered during the registration process.

It seems to be to do with the user not having a record at the point of registration, because the multi-group data capture works for registered users. Maybe multi-group records are stored in a temporary table or in memory - keyed on uid - which could be undefined during registration...?

This could be such a good module...

BTW the whole confusion about official releases, D7, etc. is doing you a great dis-service... For what its worth, my advice is to get D6 CCK3 working asap, and let D7 come when its ready. I, for one, don't see myself upgrading to D7 for at least a year, and I'm sure the vast majority of others, with stable live websites, won't be rushing into it either...

CommentFileSizeAuthor
#8 content.module.patch476 byteslegion80
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

squeakyferret_sf’s picture

I think I'm experiencing something similar. When using the content profile module, if I don't allow creation of content profile nodes during account creation, everything works fine. (Although this means that users or admins must explicitly create these content profiles after the fact.) If I check "Use on administrative user creation form" in the content type (so that the content profile node is generated and populated during account creation), I get this error:

Fatal error: Call to undefined function _content_is_empty() in /Users/Shared/cultcube2.dev/sites/all/modules/cck/content.module on line 935

I'm using the 6.x-1.0-beta4 version of content profile, and the 6.x-3.x-dev version of CCK.

Not sure where to go from here - can't imagine getting my current project done without using multigroups, but neither can I imagine not using my content profile type on the user creation form. Dilemma.

gsvitak’s picture

Agreed I cannot get my project completed without multigroups and content profile.. I would be willing to sponsor the patch since I do not have time to find the bug myself.

gsvitak’s picture

I looked at the code for a quick second and it appears the block of code that is causing the problem is intended to be used to handle the deletions of rows. It assumes there is already data in the array/records, which would explain why the code works on save for existing content profile nodes.

I will spend some time later tonight debugging and hopefully will find the issue.. I can share the code if I find the solution.

G

legion80’s picture

subscribing

OliverColeman’s picture

As a work around until this gets fixed properly this seems to work:

Add the following lines to the beginning of function content_set_empty in cck/content.module (around line 923):

function content_set_empty($field, $items) {
if (!isset($field['columns']))
return NULL;

// Prepare an empty item.
$empty = array();
foreach (array_keys($field['columns']) as $column) {

(the first line and last 3 lines are for context).

This dispatches with the error messages when adding a new user and doesn't seem to have bad side effects (ie the hidden fields can be updated properly at a later date).

I'm guessing this is related to #442312: warning: array_key_exists() [function.array-key-exists] when creating content with CCK Date fields.

gsvitak’s picture

Hi @OliverColeman

Thank you for the work around. You are a life saver..

Could you please post the entire function as I am not sure my version matches up to your build. I am using the latest cck-3.0-dev

Thanks
G

gsvitak’s picture

This change did work for me.. thank you but could you please still post the entire function..

Thanks
G

legion80’s picture

Status: Active » Needs review
FileSize
476 bytes

here's a patch based on #5

OliverColeman’s picture

@gsvitak:

function content_set_empty($field, $items) {
  if (!isset($field['columns']))
    return null;
    
  // Prepare an empty item.
  $empty = array();
  foreach (array_keys($field['columns']) as $column) {
    $empty[$column] = NULL;
  }

  // Filter out items flagged for removal.
  $filtered = array();
  $function = $field['module'] .'_content_is_empty';
  foreach ((array) $items as $delta => $item) {
    if (empty($item['_remove'])) {
      $filtered[] = ($function($item, $field) ? $empty : $item);
    }
  }

  // Make sure we store the right number of 'empty' values.
  $pad = $field['multiple'] > 1 ? $field['multiple'] : 1;
  $filtered = array_pad($filtered, $pad, $empty);

  return $filtered;
}

Like I said, I think this is probably a work around rather than a proper fix (I'm guessing the content_set_empty function probably shouldn't be called at all).

gsvitak’s picture

Thanks that worked!!!!!

delapohl’s picture

This does suppress the errors, although as described in the original post, any profile data entered during registration is not stored (as is also the case without the patch). All profile data in my tests are multigroup fields.

OliverColeman’s picture

Oh, dang, I thought the bug only occurred for profile fields that were hidden, and that the work-around would only affect those. Delapohl: can you confirm that non-hidden fields also don't get saved?

robby.smith’s picture

subscribing

Equ’s picture

any progress on this?

dipen chaudhary’s picture

Shouldn't this issue be filed in the content profile module issue queue? I am not sure where lies the problem but I think Content module would be better equipped to sort this out, coz multi groups work fine its just on user reg when used with content profile it fails.
Not sure, hence not changing the project.

dipen chaudhary’s picture

Issue tags: +CCK Multigroup

Adding issue tag.

dipen chaudhary’s picture

Try using the patch I posted here - http://drupal.org/node/621346#comment-2971688 see if it works for you. Let me know if it doesn't.

KarenS’s picture

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

Can anyone reproduce this issue using the latest code (after the nested fieldgroup patch went in)? I cannot reproduce any problem.

If it can be reproduced, I need exact information on how to reproduce -- exactly how the profile and its fields were configured.

KarenS’s picture

Status: Postponed (maintainer needs more info) » Fixed

OK, it looks like if you use multigroups, Content Profile does not hide the field because it is trying to unset the wrong value, so there is no error but it isn't working right. If you use a normal fieldgroup you get might an error because Content Profile is unsetting a value that ought to be there. Except that I see no error in that case.

Content Profile needs a patch to hide a multigroup value correctly. And I suspect it should not unset() the value but instead do #access = FALSE so that the field still exists.

I don't think there's any CCK bug here though.

Status: Fixed » Closed (fixed)
Issue tags: -CCK Multigroup

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