php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22401 ob_start callback function isn't called when script exceeds max_execution_time
Submitted: 2003-02-24 13:07 UTC Modified: 2004-02-16 01:19 UTC
Votes:12
Avg. Score:4.5 ± 0.8
Reproduced:10 of 11 (90.9%)
Same Version:7 (70.0%)
Same OS:7 (70.0%)
From: php at andyuhl dot com Assigned:
Status: No Feedback Package: Output Control
PHP Version: 4.3.2-dev, 5.0.0b2-dev OS: win32 only
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php at andyuhl dot com
New email:
PHP Version: OS:

 

 [2003-02-24 13:07 UTC] php at andyuhl dot com
The ob_start callback function doesn't seem to get called when the script runs long.  To reproduce:

<?php
	function callback($buffer) {
		return "callback function executed successfully.";
	}
	
	set_time_limit(5);
	ob_start("callback");
	
	while (1) {
		// do nothing
	}
	
	ob_end_flush();
?>


This results in empty output for me.  You can see my environment here: http://www.andyuhl.com/phpinfo.php

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-25 02:20 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip

Can not reproduce using latest CVS snapshot..

 [2003-02-25 09:32 UTC] php at andyuhl dot com
Problem still occurs with latest snapshot.  

It should be noted that not only does the replaced output not appear, but the original output containing the timeout error message and whatever your original output should be also does not appear.  It is simply empty.

I tested this on a different machine as I am not able to upgrade the original machine at this time.  This machine is WinXP instead of Win2K and it is now running the latest snapshot.
 [2003-02-26 01:07 UTC] sniper@php.net
Which php.ini are you using? php.ini-dist or php.ini-recommended? Have you made any changes to it?

 [2003-02-26 07:41 UTC] php at andyuhl dot com
The original server running 4.3.0 is using a slightly customized version of php.ini-dist.  When I installed the CVS snapshot yesterday, I used php.ini-dist with no changes and was able to reproduce the problem on a second machine.

Another thing I discovered is that it seems to work properly if I call ob_gzhandler as the callback function.  It only seems to fail when supplying your own function as I did in the example code in my original post.
 [2003-04-24 13:53 UTC] php at andyuhl dot com
This is still a bug!  Here's a modification of my example code that includes a line which fills the buffer before the script timeout occurs.  It still does not return the new buffer properly.

<?php
	function callback($buffer) {
		return "callback function executed successfully.";
	}
	
	set_time_limit(5);
	ob_start("callback");
	
	while (1) {
		echo "This is output.<br>\n"; // create some output this time
	}
	
	ob_end_flush();
?>
 [2003-04-26 10:16 UTC] helly@php.net
Shuffling code around does not change the problem. Still you are timed out and the buffers are ignored (what is correct). What you need is an on_timeout_callback().
 [2003-04-28 13:22 UTC] php at andyuhl dot com
Well, something isn't working right somewhere because the windows and linux version behave differently.  

Running the updated code that I just posted, the windows version doesn't return any output at all.  It doesn't even return the error message for timing out, which means that it is definitely doing something to that buffer that is built up in the loop.  

Additionally, the same code on linux behaves as I would expect it to.  On linux, it does process the callback function after it times out and it outputs "callback function executed successfully."

From what you've said, now I'm not sure where the bug exists, but with such distinctly different behavior across platforms, I'm fairly certain it exists somewhere.
 [2003-07-15 20:13 UTC] sniper@php.net
Happens only with win32. (works fine in Linux)

 [2003-07-15 20:13 UTC] sniper@php.net
Another note: ZTS has no effect in linux, works fine even if it's enabled.

 [2004-02-16 01:19 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Nov 28 19:03:38 2021 UTC