Hello,

I am getting the below error on page http://www.example.com/admin/content/types/profile/profile

warning: Invalid argument supplied for foreach() in /home/example/public_html/includes/form.inc on line 1207

Can anyone please assist?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

YK85’s picture

The error looks to be coming from this part.
I would really appreciate someone's help in fixing this bug.
Thank you!

<?php
function form_type_checkboxes_value($form, $edit = FALSE) {
  if ($edit === FALSE) {
    $value = array();
    $form += array('#default_value' => array());
    foreach ($form['#default_value'] as $key) {
      $value[$key] = 1;
    }
    return $value;
  }
  elseif (!isset($edit)) {
    return array();
  }
}
?>

Also, I am using Drupal 6.16 and didn't use to see this error message back in Drupal 6.15
Thanks!

obibas’s picture

Version: 6.x-1.x-dev » 6.x-1.0
Assigned: Unassigned » obibas

Thanks for all of your help here, I have experienced the same problem since I am using drupal 6.16.

If I got all my modules uninstalled it works fine. But when I am installing the content profile module I get the same warning: Invalid argument supplied for foreach() in \includes\form.inc on line 1207. This warning is shown on my content profile admin page. Some help would be appreciated.

patcon’s picture

Hey guys, it seems that this might be a duplicate of #707008: Compatibilty issue with Auto Assign Role(?) warning message and #730472: Use on Auto Assign Role paths, but I'll mark this one as the main one... I don't suppose anyone else has Auto Assign Roles installed?

I'm getting the same issue on the same line as your guys, and the guy in the other thread was getting the same thing 14 weeks ago in the dev build.

I've done a fresh install, and only activated these modules:
Administration menu 6.x-1.5
Content 6.x-2.6
Content Profile 6.x-1.0
Path 6.16
Auto Assign Role 6.x-1.2

I still get it, so it seems pretty basic. It also shows up on content profile pages aside from the default, ie. .../custom_profile/profile

Finally, when I inactivate Auto Assign Role, the error goes away.

Seems like it has to do with this checkbox array

Use on Auto Assign Role paths:
[ ] (role_1) path_1
[ ] (role_2) path_2

Line 1207 is this one: foreach ($form['#default_value'] as $key) {
so it seems it has to do with a lack of default? Guy in other thread just reverted to v1.1 and things worked fine... I'll try to dig up the change...

patcon’s picture

First error was as early as Feb 7th, so checking CVS repository for relevant changes...

Big commit right after 6.x-1.1 was released... don't think I'll have time to look through tonight...
http://drupal.org/cvs?commit=267554

kennyh’s picture

Hi, just to pitch in that I'm facing exactly the same problem described above by patcon. As in his case, when I disable Auto Assign Role the error message disappears.

Thanks

DrupT’s picture

I face the same problem and can confirm kennyh's comment
thanks

fago’s picture

Project: Content Profile » Auto Assign Role
Version: 6.x-1.0 » 6.x-1.x-dev
Component: Base module » Code

sounds like an auto assign role bug then.

JThan’s picture

Just subscribing as I am that "Guy from the other Thread" and want to see where this ends up.

rotoheni_09’s picture

Version: 6.x-1.x-dev » 6.x-1.2
Assigned: obibas » rotoheni_09

Hi same problem. Hoping this can get sorted as it sounds like a really useful module.

mwisner’s picture

Status: Active » Needs review
FileSize
476 bytes

Hello,

Attached is a patch that I believe will resolve this issue. This is my first attempt ever at submitting a patch, (so i'm not sure if it's done correctly or not) In case it doesn't work, here is the fix:

Basically, the autoassignrole_use content profile setting must be defined in hook_content_profile_settings.

Currently, autoassignrole's implementation of this hook looks like this:

/**
 * Implementation of hook_content_profile_settings().
 */
function autoassignrole_content_profile_settings() {
  static $autoassignrole;
  if (empty($autoassignrole)) {
    $autoassignrole['values'] = array_keys(user_roles((TRUE)));
  }
  return $autoassignrole;
}

I found that by adding an additional line to define autoassignrole_use seems to have fixed the issue:

/**
 * Implementation of hook_content_profile_settings().
 */
function autoassignrole_content_profile_settings() {
  static $autoassignrole;
  if (empty($autoassignrole)) {
    $autoassignrole['values'] = array_keys(user_roles((TRUE)));
  }
  $autoassignrole['autoassignrole_use'] = array();
  return $autoassignrole;
}

Status: Needs review » Needs work

The last submitted patch, autoassignrole.patch, failed testing.

patcon’s picture

Hey mwisner,

I still have to get in the groove with SimpleTest as well, so I feel your pain. I think the issue with the fail was that you submitted a patch with the autoassignrole module directory changed to "autoassignrole-fixed" :)

