--- sql.php	2008-09-23 00:15:05.000000000 +0200
+++ /usr/lib/php5/share/pear/Horde/Share/sql.php	2008-10-06 19:28:44.000000000 +0200
@@ -436,8 +436,9 @@
             $sortfield = 's.attribute_' . $sort_by;
         }
 
-        $query = 'SELECT DISTINCT s.* '
+        $query = 'SELECT s.* '
             . $this->_getShareCriteria($userid, $perm, $attributes)
+            . ' GROUP BY s.share_id '
             . ' ORDER BY ' . $sortfield
             . (($direction == 0) ? ' ASC' : ' DESC');
         if ($from > 0 || $count > 0) {
@@ -541,9 +542,14 @@
     function _countShares($userid, $perm = PERMS_SHOW, $attributes = null)
     {
         $query = $this->_getShareCriteria($userid, $perm, $attributes);
-        $query = 'SELECT COUNT(DISTINCT s.share_id) ' . $query;
+        $query = 'SELECT COUNT(s.share_id) ' . $query . ' GROUP BY  s.share_id';
+        $result = $this->_db->query($query);
+        if (is_a($result, 'PEAR_Error')) {
+            Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
+            return $result;
+        }
 
-        return $this->_db->queryOne($query);
+        return $result->numRows();
     }
 
     /**