All pastes #82766 Raw Edit

Miscellany

public text v1 · immutable
·published 2006-07-08 22:10 UTC
rendered paste body
function aggregator_cron() {
  $half_an_hour = 60 * 30 ;
//  if (time()-variable_get('aggregator_last_cron_limiter', 0) > $half_an_hour){
    $result = db_query('SELECT * FROM {aggregator_feed} WHERE checked + refresh < %d ORDER BY checked ASC', time());
    $start = time();
    $end = $start + variable_get('aggregator_cron_run', 120);
    while (time() < $end && ($feed = db_fetch_array($result))) {
      aggregator_refresh($feed);
    }
    $age = mktime(0, 0, 0, date('m'), date('d') - 12);
    db_query('BEGIN');
    db_query('DELETE FROM {aggregator_category_item} WHERE iid IN (SELECT iid FROM {aggregator_item} WHERE timestamp < %d)', $age);
    db_query('DELETE FROM {aggregator_item} WHERE timestamp < %d', $age);
    db_query('COMMIT');

//    variable_set('aggregator_last_cron_limiter', time());
//  }
}