Currently receiving the following error message:

warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/mysite/public_html/sites/all/modules/autoassignrole/autoassignrole.module on line 461.

Anyone else experiencing this?

Comments

jamesmcd’s picture

Category: support » bug
gidgetk’s picture

I can confirm I am getting the same error

jamesmcd’s picture

StatusFileSize
new67.04 KB

gidgetk This is appearing on my registration pages, is this the same for you?

*Attached screenshot*

51ucars’s picture

same

jamesmcd’s picture

Priority: Normal » Critical

Changing priority to critical as I need this issue resolved for my site to run successfully

I am willing to sponsor fixing this if it speeds up the process of getting it sorted

Many thanks

weizrd’s picture

Status: Active » Patch (to be ported)
YK85’s picture

Status: Patch (to be ported) » Active

Hi,

Shouldn't this issue be marked as a duplicate of #755308: Content profile settings are not saved if that patch fixes this issue instead of marking as 'patch (to be ported)'?

Please help test patch located at #755308: Content profile settings are not saved

Setting back to 'active' for now

cyberswat’s picture

Status: Active » Closed (duplicate)
zeno129’s picture

Status: Closed (duplicate) » Active

I am very sure that the patch mentioned before does not fix the error.
First, because it does not affect the line where the error is. Secondly, I tried it just to be sure.

The real problem lies in that Auto Assign Role is calling the function content_profile_get_settings in Content Profile with an argument (e.g. 'autoassignrole_use') that is not supported:

<?php

/**
 * Returns the content_profiles' settings.
 * @param $type
 *   The content type to return settings for.
 * @param $return
 *   'all' or one of the content_profile_available_settings(),
 *   e.g. user_edit, register or weight.
 */
function content_profile_get_settings($type, $return = 'all') {
  $settings = variable_get('content_profile_'. $type, array());
  $settings += content_profile_settings_info();
  if ($return == 'all') {
    return $settings;
  }
  return $settings[$return];
}

?>

As you can see in the fraction of code above from Content Profile, the only arguments supported are user_edit, register or weight.
I tried changing the argument from 'autoassignrole_use' to 'register' since the error appeared in the register form. That did not fix it, so I eliminated that second parameter because Content Profile already gives a default value to that parameter in its function. Doing this seemed to fix it.

<?php

/**
 * Implementation of hook_form_alter().
 *
 * Integrate with content profile's registration integration
 */
function autoassignrole_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'content_profile_admin_settings') {
    $type = $form_state['type'];
    $result = db_query("SELECT ar.path, ar.rid, r.name FROM {autoassignrole_page} ar INNER JOIN {role} r ON ar.rid = r.rid");
    $options = array();
    while ($r = db_fetch_object($result)) {
      $options[$r->rid] = filter_xss_admin("($r->name) $r->path");
    }
    $form['registration']['autoassignrole_use'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Use on Auto Assign Role paths'),
      '#default_value' => content_profile_get_settings($type),                       //eliminated second argument of 'autoassignrole_use'
      '#options' => $options,
      '#description' => t('The Auto Assign Role module gives you the ability to assign paths a user can register from for a role.  After associating a <a href="@aar">path with a role</a> your selection can  associate this content type with a path.', array('@aar' => url('admin/user/autoassignrole'))),
      '#disabled' => count($options) == 0,
      '#weight' => 3,
    );
    array_unshift($form['#submit'], 'autoassignrole_content_profile_admin_form_submit');
  }
  elseif ($form_id == 'user_register' && module_exists('content_profile_registration')) {
    if (implode('/', arg()) != 'user/register' && $rid = autoassignrole_get_active_path_rid()) {
      // Set the content types which should be shown by the content_profile_registration module
      $form['#content_profile_registration_use_types'] = array();
      foreach (content_profile_get_types('names') as $type => $name) {
        if (in_array($rid, content_profile_get_settings($type))) {                    //eliminated second argument of 'autoassignrole_use'
          $form['#content_profile_registration_use_types'][$type] = $name;
        }
      }
    }
  }
}

?>

