-
Notifications
You must be signed in to change notification settings - Fork 297
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
UrlGenerator warming up issue #809
Comments
@nunomaduro Just a kindly reminder - this is the issue we discussed on #784 (comment) |
Thank you for reporting this issue! As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub. If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team. Thank you! |
I've been able to replicate this issue, and its definitely a bug in source |
@Velizz Thank you for confirming its a bug! |
Would greatly appreciate any help figuring this one out. |
I'm not sure it could be useful, but I added a failing test #869 for this. As described in PR, it has another problem |
Thanks @gazzoy |
@gazzoy in your demo app you aren't returning the user inside your Route::bind() closure. I think this could be the cause of your issue? Let me know. |
This issue might also be caused by a stale container reference like #887. I'll try to verify on my experimental branch when I have time. |
I was wrong, the
Doing so requires additional changes in On a sidenote: Visiting the |
More specifically, it would be necessary to bind the state of the It would probably be hard to get such a PR merged since the changes are necessary in |
I opened #896 which should fix this issue... hopefully this gets merged soon, while it's not merged you guys can bring this to your codebase by creating this file: class CreateUrlSandbox
{
public function handle($event): void
{
$event->sandbox->instance('url', clone $event->sandbox['url']);
}
} and add to your octane config: RequestReceived::class => [
...Octane::prepareApplicationForNextOperation(),
...Octane::prepareApplicationForNextRequest(),
CreateUrlSandbox::class,
], |
I can confirm #896 fix this issue. In addition to put
protected function redirectTo(Request $request): ?string
{
- return $request->expectsJson() ? null : route('sample.login');
+ $user = $request->route()->parameters()['user'];
+ return $request->expectsJson() ? null : route('sample.login', ['user' => $user]);
} |
Octane Version
2.2.7
Laravel Version
10.40.0
PHP Version
8.2.14
What server type are you using?
Swoole
Server Version
5.1.1
Database Driver & Version
No response
Description
Same as #784, #748.
When using
Route::bind()
andURL::defaults()
with Octane, it seems thatUrlGenerator
keeps the same instance ofRouteUrlGenerator
, and so the defaults are cached between requests.Especially, I believe the issue happens when we use
App\Http\Middleware\Authenticate
to handle login sessions.Steps To Reproduce
I created a public repo gazzoy/laravel-octane-urlgenerator-issue with a fresh Laravel v10.40.0, Octane v2.2.7(swoole), Sail v1.27.0(php8.2), and the smallest code to reproduce the issue.
gazzoy/laravel-octane-urlgenerator-issue/.env
.open your browser with:
http://localhost/sample/paul/login
It should show a page with a text "login page for paul" which is expected.
open below url on the same browser:
http://localhost/sample/john/home
It redirects to
http://localhost/sample/paul/login
which doesn't make sense to me. Because, as of I understood, ifRoute::bind()
andURL::defaults()
work fine, we should be redirected tohttp://localhost/sample/john/login
. Thefore, I believe it seems URL::defaults() keeps it states?Having said that, I'm not too sure its actually Octane issue, so please let me know if this is not the case.
Just to clarify, my public repo has 3 commits as follows, but the first and second commits were just installing Laravel and Octane so you should be able to ignore it. The third commit is actually my original code to reproduce the issue.
Please let me know if you have any questions.
The text was updated successfully, but these errors were encountered: