php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17635 User-defined output handler can't find files without ob_end_flush()
Submitted: 2002-06-07 00:17 UTC Modified: 2002-10-08 12:07 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mogul-php at gelatinous dot com Assigned:
Status: Closed Package: Output Control
PHP Version: 4.2.1 (plus CVS for 4.3) OS: RH Linux 7.3 w/all updates
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mogul-php at gelatinous dot com
New email:
PHP Version: OS:

 

 [2002-06-07 00:17 UTC] mogul-php at gelatinous dot com
I wrote a custom output handler and registered it with ob_start(). The handler gets called if I call ob_end_flush() or when the script ends, as expected.

If the handler tries to open a file that's in the same directory as the script, I get different behavior depending on whether ob_end_flush() was called or the script just ended.  Here's code demonstrating the bug (replace 'fileinthisdir' with an actual file's name):

<?php
$explicit_ob_flush=false;
function my_output_handler($string) {
	return (fopen('fileinthisdir', 'r') ? "Opened file!" : "Couldn't open file!");
}
ob_start("my_output_handler");
?>
Hi, this is some text.
<?
if($explicit_ob_flush) {
	ob_end_flush();
}
?>

This script won't find the file as is.  Change $explicit_ob_flush to true, though, and it will.  (Note that supplying a full pathname to the file works... This is a problem with relative paths, not absolute paths.)


[I'm running RH 7.3 with all updates applied.  My php is version 4.2.1 from the RH RawHide RPMs, recompiled to add --enable-xslt and --with-xslt-sablot but otherwise unmodified.  The sablotron version is 0.90.]

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-07 00:28 UTC] yohgaki@php.net
Cannot reproduce with PHP 4.3.0(CLI).
Could you try PHP 4.3.0-dev and report the result?

 [2002-06-07 12:03 UTC] mogul-php at gelatinous dot com
Happy to try... How do I acquire 4.3.0-dev?  Is this a tarball? CVS branch? Or is this just shorthand for the HEAD branch in CVS?
 [2002-06-07 12:13 UTC] derick@php.net
You can either use a snapshot from snaps.php.net (the non-STABLE tarball) or get it from CVS (HEAD).

Derick
 [2002-06-07 12:55 UTC] mogul-php at gelatinous dot com
Still building 4.3.0-dev... Meanwhile, I tried it via the CLI with 4.2.1 and this behavior is not exhibited!  So it only appears when called as a module from apache...

[apache version is 1.3.23.]
 [2002-06-20 14:42 UTC] sander@php.net
Status on this?
 [2002-06-20 20:08 UTC] mogul-php at gelatinous dot com
Just confirmed this with the php4-200206191200 snapshot.  The behavior is not exhibited under the CLI, but happens reliably via Apache.
 [2002-06-28 17:05 UTC] mogul-php at gelatinous dot com
Curious: Is anyone looking at this?  My project is on the back burner until there's a fix.  

I'll be happy to investigate myself given suggestions where to look in the code, but so far I'm having trouble finding where a script's execution starts and ends... It's obvious for the CLI version, but the Apache module is a different story...  Any pointers?
 [2002-10-08 12:07 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 15 18:01:27 2024 UTC