Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-clear the session form data (see #1389).
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of Contao. | ||
* | ||
* (c) Leo Feyer | ||
* | ||
* @license LGPL-3.0-or-later | ||
*/ | ||
|
||
namespace Contao\CoreBundle\EventListener; | ||
|
||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent; | ||
|
||
class ClearFormDataListener | ||
{ | ||
/** | ||
* Clear the Contao form data if not a POST request. | ||
* | ||
* @param FilterResponseEvent $event | ||
*/ | ||
public function onKernelResponse(FilterResponseEvent $event): void | ||
{ | ||
if (!$event->isMasterRequest()) { | ||
return; | ||
} | ||
|
||
$request = $event->getRequest(); | ||
|
||
if ($request->isMethod('POST')) { | ||
return; | ||
} | ||
|
||
if (null === ($session = $request->getSession()) || !$session->isStarted()) { | ||
return; | ||
} | ||
|
||
unset($_SESSION['FORM_DATA']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters