Commit aaf13e23 authored by catch's avatar catch
Browse files

Issue #3029199 by Gábor Hojtsy, alexpott: [symfony 5] Calling...

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
parent 6f7fe9b8
......@@ -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();
......
......@@ -62,7 +62,7 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Pri
* 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);
......
......@@ -42,7 +42,7 @@ public function setNoJsCookie(Request $request) {
// 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();
}
......
......@@ -152,8 +152,8 @@ public function commentPermalink(Request $request, CommentInterface $comment) {
$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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment