diff options
| author | Bert Koorengevel <BertKoor@users.noreply.github.com> | 2026-02-09 19:55:45 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-09 18:55:45 +0000 |
| commit | d371bd1b73ac6ee722f48a9a7a6bdebf8002bf13 (patch) | |
| tree | 8bac58aae09b9cfdc670259cf840770b87ae9e77 | |
| parent | 4e418e7a5a92798abecbbd5cab699c72173c80b0 (diff) | |
| download | webtrees-d371bd1b73ac6ee722f48a9a7a6bdebf8002bf13.tar.gz webtrees-d371bd1b73ac6ee722f48a9a7a6bdebf8002bf13.tar.bz2 webtrees-d371bd1b73ac6ee722f48a9a7a6bdebf8002bf13.zip | |
when logging out the homepage is fetched twice (#5160)
* fix #5153: When logging out the homepage is fetched twice.
The logout request handler may respond with a simple 204-NoContent.
The originating view already contains redirection.
As reported on the forum, some servers don't cope well.
* fix #5153 updated: chose whether to respond with empty response or redirection
Check whether header 'X-Requested-With' is not empty, similar as done in HandleExceptions.php
so actual value of the header may change and not affect this behaviour.
| -rw-r--r-- | app/Http/RequestHandlers/Logout.php | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/app/Http/RequestHandlers/Logout.php b/app/Http/RequestHandlers/Logout.php index 53f5e87a3c..295a4f1ad6 100644 --- a/app/Http/RequestHandlers/Logout.php +++ b/app/Http/RequestHandlers/Logout.php @@ -30,6 +30,7 @@ use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; use function redirect; +use function response; use function route; final class Logout implements RequestHandlerInterface @@ -44,6 +45,12 @@ final class Logout implements RequestHandlerInterface FlashMessages::addMessage(I18N::translate('You have signed out.')); } - return redirect(route(HomePage::class)); + if ($request->getHeaderLine('X-Requested-With') !== '') { + // Ajax request - send empty response + return response(); + } else { + // Form submission - redirect to home page + return redirect(route(HomePage::class)); + } } } |
