Index: weblinks.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/weblinks/weblinks.module,v
retrieving revision 1.1.4.58.2.123
diff -u -r1.1.4.58.2.123 weblinks.module
--- weblinks.module	3 Mar 2009 15:09:38 -0000	1.1.4.58.2.123
+++ weblinks.module	12 Mar 2009 14:48:04 -0000
@@ -1855,11 +1855,13 @@
  * @return result set from the query.
  */
 function _weblinks_get_query($tid = 0, $sort = 'title', $limit = 0) {
+  $query = 'SELECT !cols FROM {node} n ';
+  $cols = array();
   if ($sort === 'count') {
-    $query = 'SELECT COUNT(n.nid) FROM {node} n ';
+    $cols[] = 'COUNT(n.nid)';
   }
   else {
-      $query = 'SELECT DISTINCT(n.nid) FROM {node} n ';
+    $cols[] = 'DISTINCT(n.nid)';
   }
   $query .= 'INNER JOIN {node_revisions} nr ON nr.vid = n.vid ';
   $query .= 'INNER JOIN {weblinks} bw ON bw.vid = nr.vid ';
@@ -1878,16 +1880,19 @@
     case 'standard':
       $query .= $which_tid[$tid == 0];
       $query .= 'ORDER BY bw.weight, n.sticky, n.created';
+      $cols[] = 'bw.weight, n.sticky, n.created';
       break;
     case 'title':
       $query .= $which_tid[$tid == 0];
       $query .= 'ORDER BY bw.weight ASC, n.title ASC';
+      $cols[] = 'bw.weight, n.title';
       break;
     case 'recent':
       if ($tid > 0) {
         $query .= $which_tid[0];
       }
       $query .= 'ORDER BY n.changed DESC, n.title ASC';
+      $cols[] = 'n.changed, n.title';
       break;
     case 'random':
       if ($tid > 0) {
@@ -1902,8 +1907,8 @@
       break;
   }
 
+  $query = str_replace('!cols', implode(', ', $cols), $query);
   $query = db_rewrite_sql($query);
-// drupal_set_message("$tid / $sort / $query", 'status');
 
   if ($limit) {
     $result = db_query_range($query, $tid, 0, $limit);

