1--TEST-- 2GH-12504 (Corrupted session written when there's a fatal error in autoloader) 3--EXTENSIONS-- 4session 5--FILE-- 6<?php 7 8class TestSessionHandler implements SessionHandlerInterface 9{ 10 public function close(): bool 11 { 12 return true; 13 } 14 public function destroy(string $id): bool 15 { 16 return true; 17 } 18 public function gc(int $max_lifetime): int|false 19 { 20 return 0; 21 } 22 public function open(string $path, string $name): bool 23 { 24 return true; 25 } 26 public function read(string $id): string|false 27 { 28 // Return a session object that has 3 variables 29 return 'before|i:1234;test|O:4:"Test":0:{}after|i:5678;'; 30 } 31 public function write($id, $data): bool 32 { 33 echo 'Write session:' . PHP_EOL; 34 echo $data . PHP_EOL; 35 return true; 36 } 37} 38 39register_shutdown_function(function() { 40 echo "In shutdown function\n"; 41 var_dump($_SESSION); 42}); 43 44session_set_save_handler(new TestSessionHandler()); 45 46// Autoload class that's in session 47spl_autoload_register(function() { 48 // Easiest way to reproduce the issue is to dynamically define a class with a bogus definition 49 eval('class Test {public int $var = null;}'); 50 return true; 51}); 52 53session_start(); 54 55?> 56--EXPECTF-- 57Fatal error: Default value for property of type int may not be null. Use the nullable type ?int to allow null default value in %s on line %d 58 59Warning: Unknown: Failed to decode session object. Session has been destroyed in Unknown on line 0 60In shutdown function 61array(0) { 62} 63