Problem/Motivation

As per #2976394: Allow Symfony 4.4 to be installed in Drupal 8, various things are failing with this deprecation:

 5x: Calling "Symfony\Component\HttpFoundation\Request::getSession()" when no session has been set is deprecated since Symfony 4.1 and will throw an exception in 5.0. Use "hasSession()" instead.
    5x in InstallerExistingConfigNoSystemSiteTest::testConfigSync from Drupal\FunctionalTests\Installer

Request::hasSession() seems to be available on the Request object in Symfony 3.4 so this seems fixable in a way where we are compatible with 3.4, 4 and 5 at the same time.

Proposed resolution

Use hasSession() where needed.

Remaining tasks

Do it.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

N/A

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Gábor Hojtsy created an issue. See original summary.

Gábor Hojtsy’s picture

Status: Active » Needs review
FileSize
2.02 KB

I *think* this is what we need here.

alexpott’s picture

Status: Needs review » Needs work

The fix looks good. However it looks like there's a couple more...
if (!$this->requestStack->getCurrentRequest()->getSession()) { in core/lib/Drupal/Core/Entity/EntityDeleteMultipleAccessCheck.php
if ($session = $request->getSession()) { in core/modules/comment/src/Controller/CommentController.php

Gábor Hojtsy’s picture

Status: Needs work » Needs review
FileSize
3.86 KB
1.84 KB

Indeed. I looked through a few of the other grep results that looked suspect but did not identify others. This will need the testing patch from #2976394: Allow Symfony 4.4 to be installed in Drupal 8 to prove this deprecation does not show up anymore.

Gábor Hojtsy’s picture

This is now combined with 2976394-118.patch from #2976394: Allow Symfony 4.4 to be installed in Drupal 8 for testing purposes. It will fail for other reasons that are still outstanding on the Symfony 4 compatibility side but should not have fails due to this one.

Status: Needs review » Needs work
alexpott’s picture

#5 seems good - looking at the test run.

Gábor Hojtsy’s picture

Status: Needs work » Needs review

The hasSession/getSession problem indeed does not show up anymore in the fails of #6 and fails compared to #2976394: Allow Symfony 4.4 to be installed in Drupal 8 are down by 37.

Gábor Hojtsy’s picture

Reuploading #5 which is the complete patch for this issue as demonstrated by #6.

alexpott’s picture

Status: Needs review » Reviewed & tested by the community

Nice that we don't have to add to \Drupal\Tests\Listeners\DeprecationListenerTrait::getSkippedDeprecations() here.

  • catch committed aaf13e2 on 8.7.x
    Issue #3029199 by Gábor Hojtsy, alexpott: [symfony 5] Calling "Symfony\...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed aaf13e2 and pushed to 8.7.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.