From 730fa7041892af367bccd5ae3790e3648899fe86 Mon Sep 17 00:00:00 2001
From: Alex Dupre <ale@FreeBSD.org>
Date: Wed, 16 Nov 2005 08:24:47 +0000
Subject: - Fix pear pkg-plist - Increase pear memory limit (requested by
 amd64) - Revert apache2handler to the latest working version found in   PHP
 4.4.0, since PHP developers seem not interested in   fixing the bug with
 apache2 and mod_rewrite

---
 lang/php4/Makefile                                 |   2 +-
 lang/php4/Makefile.pear                            |   2 +-
 lang/php4/files/patch-Zend::zend.h                 |   9 +-
 lang/php4/files/patch-acinclude.m4                 |   8 +-
 lang/php4/files/patch-configure                    |  12 +-
 lang/php4/files/patch-main::php_config.h.in        |  10 +-
 lang/php4/files/patch-pear::scripts::pearcmd.php   |  11 +-
 .../files/patch-sapi_apache2handler_sapi_apache2.c | 125 +++++++++++++++++++--
 lang/php4/pkg-plist.pear                           |  28 ++++-
 9 files changed, 167 insertions(+), 40 deletions(-)

(limited to 'lang/php4')

diff --git a/lang/php4/Makefile b/lang/php4/Makefile
index 5e97d6ed7866..b1ff0dab6e7e 100644
--- a/lang/php4/Makefile
+++ b/lang/php4/Makefile
@@ -7,7 +7,7 @@
 
 PORTNAME=	php4
 PORTVERSION=	4.4.1
-PORTREVISION?=	1
+PORTREVISION?=	2
 CATEGORIES?=	lang devel www
 MASTER_SITES=	${MASTER_SITE_PHP:S,$,:release,} \
 		http://downloads.php.net/ilia/:rc \
diff --git a/lang/php4/Makefile.pear b/lang/php4/Makefile.pear
index f49c4e7b460f..f4480e1d0936 100644
--- a/lang/php4/Makefile.pear
+++ b/lang/php4/Makefile.pear
@@ -1,4 +1,4 @@
-PORTREVISION=	0
+PORTREVISION=	1
 
 LIB_DEPENDS+=   expat.5:${PORTSDIR}/textproc/expat2
 
diff --git a/lang/php4/files/patch-Zend::zend.h b/lang/php4/files/patch-Zend::zend.h
index 50625c403417..7bbc0dd24d16 100644
--- a/lang/php4/files/patch-Zend::zend.h
+++ b/lang/php4/files/patch-Zend::zend.h
@@ -1,12 +1,11 @@
---- Zend/zend.h.orig    Mon Dec  6 15:42:56 2004
-+++ Zend/zend.h Mon Dec  6 15:46:40 2004
+--- Zend/zend.h.orig	Sat Jul 23 13:58:40 2005
++++ Zend/zend.h	Tue Nov 15 23:25:54 2005
 @@ -176,7 +176,7 @@
  #endif
-
-
+ 
+ 
 -#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(ZEND_WIN32)) && !(defined(ZTS) && defined(NETWARE)) && !(defined(ZTS) && defined(HPUX)) && !defined(__darwin__) && !defined(__APPLE__)
 +#if (HAVE_ALLOCA || (defined (__GNUC__) && __GNUC__ >= 2)) && !(defined(ZTS) && defined(ZEND_WIN32)) && !(defined(ZTS) && defined(NETWARE)) && !(defined(ZTS) && defined(HPUX)) && !defined(__darwin__) && !defined(__APPLE__) && !(defined(ZTS) && defined(__FreeBSD__))
  # define do_alloca(p) alloca(p)
  # define free_alloca(p)
  #else