I'll try to work on making a patch as soon as I can... or if anyone wants to do it that is fine by me. :)
That way, more people could easily test it and see if it works right.

zeno129’s picture

StatusFileSize
new1.58 KB

Sorry, I forgot to say that the file that I edited was autoassignrole.module
Here is the patch.

zeno129’s picture

Status: Active » Needs review

Updating status.

cledman’s picture

It works for me!
Thanks!

akobashikawa’s picture

Hello. Seem patch in #9 and #10 just mask symptom but not cause.
After applied solved issue http://drupal.org/node/755308 I realize that.
Use patch that appear in http://drupal.org/node/755308 instead.

zeno129’s picture

@akobashikawa - If you read this whole thread, you'll see that the patch you mention did not work for this particular issue.
I downloaded the module after that patch was committed and I still got the error. I even went and double checked that what I downloaded had the line that the patch corrected right.

Having that in mind, I went to the line that the error pointed out and compared the arguments being passed with the valid parameter that the function from the Content Profile module accepts. The REAL problem was that the argument being passed IS NOT a valid option. So, the function was using the default value.

The change that I made was eliminating the wrong argument being passed because it actually DOES NOTHING. This eliminated the error because there were no unnecessary and erroneous arguments being passed. Therefore, I do not think that my patch "masks a symptom".

You are welcome to analyze the error and verify that what I said is correct. Thank you.

[Edited comment to fix typo]

kenorb’s picture

The same issue.

sunny.oxide’s picture

Patch in #10 worked great. Thanks @zeno129.

codeglyph’s picture

Priority: Critical » Normal
Status: Needs review » Patch (to be ported)

works for me. thanks zeno129.

emilyf’s picture

#10 works for me as well. thanks.

zeno129’s picture

You're welcome, guys. Thanks for the feedback! :)
Glad to hear it worked for you too.

cyberswat’s picture

Status: Patch (to be ported) » Fixed
StatusFileSize
new1.62 KB

Thanks for the work on this ... in the future please follow the patch generation documentation off the project pages as it will make it easier to use your code http://drupal.org/node/138844/cvs-instructions/DRUPAL-6--1 ... I went ahead and rerolled this and committed it. Marking as fixed for now ... re-open if necessary. Thanks for the help!

zeno129’s picture

Thank you, I will use it as a reference next time. :)

Status: Fixed » Closed (fixed)

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

fenstrat’s picture

Title: Error message appearing - "warning: in_array() [function.in-array]: Wrong datatype for second argument..." » Auto Assign Role paths is broken
Priority: Normal » Major
Status: Closed (fixed) » Active

The patch in #20 (which is a simple re-roll of the one in #10) is incorrect. It is the cause of a number of bug reports:
#814870: Auto Assign Role - warning: Illegal offset type
#761748: warning: Invalid argument supplied for foreach()
#873380: Auto Assign Role by Path does not work
+ others?

The patch in #20 was made on the assumption (from #9):

The real problem lies in that Auto Assign Role is calling the function content_profile_get_settings in Content Profile with an argument (e.g. 'autoassignrole_use') that is not supported:

This is incorrect. The second parameter to content_profile_get_settings() is an optional array key which will be returned from the $settings array. 'autoassignrole_use' is a perfectly valid key and is the key under which autoassignrole stores the "Use on Auto Assign Role paths" setting.

Most of the confusion around this was introduced in #666288: Introduce static cache which introduced a static cache for autoassigned roles (committed 24th Dec 2009). However it was implemented incorrectly and meant that the 'autoassignrole_use' key returned from content_profile_get_settings() was empty. This was finally fixed in #755308: Content profile settings are not saved which was not committed until 14th May 2010.

Short version: The patch in #20 needs to be rolled back.

fenstrat’s picture

Status: Active » Needs review
StatusFileSize
new1.44 KB

Here's a patch which rolls back #20.

Applied to 6.x-1.x-dev this should fix all issues with "Auto Assign Role paths".

jay_N’s picture

@24: patch works fine for me, thanks!

Demoing this to a client in half an hour so good timing as well! ;)

patcon’s picture

Awesome! thanks for pointing this out in the other threads, fenstrat :)

