Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary Policy Checks with Multi Tenancy #14830

Open
wannesmatthys opened this issue Nov 18, 2024 · 1 comment
Open

Unnecessary Policy Checks with Multi Tenancy #14830

wannesmatthys opened this issue Nov 18, 2024 · 1 comment
Labels

Comments

@wannesmatthys
Copy link

wannesmatthys commented Nov 18, 2024

Package

filament/filament

Package Version

v3.2.124

Laravel Version

v11.32.0

Livewire Version

v3.5.12

PHP Version

PHP 8.3.3

Problem description

When we have multiple teams, filament always does a check of the policies for every team instead of only for the current team. In large applications with lots of teams this can slow down the application a bit.

So for example, here I have a simple filament dashboard with only one Resource "Posts". If I have one Team, this is the output for the Gates in debugbar.
image

When registering a new Team, it loads the policies (of the navigation?) multiple times.

With 2 teams:
image

With 3 teams:
image

And so on

Expected behavior

It should only load the correct policies once.

Steps to reproduce

Clone the repository, create a couple of teams and check the debugbar. Everytime you add a new team, the "Gates" will increase in debugbar.

Reproduction repository (issue will be closed if this is not valid)

https://github.com/wannesmatthys/filament-gates-reproduction

Relevant log output

No response

Donate 💰 to fund this issue

  • You can donate funding to this issue. We receive the money once the issue is completed & confirmed by you.
  • 100% of the funding will be distributed between the Filament core team to run all aspects of the project.
  • Thank you in advance for helping us make maintenance sustainable!
Fund with Polar
@wannesmatthys
Copy link
Author

I'm debugging this further, and apparently to generate all the tenant URL's (see photo), it calls

$this->navigationManager = new NavigationManager;
$navigation = $this->navigationManager->get();

in the file HasRoutes.php (line 194). This loads all navigation items (and policies) for every tenant.

Would there be another way to generate this URL maybe?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

1 participant