When will flush() work again?

General discussions related to php

Moderators: macek, egami, gesf

liderbug
New php-forum User
New php-forum User
Posts: 20
Joined: Mon Feb 14, 2011 7:14 pm

When will flush() work again?

Postby liderbug » Thu Sep 05, 2013 7:28 am

A release or two back the command flush(); became equiv. to null();. It's causing me a real problem as I have a web page that takes just over the timeout limit to run and kills the script (hosted site - TO not settable). When flush worked it would display each output line of the script and would run to the end, I could watch the progress and watch for abc1 OK, abc2 OK, abc3 FAIL, abc4 OK... I could take note and fix #3.

<pseudo code>
select a,b,c from table1,2,3 where x=...;
foreach ( do calc, check status, do update, send email, display OK/FAIL )

A. Is flush() going to be fixed?
B. A workaround? javascript (not my best subject, I can if given a good push in the right direction)
C. other????

Thanks
Chuck

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: When will flush() work again?

Postby johnj » Sun Sep 08, 2013 3:01 am

Did you make any changes to your php.ini file?

liderbug
New php-forum User
New php-forum User
Posts: 20
Joined: Mon Feb 14, 2011 7:14 pm

Re: When will flush() work again?

Postby liderbug » Sun Sep 08, 2013 4:13 pm

My hosting service upgraded from ??? 4.1 to 4.2 or something like that and flush/ob_flush just quit. The PHP manual pages - somewhat hidden in the man page is "it's broken and all the tweeking in the world won't fix it." (well something like that). I'm trying to find out "if" it will be fixed or not. You see I send out about 200 emails once a week "Your weekly local newspaper is available on line. Click here... yada yada....". Well, I wrote the code and the woman who does the paper likes to watch each email go by:
aa11@msn.com .... OK
abcde@foo4.net .... OK
bob73@gmail.com .... FAILED
bobbi@xyz ... OK

And it worked great- until.... it didn't. I've tried a javascript in the php script - no output and the worst thing is the php script times out before all 200 emails are sent.

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: When will flush() work again?

Postby johnj » Sun Sep 08, 2013 8:49 pm

you need to make sure that the upgrade did not create this. If a rollback to the old version is possible, then please do that.

liderbug
New php-forum User
New php-forum User
Posts: 20
Joined: Mon Feb 14, 2011 7:14 pm

Re: When will flush() work again?

Postby liderbug » Mon Sep 09, 2013 10:18 am

It's my hosting service OLM.net PHP Version => 5.2.17
They're not going to roll back to a previous ver of php just for me

Also...
http://php.net/manual/en/function.ob-flush.php
9
Lee
1 year ago
As of August 2012, all browsers seem to show an all-or-nothing approach to buffering. In other words, while php is operating, no content can be shown.
In particular this means that the following workarounds listed further down here are ineffective:
1) ob_flush (), flush () in any combination with other output buffering functions;
2) changes to php.ini involving setting output_buffer and/or zlib.output_compression to 0 or Off;
3) setting Apache variables such as "no-gzip" either through apache_setenv () or through entries in .htaccess.
So, until browsers begin to show buffered content again, the tips listed here are moot.


Now Lee seems to say it's the browsers fault - except that Chrome, Firefox and IE all stopped working on the same day. When I Google "php flush not working" I get pages of the same problem.

Veryyyyy interesting. I have 2 boxes 3.6.11-4.fc16.x86_64 and 2.6.35.14-106.fc14.i686 and on both boxes my script:

Code: Select all

<?php
for ($n=0; $n<5; $n++)
{
echo "N $n<br>";
flush ();
sleep (1);
}
?>

fc16 gives me a blank screen for 5 seconds then *bam* all 5 lines are there. On my fc14 box I get 1 line per second just the way it should work - both are running PHP 5.3.20 and this is from the same browser. Now I'm really confused'ed'ed'ed.....

Thanks
---------------------
Statistically, 6 out of 7 dwarves are not Happy.

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: When will flush() work again?

Postby johnj » Mon Sep 09, 2013 8:13 pm

So, it is very clear that this is a version incompatibility. In your fc16, try not to use flush and see if it works.

liderbug
New php-forum User
New php-forum User
Posts: 20
Joined: Mon Feb 14, 2011 7:14 pm

Re: When will flush() work again?

Postby liderbug » Tue Sep 10, 2013 8:06 am

Commented out flush on both boxes [fc16/fc14] - nothing shows up until the script is done, so flush() is needed/required.

I also copied my php.ini to my hosted site - htaccess - suPHP_ConfigPath /home/user/public_html - php.ini and it still doesn't work. I'm comparing phpinfo() - well trying - is not exactly a 1:1 match so the pain level is farily .... high... I'm starting to lean towards one of the libs, changed? missing? not loading?

later...

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: When will flush() work again?

Postby johnj » Tue Sep 10, 2013 10:00 pm

Make sure in your php.ini file output_buffering = Off ; and zlib.output_compression = Off

Then, you can try this code:

Code: Select all

ob_start();

for($i=0;$i<10;$i++)
{
    ob_flush();
    flush();
    echo 'testing...'.$i.'<br />';
    sleep(3000);
}

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: When will flush() work again?

Postby johnj » Tue Sep 10, 2013 10:02 pm

Also, please check if you have any anti virus running on fc16, sometimes these may interfere with flush()

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: When will flush() work again?

Postby johnj » Tue Sep 10, 2013 10:03 pm

Please take a look at the issues solved in the php manual regarding flush()
http://php.net/manual/en/function.flush.php

liderbug
New php-forum User
New php-forum User
Posts: 20
Joined: Mon Feb 14, 2011 7:14 pm

Re: When will flush() work again?

Postby liderbug » Wed Sep 11, 2013 7:48 am

John, FC16 is a Linux box, as is FC14, with no anti-virus SW. And I was able to get both of my Linux boxes to work just fine even outputing my data as a table - row... row... row... one every second.

I've been through the PHP man page for flush more times than I can count. I'm thinking that the entry "flush() may not be able to override the buffering scheme of your web server " is my problem and I won't be able to get it to work on that server. So I'm going to pack it in. Thanks for all of the advice. Me owe beer.

Chuck


Return to “PHP General”

Who is online

Users browsing this forum: No registered users and 1 guest

cron