chris_getdepth’s picture

hey sadly i am still experiencing this issue even though the version of auto assign role module i am using has already had #24 patch applied to lines 448 and 461.

any ideas?

drupal version: 6.19
auto assign role version: 6.x-1.2

ocamp’s picture

anybody got a version of the module with the patch applied that they could upload please?

fenstrat’s picture

@cnp The patch in #24 is to be applied to autoassignrole-6.x-1.x-dev not 6.x-1.2. Can you try again against the dev version.

@ocamp Patching is a pretty straight forward process, and a great skill to have. Have a look at http://drupal.org/patch/apply and see how you go applying #24

Based on feedback from fm_jay, patcon and others from duplicate issues I'd consider this RTBC

pwilson’s picture

I was having this issue, as well as the "Use on Auto Assign Role paths: " setting not saving. It would appear that autoassignrole.module's implementation of hook_content_profile_settings is a bit wonky. Seems to return only an array of the available user roles:

array('values' => array(
0,
1, ...etc
));

The problem is that everywhere else, the content_profile_get_settings call is looking for settings with the key "autoassignrole_use". If I change the hook_content_profile_settings implementation to return array('autoassignrole_use' => false) as a sane default, the form will now save the appropriate value in the appropriate variable, and my form shows up on user registration. I'm hoping the developer will see this and make this fix, hopefully based on any insight I have provided.

fenstrat’s picture

@uncultured autoassignrole.module's implementation of hook_content_profile_settings is perfectly valid. content_profile.module's description of the hook is it "Defines content profile settings and their default value.". The hook simply defines the default values available for aar paths, i.e. make it available for all roles. aar path settings for individual content types are then activated by saving content_profile_set_settings($type, $settings) where $type is the individual content type the aar paths should be enabled for.

Can you try autoassignrole-6.x-1.x-dev and then apply the patch above in #24. This should solve your issues. I'm using this on multiple sites, and 4 other people have reported this solved their issues.

calefilm’s picture

Priority: Major » Minor

UPDATE: Issue Resolved

I got lucky by turning off my localhost acquia drupal control panel and attempted to apply the patch then... I turned off the terminal. Turned it back on again, applied the patch and it works! Thanks for the patch


original issue:
I can't apply the patch. I've installed patches before.. But this doesn't seem to be working for me.

Installed 6.x-1.x-dev
download: autoassignrole-699888-24-fix-role-by-path.patch

Apply it but all i get is no such file or directory

fenstrat’s picture

Priority: Minor » Critical
Status: Needs review » Reviewed & tested by the community

Ok, that's 5 people who have confirmed #24 solves the issue.

This stops "Auto Assign Role paths" from working at all so upping to critical.

ocamp’s picture

It stops what from working?

I applied the patch, the error doesnt display anymore, I create 2 new roles - role a and role b, give them 2 paths, signup/a and signup/b. If a user signs up via signup/a they become role a, if they sign up via signup/b they become role b.

Isnt that what its supposed to do?

whats it not doing?

YK85’s picture

I'm pretty sure what fenstrat is saying is that the patch at #24 has been reviewed and tested by many and therefore needs to be committed asap to fix the issue in hand of "Auto Assign Role paths" not working properly.

cyberswat’s picture

Status: Reviewed & tested by the community » Needs review

Would be great if the automated tests pick up on it and pass it so giving that a go.

pwilson’s picture

@fenstrat Looks like I was applying patch 24 to 6.x-1.2, not 6.x-1.x-dev. Works well now, thanks for the clarification! I have noticed that now when I enable a path I can't set the "Default Registration Page" option to "No". It doesn't appear to actually affect anything as the default registration page appears to be for the first role, which happens to work for my particular case.

maedi’s picture

subscribing

cmcintosh’s picture

Hey guys, First off great module. I have a module out that does about what yours does, but works as far as the paths are concerned. its not as graceful as yours, but thought I would link to it here, so that maybe you can take what I did that got the content_profile + paths thing working and maybe integrated into what your doing here. Let me know if you have any questions.

http://drupal.org/project/custom_registration

