Problem/Motivation
We need to address some deprecated code that throws a SessionNotFoundException in Drupal 10 (as the result of updating Symfony).
Here's the deprecation:
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.
While updating the Features Permissions module for Drupal 10, I ran into this:
1) Drupal\Tests\features_permissions\Kernel\FeaturesCrudTest::testFeatureRevert
Symfony\Component\HttpFoundation\Exception\SessionNotFoundException: Session has not been set.
/var/www/html/vendor/symfony/http-foundation/Request.php:708
/var/www/html/web/modules/contrib/features/src/FeaturesAssigner.php:432
/var/www/html/web/modules/contrib/features/src/FeaturesAssigner.php:399
/var/www/html/web/modules/contrib/features/modules/features_ui/src/Form/FeaturesDiffForm.php:106
/var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php:534
/var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php:281
/var/www/html/web/modules/contrib/features_permissions/tests/src/Kernel/FeaturesCrudTest.php:49
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:728
Steps to reproduce
Features doesn't seem to have test coverage that catches this - at least when I run 5.0.x tests locally.
So.. run D10 tests at https://www.drupal.org/project/features_permissions/issues/3324858
Proposed resolution
Call Request::hasSession()
before Request::getSession()
.
Remaining tasks
Open MR
Review
Commit
User interface changes
None
API changes
None
Data model changes
None
Issue fork features-3324881
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
Chris Burge CreditAttribution: Chris Burge as a volunteer commentedTest failures appear unrelated to this MR. Development is blocked by #3324885: 5.0.x Branch Tests Failing.
Comment #4
Chris Burge CreditAttribution: Chris Burge as a volunteer commentedThe MR also uses dependency injection for the
request_stack
service in Features'features_assigner
service.Comment #6
Chris Burge CreditAttribution: Chris Burge as a volunteer commented