patcon’s picture

FileSize
480 bytes

resubmitting, if nothing else than just to test my understanding of SimpleTest...

patcon’s picture

Status: Needs work » Needs review
FileSize
480 bytes

Aaaaaand... do-over.

Status: Needs review » Needs work

The last submitted patch, autoassignrole_0_fixed.patch, failed testing.

cyberswat’s picture

Status: Needs work » Needs review
FileSize
636 bytes
cyberswat’s picture

Just an fyi ... if you need help with generating these patches I tend to find the cvs instructions linked off the main project pages for each module is invaluable ... http://drupal.org/node/138844/cvs-instructions/DRUPAL-6--1 is the specific one for this particular branch of this module.

Status: Needs review » Needs work

The last submitted patch, autoassignrole-761748-17.patch, failed testing.

cyberswat’s picture

Status: Needs work » Needs review

It looks like the patch failed but it may it looks more like the tests need to be updated in the dev branch vs the code change that you implement here actually breaking anything. I don't know enough about content_profile to be able to say if this is a good approach or not so am relying on the participants of this thread to help validate. If anyone wants to try and help update the SimpleTests themselves that would be great to ;)

cyberswat’s picture

Status: Needs review » Needs work
ITMonkey’s picture

subscribing =)

fayola’s picture

Status: Needs work » Needs review

#15: autoassignrole_0_fixed.patch queued for re-testing.

fayola’s picture

#14: autoassignrole_0_fixed.patch queued for re-testing.

babycourageous’s picture

*subscribing as I face the issue as well.

barry769’s picture

*same problem, no solution.

patcon’s picture

Sorry guys, if it wasn't clear before, rolling back to v1.1 solves the problem. Not ideal But works in a pinch!

alexmoreno’s picture

dev version works perfect autoassignrole-6.x-1.x-dev.tar.gz

patcon’s picture

Thank urwen. Can anyone verify? I'll check when I get the chance, and report here, then maybe we could switch this to resolved

victorkane’s picture

@patcon Yes, I can verify that upon replacing 6.x-1.2 with 6.x-1.x-dev information "sticks" (associating a content profile content type with a with a role path by editing the Content Profile tab of the content type). Selecting the checkbox and hitting Submit brings up "Your changes have been saved." with no error message, and selection "sticks". Also seems to have solved 699888.

thommyboy’s picture

is the 1.xdev really working for you guys? i get "Illegal offset type in.." now instead of the old error. going back to 6.x-1.1 works for me though but throws an "security update required"...

calefilm’s picture

I'm getting this too, thommyboy--man i really want to get this resolved!

http://drupal.org/node/814870

patcon’s picture

Status: Needs review » Closed (duplicate)

Marking this one a duplicate for ease of management.

#814870: Auto Assign Role - warning: Illegal offset type seems to have more info...

patcon’s picture

Status: Closed (duplicate) » Fixed

Shoot. Seems folks are saying this error (Invalid argument supplied for foreach()) was fixed in most recent dev, but now new error (Illegal offset type) is the problem, so I'll mark this as fixed. Discussion on new error should be in other issue, I suppose. Sorry for the confusion guys

ExTexan’s picture

I uploaded a patch that fixes the illegal offset error... (at least it worked for me)...

http://drupal.org/node/814870#comment-3306836

fenstrat’s picture

Status: Fixed » Closed (duplicate)

Anyone here with this issue try the patch over at #699888-24: Auto Assign Role paths is broken

operations’s picture

Hi, I had the content profile working fine with the auto assign role, the warning wasn't appearing. I was doing lot of configurations when suddenly It showed up. Uninstalling the two modules and re-installing wouldn't seem to fix the problem.

Auto assign role v6.x-1.2
Content Profile v6.x-1.0

Did anyone found a solution instead of rolling back to v6.x-1.1 of AAR module ?

manoloka’s picture

Hi there,

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

fenstrat’s picture

@manoloka This issue was fixed and committed in #699888-24: Auto Assign Role paths is broken

zhuzhuojiang’s picture

mark...... works for me