@@ -348,6 +348,11 @@ class Database
348348
349349 protected bool $ filter = true ;
350350
351+ /**
352+ * @var array<string, bool>|null
353+ */
354+ protected ?array $ disabledFilters = [];
355+
351356 protected bool $ validate = true ;
352357
353358 protected bool $ preserveDates = false ;
@@ -813,17 +818,35 @@ public function disableFilters(): static
813818 *
814819 * @template T
815820 * @param callable(): T $callback
821+ * @param array<string>|null $filters
816822 * @return T
817823 */
818- public function skipFilters (callable $ callback ): mixed
824+ public function skipFilters (callable $ callback, ? array $ filters = null ): mixed
819825 {
820- $ initial = $ this ->filter ;
821- $ this ->disableFilters ();
826+ if (empty ($ filters )) {
827+ $ initial = $ this ->filter ;
828+ $ this ->disableFilters ();
829+
830+ try {
831+ return $ callback ();
832+ } finally {
833+ $ this ->filter = $ initial ;
834+ }
835+ }
836+
837+ $ previous = $ this ->filter ;
838+ $ previousDisabled = $ this ->disabledFilters ;
839+ $ disabled = [];
840+ foreach ($ filters as $ name ) {
841+ $ disabled [$ name ] = true ;
842+ }
843+ $ this ->disabledFilters = $ disabled ;
822844
823845 try {
824846 return $ callback ();
825847 } finally {
826- $ this ->filter = $ initial ;
848+ $ this ->filter = $ previous ;
849+ $ this ->disabledFilters = $ previousDisabled ;
827850 }
828851 }
829852
@@ -6625,6 +6648,10 @@ protected function decodeAttribute(string $filter, mixed $value, Document $docum
66256648 return $ value ;
66266649 }
66276650
6651+ if (!\is_null ($ this ->disabledFilters ) && isset ($ this ->disabledFilters [$ filter ])) {
6652+ return $ value ;
6653+ }
6654+
66286655 if (!array_key_exists ($ filter , self ::$ filters ) && !array_key_exists ($ filter , $ this ->instanceFilters )) {
66296656 throw new NotFoundException ("Filter \"{$ filter }\" not found for attribute \"{$ attribute }\"" );
66306657 }
0 commit comments