I'm getting this error when I run the update:

warning: Division by zero in /home/USERNAME/www/www/sites/all/modules/subscriptions/subscriptions.install on line 490.

Comments

salvis’s picture

Title: Error upon updating » 'Division by zero' in subscriptions.install upon updating
Status: Active » Postponed (maintainer needs more info)

What? The dividend comes from

  db_result(db_query('SELECT MAX(uid) FROM {users}'))

and it gives you 0? You're running a site with no users, not even an administrator?

jsimonis’s picture

We definitely have users. Looking at the sequences table, we're up to 1227.

salvis’s picture

If you have, say, 1000 users, then you should have seen a progress bar with 20 browser reloads, processing 50 users at a time. At which point did this occur, at the beginning or at the end of this process?

subscriptions_update_7() is modeled one-to-one after system_update_172(). I could try an other termination condition, but I need to understand why it failed.

Here's the relevant source code:

function subscriptions_update_7() {
  if (!isset($_SESSION['subscriptions_update_7'])) {
    $_SESSION['subscriptions_update_7'] = 0;
    $_SESSION['subscriptions_update_7_max'] = db_result(db_query('SELECT MAX(uid) FROM {users}'));
  }

  $limit = 50;

  $result = db_query_range("SELECT uid FROM {users} WHERE uid > %d ORDER BY uid ASC", $_SESSION['subscriptions_update_7'], 0, $limit);
  while ($usr = db_fetch_object($result)) {
    // process this user...
    $_SESSION['subscriptions_update_7'] = $usr->uid;
  }

  if ($_SESSION['subscriptions_update_7'] == $_SESSION['subscriptions_update_7_max']) {
    unset($_SESSION['subscriptions_update_7']);
    unset($_SESSION['subscriptions_update_7_max']);
    return array();
  }
  return array('#finished' => $_SESSION['subscriptions_update_7'] / $_SESSION['subscriptions_update_7_max']);
}

Does anyone see how this can fail with a zero-divide exception on the last line?

BTW, you can restart subscriptions_update_7() any number of times without risking any problems.

jsimonis’s picture

The bar comes up, jumps to 18%, sits there for a while, and then jumps right to 100%. That's when I get the error.

salvis’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

This was an odd issue that no one else seems to have had. I'm sorry I wasn't able to provide more help...