Hi,

I get this error

Invalid argument supplied for foreach() in SITE.com/sites/all/modules/drigg/drigg_autovote/drigg_autovote.module on line 327.

Any idea ?

Comments

mercmobily’s picture

Status: Active » Fixed

Hi,

Drigg in CVS fixes this issue.
Please refer to it. Or, just select one or two "vote as" users to fix the issue temporarily if you don't want to upgrade to Drigg CVS!

Merc.

wwwoliondorcom’s picture

Thank you, and I get another error, can you tell me if it's related ?

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND n.created < UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) - 60*60 AND n.status = 1 and' at line 1 query: SELECT n.title, n.nid,n.uid FROM node n LEFT JOIN drigg_node dn2 ON dn2.dnid = n.nid WHERE ( 1=1 AND !(n.type='drigg' AND n.promote=0) AND !(n.type='drigg' AND dn2.killed=1 ) ) AND ( !(n.type='drigg' AND n.created > UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) ) ) AND ( n.type='drigg' AND n.created > UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) - 60* AND n.created < UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) - 60*60 AND n.status = 1 and n.promote=0 AND n.nid NOT IN (select nid from votingapi_vote where content_type='node' AND content_id=n.nid AND uid IN (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,
39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,
73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,
105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,
129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,
153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,
177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,
201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219) AND n.uid <> uid ) ) GROUP BY n.nid in SITE.com/includes/database.mysql.inc on line 172.

mercmobily’s picture

Hi,

I am pretty sure the CVS version fixes this one two. A couple of queries escaped the { } treatment...

If you are absolutely positive the CVS version does it, please let me know.

Merc.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

wwwoliondorcom’s picture

Status: Closed (fixed) » Active

Hi,

Is it corrected only in the CVS, as I just installed the latest version, Drigg 5.x-1.34 and still have this error today ?

Invalid argument supplied for foreach() in /sites/all/modules/drigg/drigg_autovote/drigg_autovote.module on line 327.

THANKS!

mercmobily’s picture

Status: Active » Fixed

Hi,

This is the line of code:

$voting_users_a=drigg_autovote_voting_users_array();

This tells me that you haven't defined any voting users. You really have to, or autovoting won't work.

Please make sure you have UIDs (user ids) there in the autovoting interfacee, where it says: "'A comma separated list of UIDs who will vote randomly the stories voted by the deciding users'),"

Since I am 99.5% sure this will fix the problem, I am closing this. Please reopen with _full_ details of your configuration (in the autovoting tab) if you still have a problem.

Merc.

mercmobily’s picture

Hi,

Also, please make sure you are using a recent version of MySql.

Merc.

wwwoliondorcom’s picture

Status: Fixed » Active

Hello,

Thanks for reply.

MySQL is recent and UIDs are set. Here is the full configuration:

AUTOVOTING ENABLED
A comma separated list of UIDs who determine which stories get automatic voting:
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,
39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,
73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,
105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,
129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,
153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,
177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,
542,597,469,391,542,597,94,469,391,444,596,469,140,496,265,522,286

A comma separated list of UIDs who will vote randomly the stories voted by the deciding users:
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30

Settings for automatic voting of stories voted by deciders:
How many votes per hour: 1
How much karma each vote will be worth: 1
How many REAL votes a story needs: 3

AUTOVOTING ENABLED for stories in the queue:
Run this autovoting procedure every 1440 minutes
Only consider scoops that were in the queue for more than 10080 minutes
Only consider scoops that were in the queue for less than 40320 minutes

Minimum number of votes (random): 1
Maximum number of votes (random): 2

What I can see and what I understood (or not!):

Stories get as many votes as I put UIDs in the "list of UIDs who will vote randomly the stories voted by the deciding users" --------> if I put 30 UIDs in this list the stories get 30 votes, if I put 40 they get 40, so it means that stories all get the same number of votes, is it normal ?

I set "Only consider scoops that were in the queue for more than" to 10080 minutes but stories that are just published (in the upcoming queue) get votes even if they are in the queue for less than 10080 ----> is there anything wrong ?

I didn't want to bother you with my problems but since I'm using Drigg I usually promote stories manually as few of them get auto promotion (and when it happens it is stories that have just been published and are new in the upcoming queue).

The latest message I got in the logs is:

Stories in queue voted by deciders: 1218, Votes real: 0

Seconds since last autovoting: 7223.7317254543, Voters deciders plus real: 1218, Votes to assign per hour: 1, Votes per hour total: 1218, Votes to assign: 2444, remainder (votes): 0.029233778715025, reminder (seconds): 0.086405257285787 (0.33833333333333 votes per seconds, 20.3 votes per minute), 7223.7317254543 seconds passed since last autovoting

Query: SELECT n.nid,n.uid FROM {node} n LEFT JOIN {votingapi_vote} vv ON vv.content_id=n.nid WHERE vv.content_type='node' AND vv.value > 0 AND n.type='drigg' AND n.created > UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) - 60*60*672 AND n.status = 1 and n.promote=0 AND vv.uid IN (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,
38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,
72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,
104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,
152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,
200,542,597,94,469,391,542,597,469,391,444,596,469,140,496,265,522,286) GROUP BY n.nid;

Thank you so much to always be helpful.

mercmobily’s picture

Hi,

Ugh... OK, you have misunderstood how autovoting works.
I am not sure why the error message is there, but your settings aren't sane.

In autovoting:

* A comma separated list of UIDs who determine which stories get automatic voting:

Should be a FEW users (say 6,7) who will *trigger* autovoting for the stories they vote. They are your MAGIC user

* A comma separated list of UIDs who will vote randomly the stories voted by the deciding

This is a longer list of users which will do the voting. Say 40, 50 users. The list mustn't overlap with the previous one.

* How many votes the system will assign per hour

This is what it says it is. It will assign N votes per hour. If you set it to 1, it will assign 1 vote per hour. The number of voters, deciders etc. is completely unrelated.

* How many REAL votes a story needs before it is treated as if a decider voted on it. 0 to disable this function:

This is a "trick". If enough normal users vote for a story, it will be treated as if a "decider" voted for it -- andtherefore, autovote will be triggered.

Now... you have a problem.

"Seconds since last autovoting: 7223.7317254543, Voters deciders plus real: 1218, "

You have 1218 deciders?!?!?!

I can't think for a reason why:

$voting_users_a=drigg_autovote_voting_users_array();

Is returning an empty array.

After MUCH debugging, however, I found out why you got the error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND n.created < UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) - 60*60 AND n.status = 1 and' at line 1

The reason is that you have left some fields empty:

* Only consider scoops that were in the queue for more than... (in minutes):
* Only consider scoops that were in the queue for less than... (in minutes)":

Please complete the configuration of the module and report back.
If you are rich, please consider donating -- this took me a lot of time. If you can't afford it, please don't feel bad.

Bye!

Merc.

sikjoy’s picture

Assigned: Unassigned » sikjoy

Hi Merc:

We have a usability issue here. If these fields cannot be empty without breaking the module, then they should be validated and warn the user when they are submitting the settings form.

I'll take some time and look at this issue.

--sicjoy

mercmobily’s picture

Hi,

Sicjoy, I've made them mandatory already. That _should_ be enough - if it's not, please let me know.

Merc.

sikjoy’s picture

Looking at the code, I see that now.

Then, how the heck did wwwoliondorcom manage to make the variables empty string?

Puzzled,

sicjoy

wwwoliondorcom’s picture

Hi, thanks, I'm testing now, but you told me that I had left some fields empty but it's not true as I wrote above:

AUTOVOTING ENABLED for stories in the queue:
Run this autovoting procedure every 1440 minutes
Only consider scoops that were in the queue for more than 10080 minutes
Only consider scoops that were in the queue for less than 40320 minutes

Your reply was:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND n.created < UNIX_TIMESTAMP(CURRENT_TIMESTAMP()) - 60*60 AND n.status = 1 and' at line 1
The reason is that you have left some fields empty:
* Only consider scoops that were in the queue for more than... (in minutes):
* Only consider scoops that were in the queue for less than... (in minutes)":

- About the list of UIDs who determine which stories get automatic voting: my list is huge because you cannot know who is going to vote for some stories, as most of the people don't vote, and that's why I wrote as many UIDs as possible, any problem or do I still don't undertand ?

- About list of UIDs who will vote randomly the stories voted by the deciding: if I write 30 UIDs each story will get 30 votes, if I write 50 UIDs, each story will get 50 votes, right ? At least that's what I've seen until now.

Thank you so much, and I wish I'll be rich to help soon!

mercmobily’s picture

Hi

@sicjoy: I've only just committed the change

@wwwoliondorcom: you have hugely misunderstood how autovoting works.
Please read *carefully* what I wrote.
The two set of users, deciders and voters, are *not* meant to be real users. I am going to say this once more: they are _NOT_ meant to be real users. The deciders are users that *you* use to trigger autovoting. The list below, the voters, are the ones the system uses to assign "automatic" votes.
Please re-read what I wrote above. Your list is huge, and is _wrong_. I will say that again: _wrong_.

Once again, please set autovoting with sane values and report back. Hint: sane here means maximum 10 "deciding" users and -- let's say -- 40 voting users:

A comma separated list of UIDs who determine which stories get automatic voting: (10 uids)

A comma separated list of UIDs who will vote randomly the stories voted by the deciding users: (4 uids)

Also, pick 1 story per hour.

Bye,

Merc.

wwwoliondorcom’s picture

I do not understand why the two sets of users, deciders and voters shouldn't be real users as for me it's not a problem, and I disabled the WHO VOTED option so nobody knows who voted for the stories.
And when you say "are not meant" does it mean that they MUST NOT be real users because it can create bugs ?

What I understand from your explanation (and asked confirmation to someone else) is that you expect drigg admin to login with 10 different users (deciders) to vote for stories that should get some votes ?

And the voters should be 40 fake users (to create manually or non existing UIDs are ok?) that will be the voters for the story ?

Thanks again.

mercmobily’s picture

Hi,

