ob_start(): Second array Member is not a Valid method

Asked

Viewed 65 times

2

We picked up today a system developed by Phpnuke. When analyzing, we saw that the version is old, but the client is irreducible in developing a new site, so we have to work on that existing one. The problem is that the server is giving the error HTTP ERROR 500. We open the log and the error that appears is:

ob_start(): Second array Member is not a Valid method

The code block is that way:

if (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
        if (extension_loaded('zlib')) {
            $do_gzip_compress = true;
            ob_start(array('ob_gzhandler',5)); // Essa é a linha
            ob_implicit_flush(0);
        //  if (ereg("MSIE", $_SERVER['HTTP_USER_AGENT'])) {
            if (preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT'])) {
                header('Content-Encoding: gzip');
            }
        }
    }

The PHP version is PHP Version 5.6.40. How can I fix this? Note that there is also a commented conditional, because this was the first error that appeared and made the adjustment.

  • Have you checked the documentation of this function? What would be the second parameter?

  • Hi Anderson. Yes, he seems to activate the output buffer, but I don’t know how to adjust it inside Phpnuke, because I never worked with Phpnuke.

  • muted by 
ini_set('zlib.output_compression_level', 5);
ob_start('ob_gzhandler');


  • Hi Adir. Now you’ve made that mistake: ob_start(): output handler 'ob_gzhandler' conflicts with 'zlib output compression' in /home/user/public_html/mainfile.php on line 83

1 answer

0

what that function does eh compress the contents in gz to be sent to the customer.

Turns out this call is not correct:

ob_start(array('ob_gzhandler',5));

I believe that the original intention was to compact the contents with the compression level 5. A possible solution would be to call only the ob_gzhandler that the default value of the zlib will be used

ob_start('ob_gzhandler');

Or Voce arrow the desired compress level

ini_set('zlib.output_compression_level', 5);
ob_start('ob_gzhandler');

To avoid this kind of confusion in the future Oce can refactor the code, use better names and make it clearer what Oce is doing

  • Unfortunately it didn’t work either. Returned now: output handler 'ob_gzhandler' conflicts with 'zlib output compression' in /home/user/public_html/mainfile.php on line 84

  • see what’s on this line, probably Voce will have to remove the ini_set before the ob_start

  • Nothing... keeps making the same mistake :(

  • If the web server you are using already compresses will conflict with PHP, if that is the case you will have to change php settings to disable zlib zlib.output_compression = Off

  • Unfortunately it still hasn’t worked, error 500 continues, but it stopped generating errors in the log. Is it some kind of incompatibility of the server with Phpnuke because it is a little old?

  • difficult to know without error messaging, try not to use ob_gzhandler

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.