-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Symfony version(s) affected: v4.3.4, 4.4.x-dev
Description
When _sf2_attributes
or _sf2_meta
is set to a string the following error occurs:
Argument 1 passed to Symfony\Component\HttpFoundation\Session\SessionBagProxy::initialize() must be of the type array, string given, called in vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php on line 460
To force the reproduction I used $_SESSION['_sf2_attributes'] = '';
, but it seems to happen when the session expires too.
How to reproduce
<?php
use App\Kernel;
use Symfony\Component\HttpFoundation\Request;
require dirname(__DIR__) . '/../config/bootstrap.php';
session_start();
$_SESSION['_sf2_attributes'] = '';
$kernel = new Kernel($_SERVER['APP_ENV'], (bool)$_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
Possible Solution
Updating NativeSessionStorage::loadSession to check first if is an array?
- $session[$key] = isset($session[$key]) ? $session[$key] : [];
+ $session[$key] = isset($session[$key]) && \is_array($session[$key]) ? $session[$key] : [];