Index: archive.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/archive/archive.module,v
retrieving revision 1.7
diff -u -F^f -r1.7 archive.module
--- archive.module	31 Jul 2006 21:30:20 -0000	1.7
+++ archive.module	13 Mar 2007 19:41:22 -0000
@@ -62,8 +63,7 @@ function archive_page($year = NULL, $mon
   $output = theme('archive_navigation', $date);
 
   $nodes = variable_get('default_nodes_main', 10);
-  $query = _archive_query($date);
-  $result = pager_query(array_shift($query), $nodes, 0, NULL, $query);
+  $result = _archive_query($date);
 
   if (db_num_rows($result)) {
     while ($node = db_fetch_object($result)) {
@@ -135,6 +135,7 @@ function _archive_date($year = NULL, $mo
  *    An array of (query, param_start, param_end)
  */
 function _archive_query($date) {
+  $nodes = variable_get('default_nodes_main', 10);
 
   if ($date->day > 0 && $date->month > 0) {
     // Confine the display interval to only one day
@@ -152,7 +153,8 @@ function _archive_query($date) {
     $end   = gmmktime(0, 0, 0, 1, 1, $date->year + 1);
   }
 
-  return array('SELECT nid, type FROM {node} WHERE status = 1 AND created >= %d AND created < %d ORDER BY created DESC', $start - $date->tz, $end - $date->tz);
+
+  return pager_query(db_rewrite_sql('SELECT n.nid, n.type FROM {node} n WHERE n.status = 1 AND n.created >= %d AND n.created < %d ORDER BY n.created DESC'), $nodes, 0, NULL, $start - $date->tz, $end - $date->tz);
 }
 
 /**