-
diff --git a/lang/php4/files/patch-acinclude.m4 b/lang/php4/files/patch-acinclude.m4
index aa1a2e8d683c..853082ef6319 100644
--- a/lang/php4/files/patch-acinclude.m4
+++ b/lang/php4/files/patch-acinclude.m4
@@ -1,7 +1,7 @@
---- acinclude.m4.orig	Mon Apr  4 10:30:15 2005
-+++ acinclude.m4	Mon Apr  4 10:33:00 2005
-@@ -1685,9 +1685,9 @@
-   unset OPENSSL_LIBDIR
+--- acinclude.m4.orig	Fri Sep 23 11:20:22 2005
++++ acinclude.m4	Tue Nov 15 23:25:54 2005
+@@ -1709,9 +1709,9 @@
+   test -z "$PHP_IMAP_SSL" && PHP_IMAP_SSL=no
  
    dnl Fallbacks for different configure options
 -  if test "$PHP_OPENSSL" != "no"; then
diff --git a/lang/php4/files/patch-configure b/lang/php4/files/patch-configure
index 6482eeea108d..0b4f226749ae 100644
--- a/lang/php4/files/patch-configure
+++ b/lang/php4/files/patch-configure
@@ -1,6 +1,6 @@
---- configure.orig	Mon Oct 11 15:56:07 2004
-+++ configure	Mon Oct 11 15:56:28 2004
-@@ -2672,7 +2672,7 @@
+--- configure.orig	Sun Oct 30 12:06:37 2005
++++ configure	Tue Nov 15 23:25:55 2005
+@@ -2900,7 +2900,7 @@
    save_LIBS=$LIBS
    
  if test -n "$ac_cv_pthreads_lib"; then
@@ -9,7 +9,7 @@
  fi
  
  if test -n "$ac_cv_pthreads_cflags"; then
-@@ -8934,7 +8934,7 @@
+@@ -9725,7 +9725,7 @@
  if test "$enable_experimental_zts" = "yes"; then
    
  if test -n "$ac_cv_pthreads_lib"; then
@@ -18,7 +18,7 @@
  fi
  
  if test -n "$ac_cv_pthreads_cflags"; then
-@@ -8951,8 +8951,6 @@
+@@ -9742,8 +9742,6 @@
    case $host_alias in
    *solaris*)
      PTHREAD_FLAGS="-D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT";;
@@ -27,7 +27,7 @@
    *linux*)
      PTHREAD_FLAGS=-D_REENTRANT;;
    *aix*)
-@@ -89623,7 +89621,7 @@
+@@ -98846,7 +98844,7 @@
    save_LIBS=$LIBS
    
  if test -n "$ac_cv_pthreads_lib"; then
diff --git a/lang/php4/files/patch-main::php_config.h.in b/lang/php4/files/patch-main::php_config.h.in
index 537a8dfe0d31..ca828a919078 100644
--- a/lang/php4/files/patch-main::php_config.h.in
+++ b/lang/php4/files/patch-main::php_config.h.in
@@ -1,12 +1,12 @@
---- main/php_config.h.in.orig	Tue Dec 14 18:55:22 2004
-+++ main/php_config.h.in	Thu Dec 16 09:52:53 2004
-@@ -2455,6 +2455,9 @@
+--- main/php_config.h.in.orig	Sun Oct 30 12:06:40 2005
++++ main/php_config.h.in	Wed Nov 16 09:18:14 2005
+@@ -2606,6 +2606,9 @@
  /* Whether to build zip as dynamic module */
  #undef COMPILE_DL_ZIP
  
 +/* Include external shared modules configurations */
 +#include "ext/php_config.h"
 +
- /* whether floatingpoint.h defines fp_except */
- #undef HAVE_FP_EXCEPT
+ /* Define if int32_t type is present.  */
+ #undef HAVE_INT32_T
  
diff --git a/lang/php4/files/patch-pear::scripts::pearcmd.php b/lang/php4/files/patch-pear::scripts::pearcmd.php
index e7397d32e05d..b3b74f72f147 100644
--- a/lang/php4/files/patch-pear::scripts::pearcmd.php
+++ b/lang/php4/files/patch-pear::scripts::pearcmd.php
@@ -1,11 +1,11 @@
---- pear/scripts/pearcmd.php.orig	Fri May 16 17:31:37 2003
-+++ pear/scripts/pearcmd.php	Fri May 16 17:36:10 2003
+--- pear/scripts/pearcmd.php.orig	Mon Mar 28 18:57:01 2005
++++ pear/scripts/pearcmd.php	Tue Nov 15 23:25:55 2005
 @@ -1,3 +1,4 @@
 +#!%%PREFIX%%/bin/php -nq
  <?php
  //
  // +----------------------------------------------------------------------+
