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

PathTenantResolver does not forget the tenant route parameter when resolving from cache #1174

Closed
piotrjoniec opened this issue Dec 21, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@piotrjoniec
Copy link

Bug description

https://github.com/archtechx/tenancy/blob/0b248f937dd4799aa42ecdbd2fc73c05ddb943bb/src/Resolvers/PathTenantResolver.php#L30C28-L30C28

Steps to reproduce

Set PathTenantResolver::$shouldCache = true;

Expected behavior

Expected: The tenant route parameter should always be forgotten.
Actual: The tenant route parameter is only forgotten on the initial request. Cached requests fail, because of a controller method parameter mismatch.

Laravel version

10.37.3

stancl/tenancy version

3.7.2

@piotrjoniec piotrjoniec added the bug Something isn't working label Dec 21, 2023
@stancl
Copy link
Member

stancl commented Jan 16, 2024

Hey, sorry for getting to this late.

Does adding this to the resolver fix the issue for you?

public function resolved(Tenant $tenant, ...$args): void
{
    $route = $args[0];

    $route->forgetParameter(static::$tenantParameterName);
}

@piotrjoniec
Copy link
Author

@stancl Yes, this fixes the problem.

@stancl stancl closed this as completed in 8db27a3 Jan 27, 2024
@stancl
Copy link
Member

stancl commented Jan 27, 2024

Thanks a lot for reporting this and testing the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants