@@ -95,7 +95,7 @@ function policyCheck($folderDao, $userDao = null, $policy = 0)
95
95
return true ;
96
96
}//end policyCheck
97
97
98
- /** get the size and the number of item in a folder*/
98
+ /** get the size and the number of item in a folder*/
99
99
public function getSizeFiltered ($ folders , $ userDao = null , $ policy = 0 )
100
100
{
101
101
$ isAdmin = false ;
@@ -161,8 +161,9 @@ public function getSizeFiltered($folders, $userDao = null, $policy = 0)
161
161
->union (array ($ subqueryUser , $ subqueryGroup ));
162
162
163
163
$ sql = $ this ->database ->select ()
164
+ ->distinct ()
164
165
->setIntegrityCheck (false )
165
- ->from (array ('i ' => 'item ' ), array ( ' sum ' => ' sum(i.sizebytes) ' , ' count ' => ' count(i.item_id) ' ) )
166
+ ->from (array ('i ' => 'item ' ))
166
167
->join (array ('i2f ' => 'item2folder ' ),
167
168
'( ' .$ this ->database ->getDB ()->quoteInto ('i2f.folder_id IN (?) ' , $ subSqlFolders ).'
168
169
OR i2f.folder_id = ' .$ folder ->getKey ().'
@@ -186,9 +187,14 @@ public function getSizeFiltered($folders, $userDao = null, $policy = 0)
186
187
'(
187
188
ip.item_id is not null or
188
189
ipg.item_id is not null) '
189
- );
190
+ )
191
+ ->group ('i.item_id ' );
190
192
}
191
193
194
+ $ sql = $ this ->database ->select ()
195
+ ->setIntegrityCheck (false )
196
+ ->from (array ('i ' => $ sql ), array ('sum ' => 'sum(i.sizebytes) ' , 'count ' => 'count(i.item_id) ' ));
197
+
192
198
$ row = $ this ->database ->fetchRow ($ sql );
193
199
$ folders [$ key ]->count = $ row ['count ' ];
194
200
$ folders [$ key ]->size = $ row ['sum ' ];
0 commit comments