From: laurent_baillif at hotmail dot com Operating system: WinXP / OPENSESUSE 10.2 PHP version: 5.2.5 PHP Bug Type: Apache2 related Bug description: php script don't send output/STDOUT to apache
Description: ------------ Hello, I have an issue with STDOUT/OUTPUT of PHP. Im about to use a PHP script for a RewriteMap directive inside APACHE. And I have identified that APACHE never receive the output from my PHP script and this after trying several way to send the output and also on several platform (winXP/apache2/PHP5 & OPENSUSE/apache2/PHP5.2.5) Thanks for your feedback Regards, Reproduce code: --------------- I have this configuration in a virtual host of APACHE (Works fine if I put a Perl script instead of PHP) <VirtualHost *:80> ServerAdmin [EMAIL PROTECTED] DocumentRoot "/home/mywork/web/partenaire" ServerName mytest.mydomain.com DirectoryIndex index.php ErrorLog /home/mywork/log/apache/error.log LogLevel debug RewriteLog /home/mywork/log/apache/rewrite.log RewriteLogLevel 9 RewriteEngine on #RewriteLock /home/mywork/web/partenaire/test/rewrite.lock #RewriteMap rewritemap prg:/home/mywork/web/partenaire/test/rewritemap.perl RewriteMap rewritemap prg:/home/mywork/web/partenaire/test/rewritemap.php RewriteOptions Inherit RewriteRule ^/test/(.*)$ ${rewritemap:%{REQUEST_URI}} [L] <Directory "/home/mywork/web/partenaire"> Options FollowSymLinks AllowOverride all Order allow, deny Allow from all </Directory> </VirtualHost> I can confirm my PHP script is working fine from the console (read STDIN and write STDOUT) and when it is start with apache, he receive correctly the STDIN but never send back the STDOUT. I have tried several configurations in my script and APACHE never get the STDOUT and just hang or return a blank URL. My rewritemap.php script looks like this: #!/usr/bin/php <?php //Flag to verify the script is starting //$handle = fopen ("home/stat.txt", 'a+'); //fwrite($handle, date("H")."h".date("i")."m".date("s").": start of the script\r\n"); //fclose($handle); $stdin = fopen ('php://stdin', 'r'); $output = fopen('php://output', 'w'); ob_implicit_flush (true); // Use unbuffered output while ($line = fgets ($stdin)) { $line = trim($line); //Flag to verify the script is receinving STDIN //$handle = fopen ("home/stat.txt", 'a+'); //fwrite($handle, date("H")."h".date("i")."m".date("s").": Just receive: $line \r\n"); //fclose($handle); fwrite(STDOUT,"mynewURL?".$line); //try this one and didnt work with apache fwrite($output,"mynewURL?".$line); //try this with OUTPUT and didnt work with neither echo "mynewURL?".$line //try this one also but only works with the console } ?> Expected result: ---------------- I can confirm my PHP script is working fine from the console (read STDIN and write STDOUT) and when it is start with apache, he receive correctly the STDIN but never send back the STDOUT. With the same configuration a perl script is working fine for apache. I have tried several configurations in my php script and APACHE never get the STDOUT and just hang or return a blank URL. Actual result: -------------- Blank url or apache hang. -- Edit bug report at http://bugs.php.net/?id=44551&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44551&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44551&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44551&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=44551&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=44551&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=44551&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=44551&r=needscript Try newer version: http://bugs.php.net/fix.php?id=44551&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=44551&r=support Expected behavior: http://bugs.php.net/fix.php?id=44551&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=44551&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=44551&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=44551&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44551&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=44551&r=dst IIS Stability: http://bugs.php.net/fix.php?id=44551&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=44551&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=44551&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=44551&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=44551&r=mysqlcfg