As described in #541768: Call to undefined function _content_is_empty(), Content Profile's User registration module produces the error _content_is_empty() when using multigroup in a Content Profile Type, and I solved it replacing:

node_validate($node);

with

node_validate($node, $form);

content_profile_registration.module, line 207.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

skybow’s picture

subscribe...

I tried the patch – however not with the latest (and greatest) CCK3 branch.

Using it results in having no code errors anymore.
However, I have a required field within the multigroup and now I get something like that: RequiredField is empty.
I haven't checked yet. if it works without required fields.

skybow’s picture

FileSize
1.59 KB

Hi everybody,

as I mentioned in my previous post, I was not able to validate required field residing inside a multigroup of a content_profile node type. I managed to debug the problem and even find a solution:

.  $form += array('#field_info' => array());
.  $form['#field_info'] += $node_form['#field_info'];
+  $form += array('#after_build' => array());
+  foreach ($node_form['#after_build'] as $key) {
+    if (!in_array($key, $form['#after_build'])) {
+      array_unshift($form['#after_build'], $key);
+    }
.  }
.  $form += $form_add;

The main problem, why the validation of required fields in multigroups doesn't work, is because the content profile's $node_form['#after_build'] values are not copied by the following line:

  $form += $form_add;

Doing it like the $node_form['#field_info'] in the sample also didn't work, because it won't replace the values properly. This is why I added the lines with the +.

However there is one more tweak:

.    // Copy over any fieldgroups
.    $keys = array_keys($node_form);
.    foreach ($keys as $key) {
.      if (stristr($key, 'group_')) {
.        $form_add[$key] = $node_form[$key];
+      } else if ($key == '#multigroups') {
+        $form_add[$key] = $node_form[$key];
.      }
.    }

I also made sure, that the '#multigroup'

items will be copied along with the group items.
Note, that all 'groups_' and '#multigroups' will be copied regardless of the user registration settings that specify which fields to hide, but this is something I can live with.

HTH

skybow’s picture

FileSize
1.73 KB

Hi there,

here is another patch (which replaces the previous) that fixes an issue with the latest (greatest) CCK3 as of 11/5/09.
It simply is the same thing that Cristhian did on node_validate two lines below on content_validate .

BTW: both patches were made against DRUPAL-6--1-0-BETA4

Cheers

gsvitak’s picture

I had the same issue as described above. I applied the patch and everything works great for existing users updating the node associated with their user account.

However, if if a user creates a new account with a multigroup, I receive the following error message

warning: array_keys() [function.array-keys]: The first argument should be an array in /modules/cck/content.module on line 926.

Any suggestions on how to resolve the bug?

Thanks
G

Bilmar’s picture

subscribing

mautumn’s picture

Version: 6.x-1.0-beta4 » 6.x-1.x-dev

I'm not entirely sure about this, but I was getting the same issue as #4 - when a user creates/registers a new account - which I wasn't getting until recently. The problem manifested itself during a user registration process which includes the Location module (I presume this uses Multi-group?).

Log 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.

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. This may shed some light...

MissyM’s picture

I wanted to also note that I am having a related problem where multiple instances of the mulitgroup do not show up on the profile page.

misanthropisht’s picture

subscribing

mautumn’s picture

Priority: Normal » Critical

I have wasted another 2 days on this. 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...

okeedoak’s picture

subscribing

squeakyferret_sf’s picture

subscribing

delapohl’s picture

subscribing

dpalmer’s picture

subscribing

fago’s picture

Priority: Critical » Normal
Status: Active » Needs work

Please make sure to obey the coding style ( } else ). Also node_validate($node, $form); is already in there, so I guess it needs a re-roll too.

skybow’s picture

since I posted a patch: I'm not sure what you mean? Could you please be a bit more verbose on what should be changed?

fago’s picture

ok

+ } else if ($key == '#multigroups') {

This line violates the coding style, because the closing } should be on its own line.

>node_validate($node, $form);
This is already in the latest dev version, so the patch needs to be re-rolled.

Also can we can get a comment above the #after_build stuff? What's that for!? Also does the code something different than array_merge() does? If not, we should use it.
>$form += array('#after_build' => array());

skybow’s picture

Thanks for the info, but please note: although I'd call myself an experienced C++ programmer (which is why I somehow tracked down the problem), I'm neither a full time PHP programmer nor a full time Drupal developer, so I'm still not really familiar with an awful lot of what can be done. I was working on some site and I wanted to get around the problem, nothing more.

