ID: 40016 User updated by: mbechler at eenterphace dot org Reported By: mbechler at eenterphace dot org Status: Open Bug Type: Session related Operating System: Any? PHP Version: 5.2.0 New Comment:
Have to correct me, it happens when register_long_arrays is Off (it was late last night, sorry :)) Previous Comments: ------------------------------------------------------------------------ [2007-01-04 02:23:30] mbechler at eenterphace dot org Description: ------------ When 'register_long_arrays' is enabled and a session variable is unset within a foreach loop over $_SESSION the session is not written out anymore, causing the changes to the session beeing lost. (session_unregister works nice btw.) Reproduced on various (patched and vanilla) 5.* (including 5.2.0) versions on GNU/Linux Some debugging showed that actually the internal pointer (in ps_globals' http_session_vars zval) to the session hashtable are wrecked when doing this so this seems not to be a ext/session issue but more of a core issue. ---- Dump in php_session_flush: gdb> print (*ps_globals.http_session_vars).value $5 = {lval = 0x5a5a5a5a, dval = 1.7838867517321418e+127, str = {val = 0x5a5a5a5a <Address 0x5a5a5a5a out of bounds>, len = 0x5a5a5a5a}, ht = 0x5a5a5a5a, obj = {handle = 0x5a5a5a5a, handlers = 0x5a5a5a5a}} Reproduce code: --------------- <?php session_start(); var_dump($_SESSION); $_SESSION['test'] = 'blubb'; $_SESSION['foo'] = 'test'; foreach($_SESSION as $key => $val) { unset($_SESSION['test']); } var_dump($_SESSION); ?> Expected result: ---------------- On first run: array(9) { } array(1) { ["foo"]=> string(4) "test" } On second run: array(1) { ["foo"]=> string(4) "test" } array(1) { ["foo"]=> string(4) "test" } Actual result: -------------- On every run: array(9) { } array(1) { ["foo"]=> string(4) "test" } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=40016&edit=1