Bug #17635: User-defined output handler can't find files without ob_end_flush()
| From: | mogul-php at gelatinous dot com | Date: | Fri, 07 Jun 2002 04:17:17 +0000 |
| Subject: | Bug #17635: User-defined output handler can't find files without ob_end_flush() | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-9715@lists.php.net to get a copy of this message | ||
From: mogul-php@gelatinous.com
Operating system: RH Linux 7.3 w/all updates
PHP version: 4.2.1
PHP Bug Type: Output Control
Bug description: User-defined output handler can't find files without ob_end_flush()
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.]
--
Edit bug report at http://bugs.php.net/?id=17635&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=17635&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=17635&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=17635&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=17635&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17635&r=support
Expected behavior: http://bugs.php.net/fix.php?id=17635&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=17635&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=17635&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=17635&r=globals