Now to your "complaints":

I will keep that in mind with the braces.

node_validate(): As I mentioned in comment #3, I patched against DRUPAL-6--1-0-BETA4 and not HEAD. The reason for this was, that I wanted to keep with the sort of stable BETA4. This is probably why you got complaints when applying the patch.
Since this issue was about problems with CCK3, I want to mention that I wrote a comment about the node_validate() thing in #541768: Call to undefined function _content_is_empty() comment #10 which I consider a bug in CCK3, for which markus_petrux did not reply yet.

Admittedly I did not comment things within the code itself. However, I wrote some comments about what and why I did it in comment #1 and in comment #2.

I guess you probably just wanted to take over the patch with HEAD. I am willing to work out a patch against HEAD and test it with my local copy of the site already running. However I'd appreciate a little help on the array_merge issue and why things don't get copied in content_profile_registration.module 1.1.2.36 at line 160.

dipen chaudhary’s picture

Status: Needs work » Needs review
FileSize
2.53 KB

I was facing problem in which multigroup was showing up on reg form even though I was hiding all the fields of a multigroup (Maybe there should be a separate issue queue) so I fixed that and things are working as expected, Also I checked with this issue in which you get error for content_empty function, I am not getting that error on mild testing but since its not my requirement to show multigroup fields of profile on reg form so I havent tested much.

Couple of points:

1> I am manually unsetting #pre_render and #after_build as after removing all multigroups from reg form u dont need them and it sets a warning which should be fixed from cck's end.

2> Also people complained that the solution in issue #705486: CCK3 and Content Profile module (new registrations) doesnt really fix the issue but instead supress the warning, where as in my testing I found out that data is indeed saved. Please test for yourself.

3> Patch file is a git patch file.

Please let me know how it works for you.

dipen chaudhary’s picture

As per my testing it should sort out all issues of cck3 and content profile registration form. But there is one point I forgot to make:

If any field from a multigroup is selected to appear on user reg form then the whole multigroup shows on reg form, which sounds right to me? For example I have a work experience multigroup with various fields and If I choose "Job Title" to appear on reg form (not hide) then the whole work experience group shows on reg form, which makes sense to my use case.

dipen chaudhary’s picture

Ooops my patch is against the stable version 6.x-1.0, I will follow up with a patch against the dev version.

drupaledmonk’s picture

Dipen,
Can you share the patch against the latest 6.x-3.x-dev.

kbk’s picture

Title: Compatibility with CCK3 (multigroup) » Validate Multigroup (CCK3) Fields on User Registration Form
Status: Needs review » Needs work

@Dipen, your patch is supposed to hide multi-group fields from the User Registration form when content profile is configured to do so, correct? If so, you should really move your patch and comments to a new issue because it is confusing to have patches for two different problems on the same thread. Of course, another option would be to merge patches #3 & #18.

I have altered the title to make it more specific to the original poster's intent. If someone merges #3 and #18 it would make sense to revert the title.

DeFr’s picture

Status: Needs work » Needs review
FileSize
1.02 KB

Ok, let's get back at the fundamental of this issue, and move related discussions either to separate issues. Patch in #3 seems basically in the right track, but it also incorporates the node_validate fix that went into #689442: content_profile_registration_user_register_validate() doesn't pass the form array and the re-association of the #after_build that belongs in #826126: Add in #after_build callbacks to $form. Which means that we're down to the patch attached for fixing the original Fatal error mentionned in the OP.

The problem got fixed in #689442: content_profile_registration_user_register_validate() doesn't pass the form array when you don't check the "hide other non required fields" , because we're then hitting the node_validate code path, which then passes the form to CCK. When "hide other non required fields" is checked though, we're still calling content_validate directly without a form, which makes CCK 3 crashes because it expects to find the information it needs about the fields in $form['#field_info'].

To reproduce the issue easily: install both Content Profile 6.x-1.x-dev and CCK 3 alpha3, add an unlimited required nodereference field to your content profile node type, check the "Hide other non required fields" in the content type "Content profile" settings, and try to register. You should get a WSOD.

christianchristensen’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
1.02 KB

#23 +1 RTBC

Had the exact same issue with registration on CCK3 (6.x-3.0-alpha3) - this clears the fatal.

Note: re-rolled to work with `patch -p0` for `drush make`

fago’s picture

Status: Reviewed & tested by the community » Fixed

thanks, committed.

Status: Fixed » Closed (fixed)

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