@@ -316,49 +316,25 @@ protected function configure()
316316 /**
317317 * Configure session ID length
318318 *
319- * To make life easier, we used to force SHA-1 and 4 bits per
320- * character on everyone. And of course, someone was unhappy.
321- *
322- * Then PHP 7.1 broke backwards-compatibility because ext/session
323- * is such a mess that nobody wants to touch it with a pole stick,
324- * and the one guy who does, nobody has the energy to argue with.
325- *
326- * So we were forced to make changes, and OF COURSE something was
327- * going to break and now we have this pile of shit. -- Narf
319+ * To make life easier, we force the PHP defaults. Because PHP9 forces them.
320+ * See https://wiki.php.net/rfc/deprecations_php_8_4#sessionsid_length_and_sessionsid_bits_per_character
328321 */
329322 protected function configureSidLength ()
330323 {
331- $ bitsPerCharacter = (int ) (ini_get ('session.sid_bits_per_character ' ) !== false
332- ? ini_get ('session.sid_bits_per_character ' )
333- : 4 );
334-
335- $ sidLength = (int ) (ini_get ('session.sid_length ' ) !== false
336- ? ini_get ('session.sid_length ' )
337- : 40 );
338-
339- if (($ sidLength * $ bitsPerCharacter ) < 160 ) {
340- $ bits = ($ sidLength * $ bitsPerCharacter );
341- // Add as many more characters as necessary to reach at least 160 bits
342- $ sidLength += (int ) ceil ((160 % $ bits ) / $ bitsPerCharacter );
343- ini_set ('session.sid_length ' , (string ) $ sidLength );
344- }
324+ $ bitsPerCharacter = (int ) ini_get ('session.sid_bits_per_character ' );
325+ $ sidLength = (int ) ini_get ('session.sid_length ' );
345326
346- // Yes, 4,5,6 are the only known possible values as of 2016-10-27
347- switch ($ bitsPerCharacter ) {
348- case 4 :
349- $ this ->sidRegexp = '[0-9a-f] ' ;
350- break ;
351-
352- case 5 :
353- $ this ->sidRegexp = '[0-9a-v] ' ;
354- break ;
355-
356- case 6 :
357- $ this ->sidRegexp = '[0-9a-zA-Z,-] ' ;
358- break ;
327+ // We force the PHP defaults.
328+ if (PHP_VERSION_ID < 90000 ) {
329+ if ($ bitsPerCharacter !== 4 ) {
330+ ini_set ('session.sid_bits_per_character ' , '4 ' );
331+ }
332+ if ($ sidLength !== 32 ) {
333+ ini_set ('session.sid_length ' , '32 ' );
334+ }
359335 }
360336
361- $ this ->sidRegexp . = '{ ' . $ sidLength . ' } ' ;
337+ $ this ->sidRegexp = '[0-9a-f]{32 } ' ;
362338 }
363339
364340 /**
0 commit comments