bug32330.phpt 1.5 KB

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