|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-01-08 02:53 UTC] ceeam at mail dot ru
This problem is absolutely critical if you do DB cleanups, transactions processing or other similar things in shutdown functions. Can be especially bad if you need to commit/rollback transactions with persistent DB connections.
----------
<?php
function boo()
{
...do_anything...; // never ever gets called
}
register_shutdown_function("boo");
set_time_limit(3); // not necessary, just to show the error sooner
for (;;) { // infinite loop to simulate long processing
}
?>
----------
Error message:
Fatal error: Maximum execution time of 3 seconds exceeded in c:\exp.php on line 10
Fatal error: Maximum execution time of 3 seconds exceeded in c:\exp.php on line 4
Does not depend on whether we run script as CGI/SAPI or CLI.
Report #14542 looks similar but is different IMHO.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 20:00:01 2025 UTC |
This script works just fine for me (using CLI): <?php error_log ("Start\n", 3, "test.log"); function boo() { error_log ("Shutdown - function 'foo'\n", 3, "test.log"); } register_shutdown_function("boo"); /* not necessary, just to show the error sooner */ set_time_limit(1); /* infinite loop to simulate long processing */ for (;;) {} error_log ("\nEnd\n", 3, "test.log"); ?> In test.log I have now: ----cut---- Start Shutdown - function 'foo' ----cut---- Which is the expected output. Can you try this script?compiled under cygwin [Xuefer php4]$ ./sapi/cli/php.exe -v PHP 4.3.5RC3-dev (cli) (built: Feb 13 2004 01:29:25) Copyright (c) 1997-2004 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies [Xuefer php4]$ make test ......... PASS Testing register_shutdown_function() [tests/func/005.phpt] <<- freeze here it's running 005a.phpt [Xuefer php4]$ sapi/cli/php -d max_execution_time=1 -r 'set_time_limit(1); for(;;) {}' [Xuefer php4]$ sapi/cli/php test/func/005a.phpt both is frozen