Watchdog reports:

Table 'xxxxx.activitystream_accounts' doesn't exist query: 

SELECT a.uid, a.userid, a.password, a.feed, a.module FROM activitystream_accounts a LEFT JOIN users u on a.uid = u.uid WHERE a.lastfetch < date_sub(now( ) , INTERVAL 1 HOUR) AND u.access > unix_timestamp(date_sub(now( ) , INTERVAL 30 day)) ORDER BY a.lastfetch DESC, u.access DESC in /xxxx/httpdocs/sites/all/modules/activitystream/activitystream.module on line 473.

Investigating the function activitystream_cron:

function activitystream_cron() {
  module_load_include('inc', 'node', 'node.pages');
  $number_of_hours = variable_get('activitystream_cron_hours', 1);
  $active_days = variable_get('activitystream_active_days', 30);
  $result = db_query('SELECT a.uid, a.userid, a.password, a.feed, a.module FROM activitystream_accounts a LEFT JOIN users u on a.uid = u.uid  WHERE a.lastfetch < date_sub(now( ) , INTERVAL %d HOUR) AND u.access > unix_timestamp(date_sub(now( ) , INTERVAL %d day)) ORDER BY a.lastfetch DESC, u.access DESC', $number_of_hours, $active_days);
  $users = array();
  while ($user = db_fetch_object($result)) {
    $users[] = $user;
  }
  $num_users = activitystream_update_streams($users);
  if ($num_users) {
    // Add an informative message in the watchdog
    watchdog('activitystream', 'Processed %count users.', array('%count' => $num_users));
  }  
}

The offending line 473: My implementation uses a drupal table prefix that seems abscent:

  $result = db_query('SELECT a.uid, a.userid, a.password, a.feed, a.module FROM activitystream_accounts a LEFT JOIN users u on a.uid = u.uid  WHERE a.lastfetch < date_sub(now( ) , INTERVAL %d HOUR) AND u.access > unix_timestamp(date_sub(now( ) , INTERVAL %d day)) ORDER BY a.lastfetch DESC, u.access DESC', $number_of_hours, $active_days);

Possible fix? I'm not familiar with the core enough to know if raw table names are used and the prefix is added somewhere down the line.

  $result = db_query("SELECT a.uid, a.userid, a.password, a.feed, a.module FROM ".$db_prefix."activitystream_accounts a LEFT JOIN ".$db_prefix."users u on a.uid = u.uid  WHERE a.lastfetch < date_sub(now( ) , INTERVAL %d HOUR) AND u.access > unix_timestamp(date_sub(now( ) , INTERVAL %d day)) ORDER BY a.lastfetch DESC, u.access DESC", $number_of_hours, $active_days);

Comments

akalsey’s picture

Title: function activitystream_cron() fails - missing $db_prefix ? line 473 when using a drupal database prefix » Drupal database prefix not used

Drupal adds the prefixes automatically if the table names are wrapped in curly brackets.

Changing to this will fix it...

<?php
$result = db_query('SELECT a.uid, a.userid, a.password, a.feed, a.module FROM {activitystream_accounts} a LEFT JOIN {users} u on a.uid = u.uid  WHERE a.lastfetch < date_sub(now( ) , INTERVAL %d HOUR) AND u.access > unix_timestamp(date_sub(now( ) , INTERVAL %d day)) ORDER BY a.lastfetch DESC, u.access DESC', $number_of_hours, $active_days);
?>
ericdee’s picture

Ahhh a much better fix! Thanks for the lesson :)

akalsey’s picture

Status: Active » Fixed

Fix commited in rev 1.2.2.15

Status: Fixed » Closed (fixed)

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