#9761 closed defect (bug) (fixed)
gzdecode, used in wp-includes/http.php, requires php6
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.8 |
| Component: | HTTP | Version: | 2.8 |
| Severity: | normal | Keywords: | needs-patch |
| Cc: |
Description
Ticket #8674 added support to the HTTP API, but it used the PHP 6 only function gzdecode in a few places. Included is a basic patch to use the gzdeflate (PHP 4.0.4+) function instead.
Attachments (1)
Change History (9)
josephscott
— 4 years ago
comment:1
josephscott
— 4 years ago
comment:2
DD32
— 4 years ago
- Keywords needs-patch added; has-patch removed
Need some input from Jacob here i suspect.
However, My understanding is that DEFLATE != COMPRESS != GS ENCODED
gzcompress() / gzuncompress() - COMPRESS uses ZLIB compression
gzinflate() / gzdeflate() - DEFLATE data compression - Not compatible with mod_deflate, Need to strip the leading 11chars off the string in order to deflate it correctly (And it needs to be checked that its actually mod_deflate that compressed it)
gzencode() / gzdecode() - GZIP Compression. encode variety is PHP 4.0.4+, decode appears to be PHP6 only as you suggest. This function is compatible with mod_deflate as well as gzip'd output.
Now, As for the patch.
- gzdeflate() is the method to compress the string, not inflate it(uncompress)
- gzinflate() is tried first, followed by gzuncompress(), and finally gzdecode() if all else fails.
My suggestion would to just wrap the gzdecode() in a function_exists() check, PHP6 will eventually be the PHP5 of today..
comment:3
DD32
— 4 years ago
Oh, And yeah, It needs an extra block put in there for deflating mod_deflate content along these lines:
if ( substr($compressed,0,3) == "\x1f\x8b\x08" && false !== ($decompressed = gzinflate( substr($compressed,0,3) ) ) )
return $decompressed;
$decompressed = gzinflate( $compressed );
....
comment:4
DD32
— 4 years ago
I got that from the http://au2.php.net/manual/en/function.gzinflate.php page.
However looking at it, theres a few more cases..
Java class java.util.zip.Deflater - Strip leading 2 char
mod_gzip - Strip leading 10 char
mod_deflate - strip leading 11 char
Could also use a help function much like the gzBody() function mentioned on the php page.
comment:5
Denis-de-Bernardy
— 4 years ago
there are a few potential compat functions over here:
comment:6
Denis-de-Bernardy
— 4 years ago
- Summary changed from Use gzdeflate instead of gzdecode in wp-includes/http.php to gzdecode, used in wp-includes/http.php, requires php6
Is gzuncompress the right thing to use instead of gzdeflate? Need to get some feedback from jacobsantos or DD32 on this.