[wp-hackers] gzinflate Warning on transient expiration

Dion Hulse (dd32) wordpress at dd32.id.au
Fri Nov 30 21:45:21 UTC 2012


Hi Drew,

The gzinflate error isn't coming from the Transient API, It's coming
from the WP_HTTP API, the one retrieving the remote document.

The reason you've started seeing it now, may be because you've
upgraded a PHP version, or the remote server has changed their
environment - I'm not sure, but I've started seeing the warning myself
a lot in the last few days and haven't had a chance to track down what
changed.

So it's not a code error on your behalf at all.

The cause comes from WP_HTTP_Encoding::decompress():
http://core.trac.wordpress.org/browser/trunk/wp-includes/class-http.php#L1651

It attempts to decompress the server deflate response with PHP's own
gzinflate() first, unfortunately, this function doesn't actually
decompress data correctly from some servers, which is why we've got a
WP_HTTP_Encoding::compatible_gzinflate() which tries to alter the
compressed data into a state that gzinflate() can actually handle.

gzinflate() currently has error suppression enabled, because when it
can't decompress data, it gives off that PHP Warning, of course the
Debug bar ignores that..

What can you do to avoid the Warning? Not much really, unless you feel
like hacking the core code..
Changing the order of operations in WP_HTTP_Encoding::decompress() to
first try the compatible gzinflate() may result in the warning going
away for that site, however, at the expense of the warning when you
attempt to retrieve a document from a different host which compresses
their data differently.

Moral of the story?  Although servers day "Oh yes, my content is Gzip
encoded!" PHP's decompression methods are lame and every server sends
their data in 1 of 3 different ways..

I hope this helps :)

D


On 1 December 2012 08:22, Drew <xoodrew at gmail.com> wrote:
> Hey guys,
>
> I'm running into a frustrating issue where I'm getting a gzinflate Warning
> on the first page load after transient(s) holding remote GETs have expired.
>
> This is the error:
>
> WARNING: wp-includes/class-http.php:1654 - gzinflate()
> [function.gzinflate]: data error
>
> I'm working with a method that pulls data via wp_remote_get() from various
> sites based on the value of a post meta key. When the transient(s) have
> expired I can see the transient has been set again, but it throws the
> warning on the first page load. Refreshing the page clears the warning and
> displays the value(s) of the transients. This happens every time the
> transients expire.
>
> So two questions:
> 1) Should I not be caching inside the method and if not, what are my
> alternatives?
> 2) If the caching doesn't seem to be to blame, how do I overcome the
> warning when transients are reset?
>
> This is the block I'm concerned with:
> $cached = get_transient( $meta->_stats_type . '-count' );
> if ( false == $cached ) {
>     $count = number_format( stats_count( $meta->_stats_type ), 0, '', ',' );
>     set_transient( $meta->_stats_type . '-count', $count, 3600 );
> }
> return $cached;
>
> Also, if it makes a difference, I'm working on localhost.
>
> Drew
> --
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers


More information about the wp-hackers mailing list