From vd@datamax.bg  Wed Apr 13 15:28:49 2005
Return-Path: <vd@datamax.bg>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP
	id 3A6C216A4CE; Wed, 13 Apr 2005 15:28:49 +0000 (GMT)
Received: from jengal.datamax.bg (jengal.datamax.bg [82.103.104.21])
	by mx1.FreeBSD.org (Postfix) with ESMTP
	id A466E43D4C; Wed, 13 Apr 2005 15:28:48 +0000 (GMT)
	(envelope-from vd@datamax.bg)
Received: from sinanica.bg.datamax (sinanica.bg.datamax [192.168.10.1])
	by jengal.datamax.bg (Postfix) with QMQP
	id AB11987CB; Wed, 13 Apr 2005 18:28:47 +0300 (EEST)
Received: (nullmailer pid 65290 invoked by uid 1004);
	Wed, 13 Apr 2005 15:29:23 -0000
Message-Id: <20050413152922.GA57771@sinanica.bg.datamax>
Date: Wed, 13 Apr 2005 18:29:22 +0300
From: Vasil Dimov <vd@datamax.bg>
Reply-To: vd@datamax.bg
To: ale@freebsd.org, freebsd-ports-bugs@freebsd.org,
	freebsd-gnats-submit@FreeBSD.org, map@infinitum.ch
In-Reply-To: <200501170558.j0H5wUtm031845@www.freebsd.org>
Subject: Re: zlib.output_compressions does not work because of split mod_php5/php5-zlib

