Index: sql.php
===================================================================
RCS file: /repository/framework/Share/Share/sql.php,v
retrieving revision 1.52
diff -u -r1.52 sql.php
--- sql.php	22 Sep 2008 22:15:05 -0000	1.52
+++ sql.php	6 Oct 2008 14:37:24 -0000
@@ -436,7 +436,7 @@
             $sortfield = 's.attribute_' . $sort_by;
         }
 
-        $query = 'SELECT DISTINCT s.* '
+        $query = 'SELECT s.* '
             . $this->_getShareCriteria($userid, $perm, $attributes)
             . ' ORDER BY ' . $sortfield
             . (($direction == 0) ? ' ASC' : ' DESC');
@@ -541,9 +541,21 @@
     function _countShares($userid, $perm = PERMS_SHOW, $attributes = null)
     {
         $query = $this->_getShareCriteria($userid, $perm, $attributes);
-        $query = 'SELECT COUNT(DISTINCT s.share_id) ' . $query;
+        $query = 'SELECT s.share_id ' . $query;
+        $result = $this->_db->query($query);
+        if (is_a($result, 'PEAR_Error')) {
+            Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
+            return $result;
+        } elseif (empty($result)) {
+            return array();
+        }
+
+        while ($share = $result->fetchRow(MDB2_FETCHMODE_ASSOC)) {
+            $shares[(int)$share['share_id']] = true;
+        }
+        $result->free();
 
-        return $this->_db->queryOne($query);
+        return count($shares);
     }
 
     /**