diff --git a/util/sign.php b/util/sign.php index b3c4110d..d0f8d3e8 100644 --- a/util/sign.php +++ b/util/sign.php @@ -128,27 +128,27 @@ function get_hash_values() { if($last_id == 0) { $start_id = TSA_START_ID; - if(MODE == 'unit') { $stop_id = $start_id + TSA_STAMP_REQUEST_UNIT_SIZE - 1; } - else { $stop_id = 1000000000; } - } - else { + } else { $start_id = $last_id + 1; - if(MODE == 'unit') { $stop_id = $start_id + TSA_STAMP_REQUEST_UNIT_SIZE - 1; } - else { $stop_id = 1000000000; } } - $query = $db->query("SELECT id, digest FROM " . TABLE_META . " WHERE id >= ? AND id <= ? ORDER BY id", array($start_id, $stop_id)); + if(MODE == 'unit') { + $limit = TSA_STAMP_REQUEST_UNIT_SIZE; + } else { + $limit = 100000; // stay well below default PHP memory_limit + } + + $query = $db->query("SELECT id, digest FROM " . TABLE_META . " WHERE id >= ? ORDER BY id LIMIT $limit", array($start_id)); foreach($query->rows as $q) { $count++; + $last_id = $q['id']; $s .= $q['digest']; } - if(MODE == 'time') { $stop_id = $start_id + $count - 1; } - return [ START_ID => $start_id, - STOP_ID => $stop_id, + STOP_ID => $last_id, COUNT => $count, HASH_VALUE => hash(ALGO, $s) ];