@@ -992,7 +992,7 @@ public function updateDocument(Document $collection, string $id, Document $docum
992992 DELETE FROM {$ this ->getSQLTable ($ name . '_perms ' )}
993993 WHERE _document = :_uid
994994 {$ this ->getTenantQuery ($ collection )}
995- " ;
995+ " ;
996996
997997 $ sql = $ this ->trigger (Database::EVENT_PERMISSIONS_DELETE , $ sql );
998998
@@ -1003,10 +1003,12 @@ public function updateDocument(Document $collection, string $id, Document $docum
10031003 }
10041004
10051005 $ values = [];
1006+ $ binds = [];
10061007 foreach (Database::PERMISSIONS as $ type ) {
1007- foreach ($ document ->getPermissionsByType ($ type ) as $ i => $ _ ) {
1008+ foreach ($ document ->getPermissionsByType ($ type ) as $ i => $ permission ) {
10081009 $ tenantPlaceholder = $ this ->sharedTables ? ', :_tenant ' : '' ;
1009- $ values [] = "( :_uid, ' {$ type }', :_add_ {$ type }_ {$ i }{$ tenantPlaceholder }) " ;
1010+ $ values [] = "( :_uid, ' {$ type }', :_add_ {$ type }_ {$ i } {$ tenantPlaceholder }) " ;
1011+ $ binds [":_add_ {$ type }_ {$ i }" ] = $ permission ;
10101012 }
10111013 }
10121014
@@ -1020,17 +1022,13 @@ public function updateDocument(Document $collection, string $id, Document $docum
10201022 $ sql = $ this ->trigger (Database::EVENT_PERMISSIONS_CREATE , $ sql );
10211023
10221024 $ stmtAddPermissions = $ this ->getPDO ()->prepare ($ sql );
1023-
10241025 $ stmtAddPermissions ->bindValue (":_uid " , $ newUid );
1025-
10261026 if ($ this ->sharedTables ) {
10271027 $ stmtAddPermissions ->bindValue (":_tenant " , $ this ->tenant );
10281028 }
10291029
1030- foreach (Database::PERMISSIONS as $ type ) {
1031- foreach ($ document ->getPermissionsByType ($ type ) as $ i => $ permission ) {
1032- $ stmtAddPermissions ->bindValue (":_add_ {$ type }_ {$ i }" , $ permission );
1033- }
1030+ foreach ($ binds as $ key => $ permission ) {
1031+ $ stmtAddPermissions ->bindValue ($ key , $ permission );
10341032 }
10351033 }
10361034 }
0 commit comments