欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

ob_end_flush() failed to send buffer of zlib output compression (1) in wordpress


I don't have any problem on localhost. but when i tested my codes on server, end of every page i see this notice.

my code:

<?php
ob_start();
include 'view.php';

$data = ob_get_contents();
ob_end_clean();
include 'master.php';
ob_end_flush();  // Problem is this line
shareimprove this question
 

It solved when switched off zlib.output_compression in php.ini

zlib.output_compression = Off

 

I don't have any problem on localhost. but when i tested my codes on server, end of every page i see this notice.

my code:

<?php
ob_start();
include 'view.php';

$data = ob_get_contents();
ob_end_clean();
include 'master.php';
ob_end_flush();  // Problem is this line
shareimprove this question
 

It solved when switched off zlib.output_compression in php.ini

zlib.output_compression = Off

来自 https://stackoverflow.com/questions/38693992/notice-ob-end-flush-failed-to-send-buffer-of-zlib-output-compression-1-in

Support » Fixing WordPress » Notice: ob_end_flush(): failed to send buffer of zlib output compression

  • ResolvedSRD75 

    (@srd75)


    Hi,

    Our website receives the error:

    Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /…/wp-includes/functions.php on line 3718 Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /…/wp-includes/functions.php on line 3718

    Not sure what this means.

    • This topic was modified 4 months, 2 weeks ago by SRD75.
Viewing 4 replies - 1 through 4 (of 4 total)
  • I fixed this by adding the following to my theme’s functions.php:

    remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );

    Hi mate. I seriously need your help.

    I saw your topic about

    WordPress “is currently unable to handle this request.’
    Hi,

    I’ve left a development site untouched for a week or so, and when I look at the front end I receive a message:

    http://www.example.com is currently unable to handle this request.
    500

    I’ve both reset permalinks and disabled all plugins, and the issue remains.

    Advice appreciated.

    Regards,
    Steve.

    And then you said “I had made a change to the theme’s index.php which was out of place. Fixed now.”

    And now I am facing similar problem to that and i made change to theme.inc file. How Did you fixed those theme.inc files because even I go to http://www.example.com/wp-admin it is blank. please help me.

    • This reply was modified 4 months, 2 weeks ago by azlmkjsd.

    Hi azlmkjsd,

    Please start a new topic or reply to the older topic. This is not the right place to post about this topic, as it is completely different to the original post in this thread. 

来自  https://wordpress.org/support/topic/notice-ob_end_flush-failed-to-send-buffer-of-zlib-output-compres...


Disable zlib.output_compression on WordPress : Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /path/wp-includes/functions.php on line 3282 via https://core.trac.wordpress.org/ticket/18525
 SOLUTIONS I have came across so far:
  
 ======================== SOLUTION 1 ====================
  
 In plugins (or somewhere) you probably have this code:
  
 ini_set('zlib.output_compression', '1');
  
 so, I replaced that code with
  
 if (!is_admin()) ob_start('ob_gzhandler'); //because, in admin pages, it causes plugin installation freezing
  
 and Compression will be remained still ON.
  
 ======================== SOLUTION 2 ====================
 You may have to use:
  
 remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );



Opened 5 years ago

Closed 5 years ago

Last modified 2 years ago

#22430 closed defect (bug) (duplicate)

wp_ob_end_flush_all bug when zlib.output_compression = On

Reported by:Matthias ReuterOwned by: 
Milestone:Priority:normal
Severity:majorVersion:2.8
Component:GeneralKeywords: 
  

Description 

When zlib.output_compression is set to On, the function wp_ob_end_flush_all throws the following error:

Notice: ob_end_flush() [ref.outcontrol]: failed to delete buffer zlib output compression in /wp-includes/functions.php on line 2683

You can see this error e.g. when opening /wp-login.php in browser.

Critical Issue related to this bug: it also affects usage of /wp-admin/customize.php - the preview results in a blank page. Seems that the error avoids ajax snippets from getting loaded succesfully.

Hotfix is replacing in /wp-includes/functions.php

function wp_ob_end_flush_all() {
	$levels = ob_get_level();
	for ($i=0; $i<$levels; $i++)
		ob_end_flush();
}

with

function wp_ob_end_flush_all() {
	//$levels = ob_get_level();
	//for ($i=0; $i<$levels; $i++)
	//	ob_end_flush();
}

This issue occurs in all browsers (ie,ff,opera, etc) with both latest versions of WordPress, 3.4.2 and latest nightly build on a LAMP system with PHP Version 5.3.10-1~dotdeb.0.

PHP zlib settings:

Directive	Local Value	Master Value
zlib.output_compression	On	Off
zlib.output_compression_level	5	-1
zlib.output_handler	no value	no value
   
 
 

Change History (8)

#1@SergeyBiryukovCore Committer 
5 years ago

 

Related: #18239#18525

#2@SergeyBiryukovCore Committer 
5 years ago

 
  • Keywords needs-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version changed from trunk to 2.8

Going to close as a duplicate of #18525, which has patches.

The same notice is mentioned in ticket:18525:9.

#3@Matthias Reuter 
5 years ago

 
  • Resolution duplicate deleted
  • Status changed from closed to reopened

Hi Sergey,

thanks for relating the other tickets to this issue. Currently WordPress per default is not compatible with zlib enabled. While Server-Side-Compression is recommened by search engines and most browsers, the other tickets linked by you recommend either disabling zlib or inserting a hotfix.

I don't want to live with a hotfix over the next years which needs to be re-applied manually with every WordPress update.

I would recommend dropping support for PHP 5.2 (or even check wether PHP 5.3 is on server) to avoid that a compatibility function (wp_ob_end_flush_all()) for PHP 5.2 produces new errors on PHP 5.3 installations with zlib enabled.

So I hope that the developers of WordPress will fix this issue and don't let me hotfix that the next years until PHP 5.2 support is finally dropped.

Kind regards,

Matthias

#4@nacinLead Developer 
5 years ago

 
  • Resolution set to duplicate
  • Status changed from reopened to closed

Rather than hacking core, try this one-line plugin on for size:

remove_action( 'shutdown', 'wp_ob_end_flush_all', 1 );

We may be at the point where we can eliminate this from core. I'll look into it at the start of the 3.6 cycle. Closing this as a duplicate of #18525 makes sense, because that ticket is reporting the same problem. You disagree with the solution, and that's completely fine, but you should voice it there. (For what it's worth, I also don't like the solution, which is why I myself have not committed it.)

#5@Matthias Reuter 
5 years ago

 

Wow, nacin, this fix works great and I don't need to touch the core - perfect :)

#6@daveagp 
4 years ago

 

I found nacin's fix to work for me as well. I was experiencing problems with ajax (regardless of whether I used WP's ajax hooks, or I directly called a .php from ajax and had the php load wp-load.php). Thanks!

#7@Sam_a 
3 years ago

 

Thanks @nacin. I've seen this bug for years and I hope it's eventually fixed in core.

#8@selnomeria 
2 years ago

 

NO! 
in documentation comments ( https://core.trac.wordpress.org/browser/tags/4.2.2/src/wp-includes/functions.php#L3279 ) they say that it is needed for PHP 5.2 . 

So, i dont know, if other PHP versions doesnt need that function.. I dont know. 

Last edited 2 years ago by selnomeria (previous) (diff)
 
@shipingzhong
 
 
 
 

Attach files by dragging & dropping, selecting them, or pasting from the clipboard.


来自 https://gist.github.com/loorlab/028d9fca02e6e4f85d1a


普通分类: