Hello

When i try to run cron i get the error message

 drush @1med cron
WD php: Recoverable fatal error: Argument 2 passed to db_query() must be an array, integer given, called in                                                          [error]
/var/www/drupal-7.0/sites/all/modules/contrib/votingapi/votingapi.module on line 74 and defined in db_query() (line 2213 of
/var/www/drupal-7.0/includes/database/database.inc).
Recoverable fatal error: Argument 2 passed to db_query() must be an array, integer given, called in /var/www/drupal-7.0/sites/all/modules/contrib/votingapi/votingapi.module on line 74 and defined в функции db_query() (строка 2213 в файле /var/www/drupal-7.0/includes/database/database.inc).
Drush command terminated abnormally due to an unrecoverable error.

I fix this

--- votingapi.module_o	2011-02-23 02:44:13.000000000 +0300
+++ votingapi.module	2011-02-23 02:49:08.000000000 +0300
@@ -71,10 +71,10 @@
   if (variable_get('votingapi_calculation_schedule', 'immediate') == 'cron') {
     $time = REQUEST_TIME;
     $last_cron = variable_get('votingapi_last_cron', 0);
-    $result = db_query('SELECT DISTINCT entity_type, entity_id FROM {votingapi_vote} WHERE timestamp > %d', $last_cron);
+    $result = db_query('SELECT DISTINCT entity_type, entity_id FROM {votingapi_vote} WHERE timestamp > :timestamp', array(':timestamp' => $last_cron));
 
-    while ($content = db_fetch_object($result)) {
-      votingapi_recalculate_results($content->entity_type, $content->entity_id, TRUE);
+    foreach ($result as $content) {
+        votingapi_recalculate_results($content->entity_type, $content->entity_id, TRUE);
     }
 
     variable_set('votingapi_last_cron', $time);
CommentFileSizeAuthor
#2 votingapi_cron_db_error.patch900 bytesslashrsm

Comments

slashrsm’s picture

Status: Active » Reviewed & tested by the community

It fixes this bug also for me. I've put dema502's code in a patch, which is attached.

slashrsm’s picture

StatusFileSize
new900 bytes
Anonymous’s picture

Version: 7.x-2.4 » 7.x-2.x-dev

Confirming this. Patch #2 works, is still needed for 2xdev. Please commit.

pmorel’s picture

Had the same issue, fixed on my version, search 'cron' in the issue queue, found this bug, my patch is exactly the same as #2, please commit.

Taxoman’s picture

Title: Cron » Cron bug with VotingAPI

Ready to be committed?

hass’s picture

+

univate’s picture

I am using the patch in #2 to fix this issue on a live site.

adammichaelroach’s picture

Patch worked for me

tomogden’s picture

I also got the above error while in the Panels Page Manager. The patch was just what I needed, thanks!

Anonymous’s picture

This is really needed. +1

Fidelix’s picture

Can this please be committed?

phoenix’s picture

Had the same problem here. And wrote same code as in the patch to fix it here. This can be committed.

eaton’s picture

Status: Reviewed & tested by the community » Fixed

At long last, committed and pushed. Will be in the 2.5 release.

Status: Fixed » Closed (fixed)

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