The following error occurs when cron runs with metering module enabled

Fatal error: Call to undefined function db_fetch_array() in /Applications/MAMP/htdocs/d7-clanavi/sites/default/modules/cloud/modules/cloud_metering/cloud_metering.inc on line 2393
CommentFileSizeAuthor
#2 1810568-2.patch2.19 KBbaldwinlouie

Comments

e_oliver’s picture

Hi I'm getting the same error. You can change db_fetch_array() to mysql_fetch_array() as per Drupal 7 syntax. But now there's a different error: Fatal error: Call to undefined function db_placeholders() in sites\all\modules\cloud\modules\cloud_metering\cloud_metering_queue_db.inc on line 246

Not sure how to fix calls to db_placeholders() under Drupal 7, as it is now a deprecated function.

Any help is greatly appreciated.


function _cloud_metering_get_in_progress_tasks($type = 'base') {

  $task_types = ($type == 'base' ? _cloud_metering_get_base_tasks() : _cloud_metering_get_checker_tasks());

  $tasks = array();

  $query  = "SELECT * FROM {" . CLOUD_METERING_QUEUE_TABLE . "} WHERE status = :status AND task IN ( " . db_placeholders($task_types, 'varchar') . ') AND TIMESTAMPDIFF(MINUTE, updated, CURRENT_TIMESTAMP) >= 1 ORDER BY created ASC';
  $params = array(':status' => CLOUD_METERING_QUEUE_STATUS_IN_PROGRESS);

  $result = db_query($query, $params);

  foreach ($result as $row) {
    $tasks[] = $row;
  }

  return $tasks;

}
baldwinlouie’s picture

Status: Active » Fixed
StatusFileSize
new2.19 KB

Here's a patch that fixes these two database errors. The code is checked into head also.

http://drupalcode.org/project/cloud.git/commit/c5230ea

baldwinlouie’s picture

The fix was to convert the queries to db_select and use D7 code conventions.

e_oliver’s picture

Title: Cloud metering module contains sql error » Louie, thanks for your help.

Wow I was stuck on this for hours, applied your patch and everything works now!

Thanks again.

e_oliver’s picture

Title: Louie, thanks for your help. » Cloud metering module contains sql error

Impressive work!

baldwinlouie’s picture

Status: Fixed » Closed (fixed)
baldwinlouie’s picture

Closing