PHP Bugs  
php.net | support | documentation | report a bug | advanced search | search howto | statistics | login

go to bug id or search bugs for  

Bug #20447 Register_shutdown_function - connection still open while registered shutdown...
Submitted:15 Nov 2002 10:32am UTC Modified: 27 Aug 2004 11:02am UTC
From:richardz at omniture dot com Assigned to:
Status:Closed Category:Documentation problem
Version:4.2.3 OS:RedHat 7.2
Votes:32 Avg. Score:4.6 ± 0.9 Reproduced:30 of 30 (100.0%)
Same Version:7 (23.3%) Same OS:10 (33.3%)
View/Vote Developer Edit Submission

[15 Nov 2002 10:32am UTC] richardz at omniture dot com
My problem is that the connection to the browser is still open while the
registered shutdown functions are executing.  The documentation says
that from the registered shutdown functions you WON'T be able to echo or
print or modify the contents of the buffer. I can...

Example:
using apache 1.3.27
php version 4.2.3
//////////////////////////////////////////////
<?
function doThing(){
     for($i=0;$i<100000;$i++){
          //just looping to demonstrate that the page hangs while
executing this function
     }
     echo "PHP documentation says I shouldn't see this in my browser";
}
register_shutdown_function('doThing');

?>
<html>
Test Page.
<br><br>
</html>
////////////////////////////////////////////

I was hoping to register shutdown functions to do some cleanup - without
affecting the load time of the site.  Apparently these functions don't
work that way?
[16 Jan 2003 12:14pm UTC] firewire at itsyourdomain dot com
I to have run across this problem. I was hoping to use a registered
shutdown function to do some final fairly slow socket processing that
the client didn't need to see. My test case is as follows:

register_shutdown_function('sd');

function sd()
{
  echo "I shouldn't be seen";
  sleep(5);
}

Causes the browser to echo text then sleep for 5 seconds before
completing the page. I also agree that the manual is incorrect. Is there
another way to force php to close the output stream so slower non user
related functions can be executed?
[4 May 2003 2:31am UTC] spic@php.net
Is this a documentation problem or a php-bug?

According to some users the documented behaviour worked under PHP <
4.1.0, but now the function behaves differently.

Could someone please check this?
[10 Aug 2003 9:24pm UTC] iliaa@php.net
This is a documtation problem.

Under certain condition you may infact be able to output data to the
browser from inside the register_shutdown_function handler.
[20 Nov 2003 5:09pm UTC] gabe at websaviour dot com
Could you elaborate on that please?  I am experiencing 
the bug in PHP 4.3.0 and Apache 1.3.27 on OS X, 10.2.8, 
as well as PHP 4.1.2 on Apache 1.3.22 on Red Hat Linux.

Under what conditions will it work?  I need this 
function to work as advertised to perform some time-
consuming tasks in the background and let the user move 
on.  Since this is pretty much the only way to achieve 
anything approaching asynchronous processing in the 
Apache PHP environment it seems fairly important.
[18 Mar 2004 4:02am UTC] php at mcking dot nl
I tested this on a system with:
OS: Fedora Linux Core 1
Apache version: 2.0.48-1.2
PHP version: 4.3.4-1.1

And the connection to the browser was still open. So the bug isn't
solved yet!
[25 Jun 2004 2:33pm UTC] mail at spybreak dot de
I'm really interested myself under which conditions a script still can
output data to the client using register_shutdown_function(). If this is
a documentation problem, how's this really supposed to work?
[25 Jun 2004 2:33pm UTC] mail at spybreak dot de
I'm really interested myself under which conditions a script still can
output data to the client using register_shutdown_function(). If this is
a documentation problem, how's this really to work?
[26 Aug 2004 5:47am UTC] lox at gecka dot com
I will be nice to repair this function guys. 
The behavior descibed in the documentation is the one we need.
[26 Aug 2004 11:54am UTC] vrana@php.net
register_shutdown_function() will not probably change back so I filled
feature request for such a function:
http://bugs.php.net/bug.php?id=29846

Conditions for when output can be written from
register_shutdown_function() still have to be documented.
[27 Aug 2004 11:02am UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation
better.

"In PHP 4.0.6 and earlier under Apache, the registered shutdown
functions are called after the request has been completed. Since PHP
4.1, the shutdown functions are called as the part of the request so
that it's possible to send the output from them. There is currently no
way to process the data after the request has been completed."

RSS feed | show source 

PHP Copyright © 2001-2009 The PHP Group
All rights reserved.
Last updated: Sat Nov 21 10:30:49 2009 UTC