Errror message when trying to create new content -- warning: Invalid argument supplied for foreach()...
jmunning - June 10, 2009 - 18:17
| Project: | Domain Access |
| Version: | 5.x-1.10 |
| Component: | User interface |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Description
On my production site I am getting an error message whenever I try to add content on my primary site. Any ideas how I could get rid of or suppress this error?
warning: Invalid argument supplied for foreach() in D:\WEB\FacultyLounge\nonmajors\sites\all\modules\domain\domain.module on line 1087.

#1
Did you install this on an existing site? It looks like your users are not assigned to any domains.
Either assign your users to domains or edit the file:
if (!isset($user->domain_user)) {$user->domain_user = array();
}
foreach ($user->domain_user as $key => $value) {
if (abs($value) > 0) {
$user_domains[] = $value;
}
}
5.x.1.9 is no longer supported, but if you users are not assigned to domains, you will have this problem in 5.x.10 as well.
Considering that you are trying to show users their domain options, it is tempting to call this configuration error rather than bug.
#2
Hi agentrickard,
Thanks for the help. I did install on an existing site. My understanding was that existing users would be assigned to the primary domain by default but now I can't find that info in the README so maybe I misunderstood. Is there an easy way to assign all existing users (I have over 2000) to the primary domain?
I didn't realize 5.x.10 was out, I will update.
Thanks.
#3
There is not an easy way in the D5 version; this is just serialized data stored in the {users} table. Better to add the error-handling code as a patch.
Even better to add a domain_enable() routine to update the {users} table.
#4
Proper patch. Committed to 5.x branch.
#5
I thought about this, and this is probably the proper patch. However, new users are auto-assigned to the domain from which they registered. So we probably need a form to assign users to domains.
#6
See #490846: Allow batch assignment of users to domains
#7
Automatically closed -- issue fixed for 2 weeks with no activity.