cyberswat’s picture

Awesome form ... you've already been pressured on duplicating the modules rather than help by contributing so you take it one step further by using the existing issue queues to advertise?

cmcintosh’s picture

@cyberswat not even, i did not understand where to start with autoassignrole or how to fix it and needed something that worked quickly, so i built it. I would much rather have the functionality I have at custom_registration moved into this module

cyberswat’s picture

http://drupal.org/cvs?commit=414676 per multiple RTBC comments ... apparently test bot is borked

cyberswat’s picture

Status: Needs review » Fixed

@cmcintosh Actually, that is exactly what you've done. #891208: What is the difference between this module, and the existing ones?

cyberswat’s picture

It sounds like this has been resolved completely by the last commit .. thx @cmcintosh for testing. Can anyone else verify the fix? I'd seriously like to see this issue die for good.

fenstrat’s picture

We've been using the committed patch in #24 on a number of sites. So I can verify it fixes the issue. Thanks to every for their efforts.

Can we get a new stable release? "Auto Assign Role paths" is totally broken in 1.2.

@cyberswat I assume you didn't get around to implementing tests for this?

fenstrat’s picture

Status: Fixed » Needs review
StatusFileSize
new1.49 KB

Whoo, somehow the commit in http://drupal.org/cvs?commit=414676 contained 2 php parse errors. This was not in the patch from #24

Attached is the fix.

sammo’s picture

Thanks this works for me

cyberswat’s picture

Status: Needs review » Fixed

http://drupal.org/cvs?commit=417348

@fenstrat Nope ... I don't use this functionality at all so am 100% reliant on the community to provide tests. I would love to not accept patches until they have legitimate tests in them but all I seem to have in these queues are users that reiterate that something is broken and aren't exactly forthcoming with patches. As a result there aren't tests that walk through the content_profile integration.

Thanks for your help.

sammo’s picture

Thanks for fixing. I've done some testing with content_profile and I get this error when visiting a custom registration page

warning: in_array(): Wrong datatype for second argument in /usr/home/mysite/my_html/sites/all/modules/contrib/autoassignrole/autoassignrole.module on line 461.

I didn't get this when applying fenstrat's patch #24 before it was committed

Edit: I've reinstalled the module and applied patch from #46 and this now works.

fenstrat’s picture

Thanks cyberswat. I generally find that patches speak louder than words here on d.o. I'd like to get to tests for content_profile integration, just need more hours in the day!

Any chance of a new stable release? content_profile integration is pretty broken in 1.2.

cyberswat’s picture

@sammo could you please check out the dev branch from cvs and help verify that what is in cvs solves this problem?

@fenstrat I'd be willing to do a stable release if I could get a couple more people to verify that what is in cvs right now is functional.

cyberswat’s picture

Just an FYI ... I just did some spring cleaning on the issue queues so everything that needs to be in place for a release is in cvs ... if a few of you can sign off that everything appears to be working and validate content profile integration I'll go ahead and create the release.

sammo’s picture

@cyberswat - I have disabled autoassignrole downloaded the CVS and then enabled autoassign role again. I've not used CVS before but I ran this which I think is correct, at least the .module file was dated sep 8:

cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -r DRUPAL-6--1 -d autoassignrole contributions/modules/autoassignrole

I've tested registration with content profile via path and via user selection. This worked fine for me. Is there anything else you want me to test?

cyberswat’s picture

@sammo that is so awesome ... thank you very much! I would prefer to get one more person to validate that the current DRUPAL-6--1 branch works for them before rolling a stable release. I'll give it a few more days and see if anyone else helps ... if not I'll run through some tests over the weekend and see if we can't get something released in the next few days.

sammo’s picture

@cyberswat Thanks and no problem, I'll keep running this version and let you know if I have any issues. I'm actively developing a site so hopefully I will notice pretty quickly if there are any bugs.

fenstrat’s picture

I can also confirm 1.x-dev is working fine.

I haven't explicitly tested the functionality of the latest 2 commits: #830314: You can not replace the user register page with a node if a path has been designated as the user register page. or #688934: autoassignrole_get_roles() is broken, however everything seems to be working well.

