gh9583.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --TEST--
  2. GH-9583: session_create_id() fails with user defined save handler that doesn't have a validateId() method
  3. --EXTENSIONS--
  4. session
  5. --SKIPIF--
  6. <?php include('skipif.inc'); ?>
  7. --FILE--
  8. <?php
  9. class SessionHandlerTester implements \SessionHandlerInterface
  10. {
  11. public function close(): bool { return true; }
  12. public function destroy($id): bool { return true; }
  13. public function gc($max_lifetime): int|false { return 1; }
  14. public function open($path, $name): bool { return true; }
  15. public function read($id): string { return ''; }
  16. public function write($id, $data): bool { return true; }
  17. //public function create_sid() { return uniqid(); }
  18. //public function validateId($key) { return true; }
  19. }
  20. $obj = new SessionHandlerTester();
  21. ini_set('session.use_strict_mode','1');
  22. session_set_save_handler($obj);
  23. session_start();
  24. echo "\nvalidateId() ".(method_exists($obj,'validateId')?('returns '.($obj->validateId(1)?'true':'false')):'is commented out');
  25. echo "\n";
  26. $sessionId = session_create_id();
  27. echo "\nSession ID:".$sessionId;
  28. echo "\n";
  29. ?>
  30. --EXPECTF--
  31. validateId() is commented out
  32. Session ID:%s