bug32330.phpt 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. --TEST--
  2. Bug #32330 (session_destroy, "Failed to initialize storage module", custom session handler)
  3. --EXTENSIONS--
  4. session
  5. --SKIPIF--
  6. <?php include('skipif.inc'); ?>
  7. --INI--
  8. session.use_trans_sid=0
  9. session.use_cookies=1
  10. session.name=sid
  11. session.save_path="{TMP}"
  12. session.gc_probability=1
  13. session.gc_divisor=1
  14. session.save_handler=files
  15. --FILE--
  16. <?php
  17. error_reporting(E_ALL);
  18. function sOpen($path, $name)
  19. {
  20. echo "open: path = {$path}, name = {$name}\n";
  21. return TRUE;
  22. }
  23. function sClose()
  24. {
  25. echo "close\n";
  26. return TRUE;
  27. }
  28. function sRead($id)
  29. {
  30. echo "read: id = {$id}\n";
  31. return '';
  32. }
  33. function sWrite($id, $data)
  34. {
  35. echo "write: id = {$id}, data = {$data}\n";
  36. return TRUE;
  37. }
  38. function sDestroy($id)
  39. {
  40. echo "destroy: id = {$id}\n";
  41. return TRUE;
  42. }
  43. function sGC($maxlifetime)
  44. {
  45. echo "gc: maxlifetime = {$maxlifetime}\n";
  46. return TRUE;
  47. }
  48. session_set_save_handler( 'sOpen', 'sClose', 'sRead', 'sWrite', 'sDestroy', 'sGC' );
  49. // without output buffering, the debug messages will cause all manner of warnings
  50. ob_start();
  51. session_start();
  52. $_SESSION['A'] = 'B';
  53. session_write_close();
  54. session_start();
  55. $_SESSION['C'] = 'D';
  56. session_destroy();
  57. session_start();
  58. $_SESSION['E'] = 'F';
  59. // Don't try to destroy this time!
  60. ?>
  61. --EXPECTF--
  62. open: path = %s, name = sid
  63. read: id = %s
  64. gc: maxlifetime = %d
  65. write: id = %s, data = A|s:1:"B";
  66. close
  67. open: path = %s, name = sid
  68. read: id = %s
  69. gc: maxlifetime = %d
  70. destroy: id = %s
  71. close
  72. open: path = %s, name = sid
  73. read: id = %s
  74. gc: maxlifetime = %d
  75. write: id = %s, data = E|s:1:"F";
  76. close