From: jason at thinkingman dot org Operating system: Win32 PHP version: 4.3.5RC3 PHP Bug Type: Feature/Change Request Bug description: set_time_limit() & register_shutdown_function()
Description: ------------ Hi I'd like to propose a modification to the SET_TIME_LIMIT() and/or the REGISTER_SHUTDOWN_FUNCTION() or perhaps, the creation of a related new function. Currently when a page goes to timeout, all buffers get flushed, and all headers get sent. In the interest of handling timeouts better; it would be ** GREAT ** if instead of all this flushing and finalization occuring, if one could also choose to not have the current script flush and finalize; but to remain in the script as if no timeout occurred at all. This way, when a timeout occurs one can (for example) do redirects, or choose to manually flush and clear buffers, allowing for cleaner INCLUDE implimentations, and so on. I'm thinking something like the following could be implimented: set_time_limit(300, true); Where 'true' means; don't end script; just kick event off stating that timeout has occurred; allowing register_shutdown_function() to be called, if defined... and continuing normal operation of script. void set_time_limit ( int seconds, [bool: event notify only]); default = false. // code example: <? set_time_limit(300, true); define("NORMAL", 0); define("ABORTED", 1); define("TIMEOUT", 2); function onShutdownEvent() { switch(connection_status()) { case NORMAL: // code normal exit. break; case ABORTED: // code aborted exit. break; case TIMEOUT: header("location: http://timeout.php"); exit; break; } } register_shutdown_function('onShutdownEvent'); while(1); ?> Another example of the TIMEOUT switch might be: case TIMEOUT: while(ob_get_level) ob_end_clean(); if($dblink) mysql_close($dblink); include('./header.html'); include('error.php'); include('./footer.html'); exit; break; Thanks, Jason -- Edit bug report at http://bugs.php.net/?id=27297&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27297&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27297&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=27297&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=27297&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=27297&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=27297&r=needscript Try newer version: http://bugs.php.net/fix.php?id=27297&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=27297&r=support Expected behavior: http://bugs.php.net/fix.php?id=27297&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=27297&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=27297&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=27297&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27297&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=27297&r=dst IIS Stability: http://bugs.php.net/fix.php?id=27297&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=27297&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=27297&r=float