Date: Wed, 13 Apr 2005 18:29:22 +0300 From: Vasil Dimov <vd@datamax.bg> To: ale@freebsd.org, freebsd-ports-bugs@freebsd.org, freebsd-gnats-submit@FreeBSD.org, map@infinitum.ch Subject: Re: zlib.output_compressions does not work because of split mod_php5/php5-zlib Message-ID: <20050413152922.GA57771@sinanica.bg.datamax> In-Reply-To: <200501170558.j0H5wUtm031845@www.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050413152922.GA57771>