dadderley’s picture

Had the same problem with the 6.x-1.2 release.
The 1.x-dev release from September 8 seems to have cleared it up.

Status: Fixed » Closed (fixed)

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

ecksley’s picture

Priority: Critical » Normal
Status: Closed (fixed) » Needs work

I am testing the 6.x-1.2 release and am still getting the error noted above:

warning: in_array() [function.in-array]: Wrong datatype for second argument in /path/to/drupal/sites/all/modules/autoassignrole/autoassignrole.module on line 461.

Perhaps this is noted elsewhere, but the module also seems to throw the following error on my Content Profile configuration page (/admin/content/node-type/my-profile-type/profile)

warning: Invalid argument supplied for foreach() in /path/to/drupal/includes/form.inc on line 1213.

Although I try to select the option to "Use (The Content Profile Fields) on Auto Assign Role paths:" my change is never recorded.

Some folks have cited a dev release that works, but there no longer seems to be one for Drupal 6.

mhrabovcin’s picture

StatusFileSize
new471 bytes

There is wrong value returned in hook_content_profile_settings(). This fix helped me.

Sknight17’s picture

Error still exists for Drupal 6.20 and Auto Assign Role 6.x-1.2. patch @60 works great so far.

Patch @20 also fixed the issue for me, however, because of the reported errors associated with the fix I neglected to use it.

sayela’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Assigned: Unassigned » sayela
Priority: Normal » Major
Status: Needs work » Active

Autoassignrole 7.x-1.x-dev doesn't appear in user registration forms after creating roles and configuring.

darin73’s picture

I have the same problem

fenstrat’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Assigned: sayela » Unassigned
Priority: Major » Normal
Status: Active » Closed (fixed)

This issue was fixed by the patch in #24 which was committed on September 1, 2010 in #42.

As autoassignrole-6.x-1.2 does not include this patch and as such you must use the autoassignrole-6.x-dev. This fix will be available in the next stable release (6.x-1.3).

As for 7.x problems in #62: create a new issue, please don't reopen old resolved issues.

fenstrat’s picture

Also note that this fix was included in autoassignrole 6.x-2.0-beta1

manoloka’s picture

Version: 6.x-1.x-dev » 6.x-1.2

I can confirm that the patch at http://drupal.org/node/755308 sorted this problem for me

fenstrat’s picture

Version: 6.x-1.2 » 6.x-1.x-dev

@manoloka please see #64

Adèle’s picture

Version: 6.x-1.x-dev » 6.x-1.2

I installed the version 6.x-1.2 and I tried to use the patch in #24 but the problem isn't fixed. The path is not save.
Could customization of registration template be the source of the problem ?
Otherwise, can anyone help me please ?

Thanks,
Adele

fenstrat’s picture

Version: 6.x-1.2 » 6.x-1.x-dev

@Adèle please try 6.x-1.x-dev or 6.x-2.0-beta1, both of which include the patch from #24. If problems persist please open a new issue.

Adèle’s picture

Version: 6.x-1.x-dev » 6.x-2.0-beta1

The version 6.x-1.x-dev seems to be not available anymore. I tried the 6.x-2.0-beta1 but the problems persist. I will open a new issue.
Thanks for your answer.

fenstrat’s picture

Version: 6.x-2.0-beta1 » 6.x-1.x-dev

.

abcdgeek’s picture

Version: 6.x-1.x-dev » 6.x-1.2

FYI, applying these patches to version 1.2 works :

http://drupal.org/files/issues/autoassignrole-content-profile-settings.p...
http://drupal.org/files/issues/autoassignrole-699888-24-fix-role-by-path...

I applied them manually and finally got rid of the traditionnal errors and CCK-fields miss

leewoodman’s picture

Version: 6.x-1.2 » 7.x-1.x-dev
Category: bug » support

Could anybody confirm if auto assign role path for Drupal 7 works? I can't find the administrative option to set the path to my two profiles

thank

L

fenstrat’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Category: support » bug

See #69 above.

@alwoodman please open a new issue.