Certainly running on mySQL 4.1 and 5.0 there is a bug due to the mixing of data types in the SQL in the premium_cron function. The times are stored as unix timestamps but the code uses the NOW() function which returns a date/time value.

<?php
function premium_cron() {
  db_query('DELETE FROM {premium} WHERE start_ts < NOW() AND end_ts != 0 AND end_ts < NOW()');
}
?>

should be replaced by

<?php
function premium_cron() {
  db_query('DELETE FROM {premium} WHERE start_ts < UNIX_TIMESTAMP() AND end_ts != 0 AND end_ts < UNIX_TIMESTAMP()');
}
?>

Simon

Comments

budda’s picture

So this would also be a problem in the premium_nodeapi() function:

      return array('premium' => (int) db_result(db_query(
      		'SELECT 1 FROM {premium}  WHERE nid = %d
    			AND ( start_ts = 0 OR start_ts > NOW()) AND end_ts < NOW()', $node->nid)));
allie micka’s picture

Status: Active » Fixed

Committed both fixes. Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)