osclass / Osclass

With Osclass, get your own classifieds site for free. Build your own Osclass installation and start advertising real estate, jobs or whatever you want- in minutes!
http://osclass.org/
647 stars 344 forks source link

Premature ob_end_flush() before header modification...? #2298

Open tamasoz opened 5 years ago

tamasoz commented 5 years ago

Hi,

I am by no means any good at PHP but I encountered the following issue using osclass 3.8 and the latest PaymentPro plugin...

The problem was there (line 1472 in utils.php):

function osc_redirect_to($url, $code = null) { if(ob_get_length()>0) { ob_end_flush(); } if($code!=null) { header("Location: ".$url, true, $code); } else { header("Location: ".$url); } exit; }

Then I noticed that when I update the PaymentPro plugin the response stalls...the logfile showed the following error:

PHP Warning: Cannot modify header information - headers already sent... ...and then the reference to the utils.php file.

As far as I understand this function closes a stream or flushing the stream of some sort then tries to modify the header...which is not possible after calling the ob_end_flush()...according to the doco..

As a solution I swaped the two calls around and it worked...so far anyway... `function osc_redirect_to($url, $code = null) {

if($code!=null) {
    header("Location: ".$url, true, $code);
} else {
    header("Location: ".$url);
}

if(ob_get_length()>0) {
    ob_end_flush();
}
exit;

}`

I am not sure if this is a real issue or just some localized mayhem here...but I thought I let you know....