WordPress.org

Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#9761 closed defect (bug) (fixed)

gzdecode, used in wp-includes/http.php, requires php6

Reported by: josephscott Owned by:
Milestone: 2.8 Priority: normal
Severity: normal Version: 2.8
Component: HTTP API Keywords: needs-patch
Focuses: 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)

wp-includes--http.php.diff (656 bytes) - added by josephscott 12 years ago.

Download all attachments as: .zip

Change History (9)

#1 @josephscott
12 years ago

Is gzuncompress the right thing to use instead of gzdeflate? Need to get some feedback from jacobsantos or DD32 on this.

#2 @DD32
12 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..

#3 @DD32
12 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 );
....

#4 @DD32
12 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.

#5 @Denis-de-Bernardy
12 years ago

there are a few potential compat functions over here:

http://fr.php.net/manual/en/function.gzdecode.php#84174

#6 @Denis-de-Bernardy
12 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

#7 @ryan
12 years ago

(In [11271]) Add function_exists check for gzdecode. see #9761

#8 @ryan
12 years ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.