Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#10 | 3029199-5.patch | 3.86 KB | Gábor Hojtsy |
#6 | 3029199-5-combined-with-2976394-118-for-testing.patch | 157.7 KB | Gábor Hojtsy |
#5 | interdiff.txt | 1.84 KB | Gábor Hojtsy |
#5 | 3029199-5.patch | 3.86 KB | Gábor Hojtsy |
#3 | 3029199-3.patch | 2.02 KB | Gábor Hojtsy |
Comments
Comment #2
Gábor HojtsyComment #3
Gábor HojtsyI *think* this is what we need here.
Comment #4
alexpottThe fix looks good. However it looks like there's a couple more...
if (!$this->requestStack->getCurrentRequest()->getSession()) {
in core/lib/Drupal/Core/Entity/EntityDeleteMultipleAccessCheck.phpif ($session = $request->getSession()) {
in core/modules/comment/src/Controller/CommentController.phpComment #5
Gábor HojtsyIndeed. 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.
Comment #6
Gábor HojtsyThis 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.
Comment #8
alexpott#5 seems good - looking at the test run.
Comment #9
Gábor HojtsyThe 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.
Comment #10
Gábor HojtsyReuploading #5 which is the complete patch for this issue as demonstrated by #6.
Comment #11
alexpottNice that we don't have to add to \Drupal\Tests\Listeners\DeprecationListenerTrait::getSkippedDeprecations() here.
Comment #13
catchCommitted aaf13e2 and pushed to 8.7.x. Thanks!