ID:               44551
 Updated by:       [EMAIL PROTECTED]
 Reported By:      laurent_baillif at hotmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Apache2 related
 Operating System: *
 PHP Version:      5.2.5
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php




Previous Comments:
------------------------------------------------------------------------

[2008-06-25 12:16:58] laurent_baillif at hotmail dot com

Hi,

I have found a solution for my issue! Always send your echo with a "\n"
at the end of your script. 

We sould put that in the manuel because it is says no where.

Another issue I have experience:
If your script is running on a windows platform, never leave a magic
cookies (from linux for instance) and never leave a blank line at the
begining of your script. that will de-synchronise all your answer in
STDOUT. 
Let me explain:
request one => answer one: error in apache
request two => answer two: request one in apache
request three => answer three: request two in apache
and so on...

So if you are running on windows, always start your script with the php
quote:"<?php" and finish it with "?>" whithout any white space in the
middle of the code (e.g like: "?>    <?php" )

Regards

------------------------------------------------------------------------

[2008-06-25 11:37:17] john dot walsh at mini-net dot co dot uk

Hi,

I had a similar problem - stdout not getting to apache, but worked from
the command line.

I tried switching to using echo (with carefully constructed strings),
but that still didn't work.

Then, just to be sure, I put an echo "z" at the start (top level) of my
script.

The 'z' came through, along will all the rest of my scripts output.

I changed the echo "z" to echo "" - the script continued to work.

So it seamed that stdout needed some kick-into-life usage, before it
would work from my functions.

So something to try.

Note: I was outputting binary data, and I think the first character
would have been value 0x0A.

Yours,
John.

------------------------------------------------------------------------

[2008-03-27 15:28:19] laurent_baillif at hotmail dot com

Description:
------------
Hello,

I have an issue with STDOUT/OUTPUT of PHP. I’m 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)

Thank’s 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 didn’t work
with apache
    fwrite($output,"mynewURL?".$line);  //try this with OUTPUT and
didn’t 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 this bug report at http://bugs.php.net/?id=44551&edit=1

Reply via email to