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

Only start the session if needed to find data in FORM_DATA #1471

Merged
merged 2 commits into from
Apr 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Resources/contao/library/Contao/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,14 @@ public static function findPost($strKey)
return $_POST[$strKey];
}

$request = System::getContainer()->get('request_stack')->getMasterRequest();

// Return if the session has not been started before
if ($request === null || !$request->hasPreviousSession())
{
return null;
}

if (isset($_SESSION['FORM_DATA'][$strKey]))
{
return ($strKey == 'FORM_SUBMIT') ? preg_replace('/^auto_/i', '', $_SESSION['FORM_DATA'][$strKey]) : $_SESSION['FORM_DATA'][$strKey];
Expand Down
8 changes: 8 additions & 0 deletions tests/Contao/WidgetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
namespace Contao\CoreBundle\Tests\Contao;

use Contao\Input;
use Contao\System;
use Contao\Widget;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpFoundation\RequestStack;

/**
* @group contao3
Expand Down Expand Up @@ -44,6 +47,11 @@ public function setUp(): void
parent::setUp();

\define('TL_MODE', 'FE');

$container = new ContainerBuilder();
$container->set('request_stack', new RequestStack());

System::setContainer($container);
}

/**
Expand Down