Problem/Motivation
The RFC https://wiki.php.net/rfc/deprecations_php_8_4#sessionsid_length_and_sess...
Symfony https://github.com/symfony/symfony/pull/57805
In other words changing the default values will either generate session IDs that raise eyebrows (4 bits per character with less than 32 characters or 5 bpc for less than 26 characters) or generate session IDs that are needlessly strong, increasing CPU costs, due to the additional randomness required, and increasing the chance for interoperability problems, such as the mod_security example.
For this reason we propose to deprecate the two INI settings in favor of the opinionated choice of the current defaults of a 32 character hexadecimal session ID.
The hexadecimal character set is not expected to cause any interoperability issues, as it is the most limited one of the currently available ones and hexadecimal identifiers are likely the most commonly used. While this would increase the length of the session ID from the previous minimum of 22 characters (which is a secure choice when combined with 6 bits per character) to 32, we do not expect this to be an issue in practice. The difference in traffic is minimal and a hexadecimal session ID is trivially packed into a 16 Byte binary string using hex2bin(), should storage requirements of the session backend be a concern.
Steps to reproduce
core$ git grep sid_length
core/assets/scaffold/files/default.services.yml:57: sid_length: 48
core/core.services.yml:18: sid_length: 48
core/lib/Drupal/Core/Session/SessionConfiguration.php:28: // Provide sensible defaults for sid_length, sid_bits_per_character and
core/lib/Drupal/Core/Session/SessionConfiguration.php:32: 'sid_length' => 48,
core/tests/Drupal/Tests/Core/Session/SessionConfigurationTest.php:269: public function testConstructorDefaultSettings(array $options, int $expected_sid_length, int $expected_sid_bits_per_character, string $expected_name_suffix): void {
core/tests/Drupal/Tests/Core/Session/SessionConfigurationTest.php:272: $this->assertSame($expected_sid_length, $options['sid_length']);
core/tests/Drupal/Tests/Core/Session/SessionConfigurationTest.php:286: [['sid_length' => 100], 100, 6, ''],
core/tests/Drupal/Tests/Core/Session/SessionConfigurationTest.php:289: [['sid_length' => 100, 'sid_bits_per_character' => 5, 'name_suffix' => 'some-suffix'], 100, 5, 'some-suffix'],
sites/default/default.services.yml:57: sid_length: 48
core$ git grep sid_bits_per_character
core/assets/scaffold/files/default.services.yml:66: sid_bits_per_character: 6
core/core.services.yml:19: sid_bits_per_character: 6
core/lib/Drupal/Core/Session/SessionConfiguration.php:28: // Provide sensible defaults for sid_length, sid_bits_per_character and
core/lib/Drupal/Core/Session/SessionConfiguration.php:33: 'sid_bits_per_character' => 6,
core/tests/Drupal/Tests/Core/Session/SessionConfigurationTest.php:269: public function testConstructorDefaultSettings(array $options, int $expected_sid_length, int $expected_sid_bits_per_character, string $expected_name_suffix): void {
core/tests/Drupal/Tests/Core/Session/SessionConfigurationTest.php:273: $this->assertSame($expected_sid_bits_per_character, $options['sid_bits_per_character']);
core/tests/Drupal/Tests/Core/Session/SessionConfigurationTest.php:287: [['sid_bits_per_character' => 5], 48, 5, ''],
core/tests/Drupal/Tests/Core/Session/SessionConfigurationTest.php:289: [['sid_length' => 100, 'sid_bits_per_character' => 5, 'name_suffix' => 'some-suffix'], 100, 5, 'some-suffix'],
sites/default/default.services.yml:66: sid_bits_per_character: 6
Proposed resolution
discuss how to prevent using deprecated code
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3465836
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:
- 3465836-php-8.4-session.sidlength
changes, plain diff MR !9266
Comments
Comment #2
andypostAdded https://github.com/symfony/symfony/pull/57805
Comment #4
andypostComment #5
andypostAdded CR and it's a blocker for 8.4 adoption, the same as related #3465827: Stop passing E_USER_ERROR to trigger_error() on PHP 8.4
Comment #6
andypostAdditionally deprecated
session.use_only_cookies,session.use_trans_sidandsession.referer_checkvia https://wiki.php.net/rfc/deprecate-get-post-sessionshttps://github.com/php/php-src/commit/c5bce0d8a2e6794cd6809e4047dd1f488f...
Comment #7
smustgrave commentedThought about if we would need some kind of comment or deprecation message but since we probably don't know the php requirement for D12 figured when the time comes we would search for
Comment #10
catchCommitted/pushed to 11.x and cherry-picked to 10.4.x, thanks!
Looks fine to me for a quick fix for 8.4 compatibility, opened a follow-up for removing/deprecating these from services.default.yml #3471199: Remove sid_length and sid_bits_per_character deprecation from CoreServiceProvider.