-@@ -24,9 +25,9 @@
+@@ -24,9 +25,10 @@
  /**
   * @nodep Gtk
   */
@@ -15,6 +15,7 @@
 +dl('pcre.so');
 +dl('xml.so');
 +ini_set('include_path', '%%PREFIX%%/share/pear:%%PREFIX%%/share/pear/bootstrap');
++ini_set('memory_limit', '16M');
  ini_set('allow_url_fopen', true);
- set_time_limit(0);
- ob_implicit_flush(true);
+ if (!ini_get('safe_mode')) {
+     @set_time_limit(0);
diff --git a/lang/php4/files/patch-sapi_apache2handler_sapi_apache2.c b/lang/php4/files/patch-sapi_apache2handler_sapi_apache2.c
index dde4289f4726..cf9340073f07 100644
--- a/lang/php4/files/patch-sapi_apache2handler_sapi_apache2.c
+++ b/lang/php4/files/patch-sapi_apache2handler_sapi_apache2.c
@@ -1,11 +1,118 @@
---- sapi/apache2handler/sapi_apache2.c.orig	Thu Nov  3 10:13:33 2005
-+++ sapi/apache2handler/sapi_apache2.c	Thu Nov  3 10:14:41 2005
-@@ -535,7 +535,7 @@
- 		if (!parent_req) {
- 			parent_req = ctx->r;
+--- sapi/apache2handler/sapi_apache2.c.orig	Wed Oct 12 23:41:36 2005
++++ sapi/apache2handler/sapi_apache2.c	Tue Nov 15 23:27:16 2005
+@@ -453,34 +453,15 @@
+ 	request_rec *parent_req = NULL;
+ 	TSRMLS_FETCH();
+ 
+-#define PHPAP_INI_OFF \
+-	if (strcmp(r->protocol, "INCLUDED")) { \
+-		zend_try { zend_ini_deactivate(TSRMLS_C); } zend_end_try(); \
+-	} \
+-
+ 	conf = ap_get_module_config(r->per_dir_config, &php4_module);
+-
+-	/* apply_config() needs r in some cases, so allocate server_context early */
+-	ctx = SG(server_context);
+-	if (ctx == NULL) {
+-		ctx = SG(server_context) = apr_pcalloc(r->pool, sizeof(*ctx));
+-		/* register a cleanup so we clear out the SG(server_context)
+-		 * after each request. Note: We pass in the pointer to the
+-		 * server_context in case this is handled by a different thread.
+-		 */
+-		apr_pool_cleanup_register(r->pool, (void *)&SG(server_context), php_server_context_cleanup, apr_pool_cleanup_null);
+-		ctx->r = r;
+-		ctx = NULL; /* May look weird to null it here, but it is to catch the right case in the first_try later on */
+-	} else {
+-		parent_req = ctx->r;
+-		ctx->r = r;
+-	}
+ 	apply_config(conf);
+ 
+ 	if (strcmp(r->handler, PHP_MAGIC_TYPE) && strcmp(r->handler, PHP_SOURCE_MAGIC_TYPE) && strcmp(r->handler, PHP_SCRIPT)) {
+ 		/* Check for xbithack in this case. */
+ 		if (!AP2(xbithack) || strcmp(r->handler, "text/html") || !(r->finfo.protection & APR_UEXECUTE)) {
+-			PHPAP_INI_OFF;
++			zend_try {
++				zend_ini_deactivate(TSRMLS_C);
++			} zend_end_try();
+ 			return DECLINED;
  		}
+ 	}
+@@ -489,24 +470,32 @@
+ 	 * the configuration; default behaviour is to accept. */ 
+ 	if (r->used_path_info == AP_REQ_REJECT_PATH_INFO
+ 		&& r->path_info && r->path_info[0]) {
+-		PHPAP_INI_OFF;
++		zend_try {
++			zend_ini_deactivate(TSRMLS_C);
++		} zend_end_try();
+ 		return HTTP_NOT_FOUND;
+ 	}
+ 
+ 	/* handle situations where user turns the engine off */
+ 	if (!AP2(engine)) {
+-		PHPAP_INI_OFF;
++		zend_try {
++			zend_ini_deactivate(TSRMLS_C);
++		} zend_end_try();
+ 		return DECLINED;
+ 	}
+ 
+ 	if (r->finfo.filetype == 0) {
+ 		php_apache_sapi_log_message_ex("script '%s' not found or unable to stat", r);
+-		PHPAP_INI_OFF;
++		zend_try {
++				zend_ini_deactivate(TSRMLS_C);
++		} zend_end_try();
+ 		return HTTP_NOT_FOUND;
+ 	}
+ 	if (r->finfo.filetype == APR_DIR) {
+ 		php_apache_sapi_log_message_ex("attempt to invoke directory '%s' as script", r);
+-		PHPAP_INI_OFF;
++		zend_try {
++			zend_ini_deactivate(TSRMLS_C);
++		} zend_end_try();
+ 		return HTTP_FORBIDDEN;
+ 	}
+ 
+@@ -522,30 +511,24 @@
+ 
+ zend_first_try {
+ 
++	ctx = SG(server_context);
+ 	if (ctx == NULL) {
+-normal:
++		ctx = SG(server_context) = apr_pcalloc(r->pool, sizeof(*ctx));
++		/* register a cleanup so we clear out the SG(server_context)
++		 * after each request. Note: We pass in the pointer to the
++		 * server_context in case this is handled by a different thread.
++		 */
++		apr_pool_cleanup_register(r->pool, (void *)&SG(server_context), php_server_context_cleanup, apr_pool_cleanup_null);
++
++		ctx->r = r;
+ 		brigade = apr_brigade_create(r->pool, r->connection->bucket_alloc);
+-		ctx = SG(server_context);
+ 		ctx->brigade = brigade;
+ 
+ 		if (php_apache_request_ctor(r, ctx TSRMLS_CC)!=SUCCESS) {
+ 			zend_bailout();
+ 		}
+ 	} else {
+-		if (!parent_req) {
+-			parent_req = ctx->r;
+-		}
 -		if (parent_req && strcmp(parent_req->handler, PHP_MAGIC_TYPE) && strcmp(parent_req->handler, PHP_SOURCE_MAGIC_TYPE) && strcmp(parent_req->handler, PHP_SCRIPT)) {
-+		if (parent_req && parent_req->handler && strcmp(parent_req->handler, PHP_MAGIC_TYPE) && strcmp(parent_req->handler, PHP_SOURCE_MAGIC_TYPE) && strcmp(parent_req->handler, PHP_SCRIPT)) {
- 			if (php_apache_request_ctor(r, ctx TSRMLS_CC)!=SUCCESS) {
- 				zend_bailout();
- 			}
+-			if (php_apache_request_ctor(r, ctx TSRMLS_CC)!=SUCCESS) {
+-				zend_bailout();
+-			}
+-		}
+-		
+-		/* check if comming due to ErrorDocument */
+-		if (parent_req && parent_req->status != HTTP_OK) {
+-			parent_req = NULL;
+-			goto normal;
+-		}
++		parent_req = ctx->r;
+ 		ctx->r = r;
+ 		brigade = ctx->brigade;
+ 	}
diff --git a/lang/php4/pkg-plist.pear b/lang/php4/pkg-plist.pear
index 9e0a562ecc98..17253c65649a 100644
--- a/lang/php4/pkg-plist.pear
+++ b/lang/php4/pkg-plist.pear
@@ -1,5 +1,14 @@
 bin/pear
-@exec mkdir -p %D/lib/php/pear/.registry
+@exec mkdir -p %D/lib/php/pear/.channels/.alias
+@exec mkdir -p %D/lib/php/pear/.registry/.channel.__uri
+@exec mkdir -p %D/lib/php/pear/.registry/.channel.pecl.php.net
+@exec touch %D/lib/php/pear/.channels/.alias/pear.txt
+@exec touch %D/lib/php/pear/.channels/.alias/pecl.txt
+@exec touch %D/lib/php/pear/.channels/__uri.reg
+@exec touch %D/lib/php/pear/.channels/pear.php.net.reg
+@exec touch %D/lib/php/pear/.channels/pecl.php.net.reg
+@exec touch %D/lib/php/pear/.depdb
+@exec touch %D/lib/php/pear/.depdblock
 @exec touch %D/lib/php/pear/.filemap
 @exec touch %D/lib/php/pear/.lock
 share/pear/bootstrap/Archive/Tar.php
@@ -7,6 +16,9 @@ share/pear/bootstrap/PEAR.php
 share/pear/bootstrap/System.php
 share/pear/bootstrap/Console/Getopt.php
 share/pear/bootstrap/OS/Guess.php
+share/pear/bootstrap/PEAR/Autoloader.php
+share/pear/bootstrap/PEAR/Builder.php
+share/pear/bootstrap/PEAR/Command.php
 share/pear/bootstrap/PEAR/Command/Auth.php
 share/pear/bootstrap/PEAR/Command/Build.php
 share/pear/bootstrap/PEAR/Command/Common.php
@@ -16,9 +28,6 @@ share/pear/bootstrap/PEAR/Command/Mirror.php
 share/pear/bootstrap/PEAR/Command/Package.php
 share/pear/bootstrap/PEAR/Command/Registry.php
 share/pear/bootstrap/PEAR/Command/Remote.php
-share/pear/bootstrap/PEAR/Autoloader.php
-share/pear/bootstrap/PEAR/Builder.php
-share/pear/bootstrap/PEAR/Command.php
 share/pear/bootstrap/PEAR/Common.php
 share/pear/bootstrap/PEAR/Config.php
 share/pear/bootstrap/PEAR/Dependency.php
@@ -33,8 +42,19 @@ share/pear/bootstrap/PEAR/Remote.php
 share/pear/bootstrap/PEAR/RunTest.php
 share/pear/bootstrap/XML/RPC.php
 share/pear/bootstrap/XML/RPC/Server.php
+@unexec rm %D/lib/php/pear/.channels/.alias/pear.txt 2> /dev/null || true
+@unexec rm %D/lib/php/pear/.channels/.alias/pecl.txt 2> /dev/null || true
+@unexec rm %D/lib/php/pear/.channels/__uri.reg 2> /dev/null || true
+@unexec rm %D/lib/php/pear/.channels/pear.php.net.reg 2> /dev/null || true
+@unexec rm %D/lib/php/pear/.channels/pecl.php.net.reg 2> /dev/null || true
+@unexec rm %D/lib/php/pear/.depdb 2> /dev/null || true
+@unexec rm %D/lib/php/pear/.depdblock 2> /dev/null || true
 @unexec rm %D/lib/php/pear/.filemap 2> /dev/null || true
 @unexec rm %D/lib/php/pear/.lock 2> /dev/null || true
+@unexec rmdir %D/lib/php/pear/.channels/.alias 2> /dev/null || true
+@unexec rmdir %D/lib/php/pear/.channels 2> /dev/null || true
+@unexec rmdir %D/lib/php/pear/.registry/.channel.__uri 2> /dev/null || true
+@unexec rmdir %D/lib/php/pear/.registry/.channel.pecl.php.net 2> /dev/null || true
 @unexec rmdir %D/lib/php/pear/.registry 2> /dev/null || true
 @unexec rmdir %D/lib/php/pear 2> /dev/null || true
 @unexec rmdir %D/lib/php 2> /dev/null || true
-- 
cgit debian/1.2.3+git2.25.1-1-2-gaceb0