Closed (fixed)
Project:
Subscriptions
Version:
5.x-2.1
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
25 May 2008 at 21:12 UTC
Updated:
2 Jun 2008 at 15:29 UTC
I'm getting the following errors (screenshot attached) repeatedly.
warning: Invalid argument supplied for foreach() in /home/loho0004/sites/wikijoba/modules/subscriptions/subscriptions.module on line 500.
The errors come when using the advanced forum module. I've been trying to debug this but without much luck. Line 500 is:
foreach ($defaults[$uid] as $key => $value) {
I'm not sure where to look next. Could it be a permissions issue?
| Comment | File | Size | Author |
|---|---|---|---|
| subscriptions misery.jpg | 192.75 KB | chrism2671 |
Comments
Comment #1
chrism2671 commentedJust thought I should paste that entire foreach loop:
Comment #2
chrism2671 commentedIn order to help diagnose the problem, I have acquired and pasted the contents of $defaults
Hope this helps. Any assitance much appreciated.
Comment #3
salvisWhat action do you do to get this error? Under what account? What's the value of $uid?
Comment #4
chrism2671 commentedI am logged in as a normal user. The errors arise from merely visiting a page, although it does not occur on all pages. The function attempts to determine if the user has made a subscription choice, or else otherwise apply the default settings.
For reference I have pasted the entire code block for the this function. The relevant section is indicated, towards the bottom. Any help would be much appreciated!
Thanks,
Chris.
Comment #5
salvisI know the function, no need to post it here.
That code is working fine for everyone else. Something on your site causes it to be called in an invalid context, and we need to find out what that something is.
Please find out what the value of $uid is at that point, and also the values of $name and $account on function entry.
Comment #6
chrism2671 commented$name and $uid didn't have values, however $account did:
tdClass Object ( [uid] => 1000002 [name] => chrism2671 [pass] => df1c0bac4d4d33b360c187b63b1150b3 [mail] => hello@world.com [mode] => 0 [sort] => 0 [threshold] => 0 [theme] => [signature] => [created] => 1186994202 [access] => 1212302311 [login] => 1212232769 [status] => 1 [timezone] => 0 [language] => [picture] => [init] => [data] => a:6:{s:7:"contact";i:0;s:14:"picture_delete";s:0:"";s:14:"picture_upload";s:0:"";s:16:"privatemsg_allow";i:1;s:28:"privatemsg_setmessage_notify";i:1;s:20:"privatemsg_mailalert";s:1:"0";} [sid] => 82fdbf544f0d20e1108cf485258d7e0c [hostname] => 86.3.90.180 [timestamp] => 1212302311 [cache] => 0 [session] => [contact] => 0 [picture_delete] => [picture_upload] => [privatemsg_allow] => 1 [privatemsg_setmessage_notify] => 1 [privatemsg_mailalert] => 0 [roles] => Array ( [2] => authenticated user [1000002] => Registered Users [1000006] => Administrators ) )(I stuck in a fake email for the sake of pasting).
Comment #7
salvis$uid cannot be empty. We have
so $uid would have to be 1000002. It's odd that you have such high UID numbers — they start at 1...
$name cannot be empty. Most calls to _subscriptions_get_setting() in Subscriptions pass a string constant as their first parameter. There are one or two where $name is the concatenation of two strings, but they all have a constant part, so they won't be empty.
Please look through your entire source code — there must be a module that calls _subscriptions_get_setting() with invalid parameters.
You can also experiment with debug_backtrace(), which should show you where the function is called from.
Comment #8
chrism2671 commentedI've managed to solve the problem. The issue was that the subscriptions_user table wasn't fully populated with all users. This (including the high uid numbers) was caused by the a data import from vbulletin (using the vb to drupal import module). By repopulating this table, all the errors disappeared!
Thanks for all your help!
Chris.
Comment #9
salvisGood, thanks for letting me know.
That means that the vb to drupal import module isn't making the appropriate hook_user('insert') call when importing users. This is a bug and can cause all sorts of problems with other modules that track the users. You should report this to their issues queue.