@@ -201,10 +201,12 @@ public function addShareSource(ShareAccessContext $accessContext, string $id, Sh
201201 throw new ShareInvalidException ('Invalid source: ' . $ source ->value . ' ' . $ source ->class , $ this ->l10n ->t ('The source does not exist. ' ));
202202 }
203203
204- $ share = $ this ->getShare ($ accessContext , $ id , $ backend );
205- $ sources = $ share ->sources ;
206- $ sources [] = $ source ;
207- $ this ->validateInteraction ($ accessContext , $ owner , $ sources , $ share ->getEnabledPermissions (), $ share ->recipients );
204+ if (!$ accessContext ->overrideChecks ) {
205+ $ share = $ this ->getShare ($ accessContext , $ id , $ backend );
206+ $ sources = $ share ->sources ;
207+ $ sources [] = $ source ;
208+ $ this ->validateInteraction ($ accessContext , $ owner , $ sources , $ share ->getEnabledPermissions (), $ share ->recipients );
209+ }
208210
209211 $ backend ->addShareSource ($ id , $ source );
210212 }
@@ -277,10 +279,12 @@ public function addShareRecipient(ShareAccessContext $accessContext, string $id,
277279 throw new ShareInvalidException ('Invalid recipient: ' . $ recipient ->value . ' ' . $ recipient ->class . ' ' . ($ recipient ->instance ?? 'local ' ), $ this ->l10n ->t ('The recipient does not exist. ' ));
278280 }
279281
280- $ share ??= $ this ->getShare ($ accessContext , $ id , $ backend );
281- $ recipients = $ share ->recipients ;
282- $ recipients [] = $ recipient ;
283- $ this ->validateInteraction ($ accessContext , $ owner , $ share ->sources , $ share ->getEnabledPermissions (), $ recipients );
282+ if (!$ accessContext ->overrideChecks ) {
283+ $ share ??= $ this ->getShare ($ accessContext , $ id , $ backend );
284+ $ recipients = $ share ->recipients ;
285+ $ recipients [] = $ recipient ;
286+ $ this ->validateInteraction ($ accessContext , $ owner , $ share ->sources , $ share ->getEnabledPermissions (), $ recipients );
287+ }
284288
285289 $ backend ->addShareRecipient ($ id , $ currentUser , $ recipient );
286290 }
@@ -423,12 +427,12 @@ public function updateSharePermission(ShareAccessContext $accessContext, string
423427 throw new RuntimeException ('The permission type is not registered: ' . $ permission ->class );
424428 }
425429
426- $ share = $ this -> getShare ( $ accessContext, $ id , $ backend );
427-
428- $ permissions = $ share ->permissions ;
429- $ permissions [$ permission ->class ] = $ permission ;
430-
431- $ this -> validateInteraction ( $ accessContext , $ owner , $ share -> sources , array_filter ( $ permissions , static fn ( SharePermission $ permission ): bool => $ permission -> enabled ), $ share -> recipients );
430+ if (! $ accessContext-> overrideChecks ) {
431+ $ share = $ this -> getShare ( $ accessContext , $ id , $ backend );
432+ $ permissions = $ share ->permissions ;
433+ $ permissions [$ permission ->class ] = $ permission ;
434+ $ this -> validateInteraction ( $ accessContext , $ owner , $ share -> sources , array_filter ( $ permissions , static fn ( SharePermission $ permission ): bool => $ permission -> enabled ), $ share -> recipients );
435+ }
432436
433437 $ backend ->updateSharePermission ($ id , $ permission );
434438
0 commit comments