>Number:         79867
>Category:       ports
>Synopsis:       Re: zlib.output_compressions does not work because of split mod_php5/php5-zlib
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    ale
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 13 15:30:26 GMT 2005
>Closed-Date:    Thu Apr 14 00:29:03 GMT 2005
>Last-Modified:  Thu Apr 14 00:29:03 GMT 2005
>Originator:     
>Release:        
>Organization:
>Environment:
>Description:
 --XMCwj5IQnwKtuyBG
 Content-Type: multipart/mixed; boundary="ftEhullJWpWg/VHq"
 Content-Disposition: inline
 
 
 --ftEhullJWpWg/VHq
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 As noted in
 
 http://www.freebsd.org/cgi/query-pr.cgi?pr=3D76331
 
 The problem is that PHP outputs "Content-Encoding: gzip" header only if
 zlib is enabled at compile time. Which is not the case with the FreeBSD
 port - zlib support is installed as separate port(s): archivers/php[45]-zli=
 b.
 
 So zlib.output_compression=3DOn is unusable because of the missing
 header.
 
 So we have the following 2 choises:
 1. Enable zlib in php at compile time and remove archivers/php[45]-zlib
 ports (poor).
 2. Change PHP source to output the headers mentioned even if zlib is not
 enabled at compile time.
 
 Fortunately the second is very easy to achieve due to the well-written
 PHP code. As seen in the included patch just "#if HAVE_ZLIB" must be
 removed from SAPI.c. What happens is that
 
 zend_ini_long("zlib.output_compression", sizeof("zlib.output_compression"),=
  0)
 
 is always false when zlib is not loaded even if zlib.output_compression
 is turned on in php.ini and so - no extra headers or errors appear when
 zlib.output_compression=3DOn and no zlib.so extension is loaded.
 
 E.g. #if HAVE_ZLIB is not needed at all in the places where it is
 removed in the included patch. Probably this should be emailed to the
 PHP developers for review and inclusion in the next releases.
 
 The same patch can be appiled and is valid for PHP4 and PHP5.
 
 
 --- SAPI.c.orig	Wed Apr 13 17:06:11 2005
 +++ SAPI.c	Wed Apr 13 17:43:58 2005
 @@ -565,11 +565,18 @@
  					ptr++;
  					len--;
  				}
 +/*
 + * Will not hurt in any way if we do not have zlib installed.
 + * This code is allowed to make it possible to use zlib as a
 + * runtime extension (HAVE_ZLIB not defined at compile time).
  #if HAVE_ZLIB
 +*/
  				if(!strncmp(ptr, "image/", sizeof("image/")-1)) {
  					zend_alter_ini_entry("zlib.output_compression", sizeof("zlib.output_c=
 ompression"), "0", sizeof("0") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
  				}
 +/*
  #endif
 +*/
  				mimetype =3D estrdup(ptr);
  				newlen =3D sapi_apply_default_charset(&mimetype, len TSRMLS_CC);
  				if (!SG(sapi_headers).mimetype){
 @@ -712,7 +719,12 @@
  		return SUCCESS;
  	}
 =20
 +/*
 + * Output zlib related headers even if zlib is not enabled at compile time.
 + * This code is allowed to make it possible to use zlib as a
 + * runtime extension (HAVE_ZLIB not defined at compile time).
  #if HAVE_ZLIB
 +*/
  	/* Add output compression headers at this late stage in order to make
  	   it possible to switch it off inside the script. */
 =20
 @@ -740,7 +752,9 @@
  			zval_ptr_dtor(&uf_result);
  		}
  	}
 +/*
  #endif
 +*/
 =20
  	/* Success-oriented.  We set headers_sent to 1 here to avoid an infinite =
 loop
  	 * in case of an error situation.
 
 --ftEhullJWpWg/VHq
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="SAPI.c.patch"
 Content-Transfer-Encoding: quoted-printable
 
 --- SAPI.c.orig	Wed Apr 13 17:06:11 2005
 +++ SAPI.c	Wed Apr 13 17:43:58 2005
 @@ -565,11 +565,18 @@
  					ptr++;
  					len--;
  				}
 +/*
 + * Will not hurt in any way if we do not have zlib installed.
 + * This code is allowed to make it possible to use zlib as a
 + * runtime extension (HAVE_ZLIB not defined at compile time).
  #if HAVE_ZLIB
 +*/
  				if(!strncmp(ptr, "image/", sizeof("image/")-1)) {
  					zend_alter_ini_entry("zlib.output_compression", sizeof("zlib.output_c=
 ompression"), "0", sizeof("0") - 1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
  				}
 +/*
  #endif
 +*/
  				mimetype =3D estrdup(ptr);
  				newlen =3D sapi_apply_default_charset(&mimetype, len TSRMLS_CC);
  				if (!SG(sapi_headers).mimetype){
 @@ -712,7 +719,12 @@
  		return SUCCESS;
  	}
 =20
 +/*
 + * Output zlib related headers even if zlib is not enabled at compile time.
 + * This code is allowed to make it possible to use zlib as a
 + * runtime extension (HAVE_ZLIB not defined at compile time).
  #if HAVE_ZLIB
 +*/
  	/* Add output compression headers at this late stage in order to make
  	   it possible to switch it off inside the script. */
 =20
 @@ -740,7 +752,9 @@
  			zval_ptr_dtor(&uf_result);
  		}
  	}
 +/*
  #endif
 +*/
 =20
  	/* Success-oriented.  We set headers_sent to 1 here to avoid an infinite =
 loop
  	 * in case of an error situation.
 
 --ftEhullJWpWg/VHq--
 
 --XMCwj5IQnwKtuyBG
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 
 iD8DBQFCXTrSFw6SP/bBpCARAoMnAJ4uS5YeJlYCL/iYZvGyttslt5jlEQCgg9ej
 M7kkwWZG7ZW/slYTdX6VY3g=
 =44Td
 -----END PGP SIGNATURE-----
 
 --XMCwj5IQnwKtuyBG--
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Thu Apr 14 00:27:50 GMT 2005 
State-Changed-Why:  
Misfiled followup to ports/76331; content migrated. 

Note to submitter: submitting patches using quoted-printable utterly 
destroys them. 


Responsible-Changed-From-To: gnats-admin->ale 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Thu Apr 14 00:27:50 GMT 2005 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=79867 
>Unformatted:
