@@ -1960,15 +1960,12 @@ public function deleteDocuments(string $collection, array $internalIds, array $p
19601960
19611961 try {
19621962 $ name = $ this ->filter ($ collection );
1963- $ where = [];
19641963
1965- if ($ this ->sharedTables ) {
1966- $ where [] = "_tenant = :_tenant " ;
1967- }
1968-
1969- $ where [] = "_id IN ( " . \implode (', ' , \array_map (fn ($ index ) => ":_id_ {$ index }" , \array_keys ($ internalIds ))) . ") " ;
1970-
1971- $ sql = "DELETE FROM {$ this ->getSQLTable ($ name )} WHERE " . \implode (' AND ' , $ where );
1964+ $ sql = "
1965+ DELETE FROM {$ this ->getSQLTable ($ name )}
1966+ WHERE _id IN ( " . \implode (', ' , \array_map (fn ($ index ) => ":_id_ {$ index }" , \array_keys ($ internalIds ))) . ")
1967+ {$ this ->getTenantQuery ($ collection )}
1968+ " ;
19721969
19731970 $ sql = $ this ->trigger (Database::EVENT_DOCUMENTS_DELETE , $ sql );
19741971
@@ -1989,19 +1986,16 @@ public function deleteDocuments(string $collection, array $internalIds, array $p
19891986 if (!empty ($ permissionIds )) {
19901987 $ sql = "
19911988 DELETE FROM {$ this ->getSQLTable ($ name . '_perms ' )}
1992- WHERE _document IN ( " . \implode (', ' , \array_map (fn ($ index ) => ":_pid_ {$ index }" , \array_keys ($ permissionIds ))) . ")
1993- " ;
1994-
1995- if ($ this ->sharedTables ) {
1996- $ sql .= ' AND _tenant = :_tenant ' ;
1997- }
1989+ WHERE _document IN ( " . \implode (', ' , \array_map (fn ($ index ) => ":_id_ {$ index }" , \array_keys ($ permissionIds ))) . ")
1990+ {$ this ->getTenantQuery ($ collection )}
1991+ " ;
19981992
19991993 $ sql = $ this ->trigger (Database::EVENT_PERMISSIONS_DELETE , $ sql );
20001994
20011995 $ stmtPermissions = $ this ->getPDO ()->prepare ($ sql );
20021996
20031997 foreach ($ permissionIds as $ id => $ value ) {
2004- $ stmtPermissions ->bindValue (":_pid_ {$ id }" , $ value );
1998+ $ stmtPermissions ->bindValue (":_id_ {$ id }" , $ value );
20051999 }
20062000
20072001 if ($ this ->sharedTables ) {
0 commit comments