Issue #3029199 by Gábor Hojtsy, alexpott: [symfony 5] Calling "Symfony\Component\HttpFoundation\Request::getSession()" when no session has been set is deprecated since Symfony 4.1

8.7.x
Nathaniel Catchpole 2019-01-30 10:31:17 +00:00
parent 6f7fe9b86b
commit aaf13e2338
4 changed files with 8 additions and 8 deletions

View File

@ -145,8 +145,8 @@ function install_drupal($class_loader, $settings = [], callable $callback = NULL
// next page.
if ($state['interactive']) {
// If a session has been initiated in this request, make sure to save it.
if ($session = \Drupal::request()->getSession()) {
$session->save();
if (\Drupal::request()->hasSession()) {
\Drupal::request()->getSession()->save();
}
if ($state['parameters_changed']) {
// Redirect to the correct page if the URL parameters have changed.
@ -657,8 +657,8 @@ function install_run_task($task, &$install_state) {
$url = Url::fromUri('base:install.php', ['query' => $install_state['parameters'], 'script' => '']);
$response = batch_process($url, clone $url);
if ($response instanceof Response) {
if ($session = \Drupal::request()->getSession()) {
$session->save();
if (\Drupal::request()->hasSession()) {
\Drupal::request()->getSession()->save();
}
// Send the response.
$response->send();

View File

@ -62,7 +62,7 @@ class EntityDeleteMultipleAccessCheck implements AccessInterface {
* Allowed or forbidden, neutral if tempstore is empty.
*/
public function access(AccountInterface $account, $entity_type_id) {
if (!$this->requestStack->getCurrentRequest()->getSession()) {
if (!$this->requestStack->getCurrentRequest()->hasSession()) {
return AccessResult::neutral();
}
$selection = $this->tempStore->get($account->id() . ':' . $entity_type_id);

View File

@ -42,7 +42,7 @@ class BigPipeController {
// the cookie was already set, yet the user is executing this controller;
// - there is no session, in which case BigPipe is not enabled anyway, so it
// is pointless to set this cookie.
if ($request->cookies->has(BigPipeStrategy::NOJS_COOKIE) || $request->getSession() === NULL) {
if ($request->cookies->has(BigPipeStrategy::NOJS_COOKIE) || !$request->hasSession()) {
throw new AccessDeniedHttpException();
}

View File

@ -152,8 +152,8 @@ class CommentController extends ControllerBase {
$subrequest_url = $entity->toUrl()->setOption('query', ['page' => $page])->toString(TRUE);
$redirect_request = Request::create($subrequest_url->getGeneratedUrl(), 'GET', $request->query->all(), $request->cookies->all(), [], $request->server->all());
// Carry over the session to the subrequest.
if ($session = $request->getSession()) {
$redirect_request->setSession($session);
if ($request->hasSession()) {
$redirect_request->setSession($request->getSession());
}
$request->query->set('page', $page);
$response = $this->httpKernel->handle($redirect_request, HttpKernelInterface::SUB_REQUEST);