Hello, I get this error message anytime I set any permission(s) on my site. I have updated all the necessary modules and my drupal installation is up to date.

"
Warning: Invalid argument supplied for foreach() in user_permission_get_modules() (line 3040 of /home/mysite/public_html/modules/user/user.module).
Warning: Invalid argument supplied for foreach() in user_permission_get_modules() (line 3040 of /home/mysite/public_html/modules/user/user.module).
Warning: Invalid argument supplied for foreach() in user_permission_get_modules() (line 3040 of /home/mysite/public_html/modules/user/user.module).
Warning: Invalid argument supplied for foreach() in user_permission_get_modules() (line 3040 of /home/mysite/public_html/modules/user/user.module).
"

I'll appreciate a solution from anyone concerning this issue,
Thanks in advance

Comments

pixelsweatshop’s picture

Status: Active » Postponed (maintainer needs more info)

A quick google search for:

Warning: Invalid argument supplied for foreach() in user_permission_get_modules() (line 3040 of /modules/user/user.module).

results in a number of people with the same issue.

Have you tried any of them?

deeray’s picture

Yes I have done a google search on this, but none of codes looked liked what I saw when I opened up my user.module file.

Please bear with me, I don't have any coding experience, I hope am reporting this correctly,

This is what I got on my user.module file from Line 3036 - line 3045,

"function user_permission_get_modules() {
$permissions = array();
foreach (module_implements('permission') as $module) {
$perms = module_invoke($module, 'permission');
foreach ($perms as $key => $value) {
$permissions[$key] = $module;
}
}
return $permissions;
}"

what can I edit in this code to resolve the issue?

Thanks in advance for your help.

pixelsweatshop’s picture

Don't touch core. The problem is most likely one of your installed contrib modules

deeray’s picture

I have over 300 installed contrib modules on my site, how do I figure out which is generating the problem?

deeray’s picture

Status: Postponed (maintainer needs more info) » Active

I have over 300 installed contrib modules on my site, how do I figure out which is generating the problem? I have also had my site host perform a malware scan on the site and they found nothing.
What other information may you need to help me get to the solution?

pixelsweatshop’s picture

300 is a lot. Even for a large site. I would start by identifying which modules interact with the user API and start disabling one by one and testing each tine to see if the error persists. Also what else does dblog say?

deeray’s picture

I have disabled all the user related modules I know, but the problem still persists... and I must mention that this error message also pops up sometimes when I delete a module

"An illegal choice has been detected. Please contact the site administrator"

It has really been a challenge mainly because I don't even know what I'm looking for or where to look.

Is it okay for me to just 'ignore' these error messages?

deeray’s picture

Hello,

I just had my sites hosting provider restore my "public_html/sites/all" folder to Feb 25th, that is One month ago, but I'm sorry to say the problem persists.

I need some help please,

thanks in advance

pixelsweatshop’s picture

What does it say in dblog and server error logs

deeray’s picture

I'm inexperienced with drupal, I did a search concerning your last comment and it appears 'dblog' is a module and I need a special module to check my server error logs, but I was unable to find any links to download and install them

pixelsweatshop’s picture

Try setting your permissions to trigger the error, then go to /admin/reports/dblog and copy and paste the errors and details

flocondetoile’s picture

@deeray.
I met same error messages.
Ii was because some custom modules have implemented hook_permission() but without returning anything.

For debug, you can add in user.module (remove it after) this snippet to see wich module implement this empty permission

if (empty($perms)) {dsm($module, '$module';}

You will see then which module is the guilty.

ZalemCitizen’s picture

@flocondetoile
Thanks to point it out !

#12 made the trick

cilefen’s picture

Status: Active » Closed (works as designed)