They can be real users, no worries there.
As I wrote above, however, setting an absurd number of users is _not_ what autovoting is for. Having an insane number of UIDs in the config window is _not_ a good way to go.

So, please to quote myself:

"Once again, please set autovoting with sane values and report back. Hint: sane here means maximum 10 "deciding" users and -- let's say -- 40 voting users:"

Once you've done that, please check the site thoroughly and report back problems.

I will only be able to support you again once you've done what I've requested.

Merc.

sikjoy’s picture

Hi Merc:

I have a few of questions, concerning this issue:

What are the specifications for the "voting users"? You mentioned that they aren't real users. I'm assuming that they must at least have a user account, even if set up by the admin. Is this correct?

Should we set limitations on the maximum number of "voting users"? Also, if my assumption above is correct, we can validate the "voting users" that are submitted as having an account with the Drigg site.

Likewise, should we set limits on the maximum number of "deciding users"? We can also validate the existence of the deciding users.

The effort to put in solid validation will prevent us, in the future, having to field things like this in the issue queue. I'd much rather be adding new features.

--sicjoy

mercmobily’s picture

Hi,

1) Yeah, validation would be good. But it might be time intensive -- one query per user. But,,, why not?

2) About a limitation on how many... again, maybe that's a good idea. Keep in mind that there are no *hard* numbers... but, too many of them might turn the SQL queries within Drigg ridicolous

I think I would simply go with validation.

Bye,

Merc.

sikjoy’s picture

Hi Merc:

I still need an answer to my question:

What are the specifications for the "voting users"? You mentioned that they aren't real users. I'm assuming that they must at least have a user account, even if set up by the admin. Is this correct?

Thanks,

sicjoy

wwwoliondorcom’s picture

Yes, I tried to use fake IUDs (that do not exist in the database and it doesn't work), I'm testing more and will report.

Thanks.

mercmobily’s picture

Hi,

The UID need to be "fake" from a logical perspective. They need to be REGiSTERED users. Just, not users who would normally log in and use the system.

Merc.

mercmobily’s picture

Hi,

Please report back. This bug really should be fixed...

Merc.

sikjoy’s picture

Version: 5.x-2.x-dev » 5.x-1.x-dev
Status: Active » Fixed

OK - It turns out that the form was not requiring the fields for the UID lists. I fixed that. I also added extra validation to insure that numeric values are entered and that they are indeed registered users.

wwwoliondorcom’s picture

Hi,

With all parameters set as you want, no more error message, but it is anyway a trouble to regularly get stories automatically published as few people really votes, and I have to do it myself.

When I check the logs I always have 2 AUTOVOTING_ACT in a row but the first one is sometimes (most of the time) empty with no votes, can you explain me why ? What determines if stories are voted or not? The log I get is:

Type AUTOVOTING_ACT
Message DRIGG AUTOVOTING UB Cron: It's been long enough: starting
---> HERE, NO STORY VOTED <---
Severity notice

Parameters I have set are:
Run this autovoting procedure every... (in minutes): 10
Only consider scoops that were in the queue for more than... (in minutes): 1440
Only consider scoops that were in the queue for less than... (in minutes)": 40320
Minimum number of votes (random): 1
Maximum number of votes (random): 30

But I have more than 100 stories in the queue, so why aren't the other ones voted ?

Thanks.

mercmobily’s picture

Hi,

wwwoliondorcom, sorry, I don't know and I can't work it out.
If you are able to pay for consultancy, please let me know. The good news is, if it was Drigg's fault, then the 1:1 consultancy is free.

Please let me know in a private message.

Merc.

mercmobily’s picture

Hi,

@wwwoliondorcom: one last thing. If you want to avoid logging out and in etc., you can use the option:

* Enable bulk voting for users with role "drigg bulk voter"

This means that users with that permission will be able to re-vote for a story, and each time it will automatically cast the vote from a randomly selected user within the list of "voters" (one of the users in the list 'A comma separated list of UIDs who will vote randomly the stories voted by the deciding users:'). This will save you a lot of logging out/in/out/in etc.

I realise that autovoting is complicated. However, as I said, please read the documentation here and on Drigg's web site carefully, and do a lot of experimenting etc. and you will get there.

Bye,

Merc.

wwwoliondorcom’s picture

Hi,

I'm still testing, as the autovoting works on some cron run and not on some others (no stories voted), I will tell you more as soon as I find out.

Thanks.

mercmobily’s picture

Hi,

OK. Please consider hiring some of us for specific 1:1 help.

I am happy to be hired and not charge you if it was Drigg's fault rather than a misuse of the module. However, I think it's unlikely.

Merc.

mercmobily’s picture

Hi,

At this point, please keep in mind that I will only reopen this bug if you provide clear instructions on how to reproduce it.
By "clear instructions" I mean a detailed step by step procedure on how to configure absolutely everything from a new drigg-distr.tgz site in order to reproduce exactly the problem you are having.

Or hire somebody to actually get on your site and do some specific cient-oriented debugging.

Merc.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

diesel7’s picture

hey Merc, assigning UIDs did not solve the problem ;(