1 diff -urN php-4.1.2.org/sapi/apache2filter/apache_config.c php-4.1.2/sapi/apache2filter/apache_config.c
2 --- php-4.1.2.org/sapi/apache2filter/apache_config.c Mon Apr 8 02:40:24 2002
3 +++ php-4.1.2/sapi/apache2filter/apache_config.c Wed Feb 28 15:11:34 2001
12 phpapdebug((stderr, "Merge dir (%p) (%p)\n", base_conf, new_conf));
15 php_conf_rec *d = dummy;
21 for (zend_hash_internal_pointer_reset(&d->config);
22 diff -urN php-4.1.2.org/sapi/apache2filter/php_apache.h php-4.1.2/sapi/apache2filter/php_apache.h
23 --- php-4.1.2.org/sapi/apache2filter/php_apache.h Mon Apr 8 02:40:24 2002
24 +++ php-4.1.2/sapi/apache2filter/php_apache.h Mon Apr 8 02:34:03 2002
27 +----------------------------------------------------------------------+
30 +----------------------------------------------------------------------+
31 - | Copyright (c) 1997-2001 The PHP Group |
32 + | Copyright (c) 1997-2002 The PHP Group |
33 +----------------------------------------------------------------------+
34 | This source file is subject to version 2.02 of the PHP license, |
35 | that is bundled with this package in the file LICENSE, and is |
37 | obtain it through the world-wide-web, please send a note to |
38 | license@php.net so we can mail you a copy immediately. |
39 +----------------------------------------------------------------------+
40 - | Authors: Sascha Schumann <sascha@schumann.cx> |
41 + | Author: Sascha Schumann <sascha@schumann.cx> |
42 +----------------------------------------------------------------------+
45 diff -urN php-4.1.2.org/sapi/apache2filter/php_functions.c php-4.1.2/sapi/apache2filter/php_functions.c
46 --- php-4.1.2.org/sapi/apache2filter/php_functions.c Mon Apr 8 02:40:24 2002
47 +++ php-4.1.2/sapi/apache2filter/php_functions.c Mon Apr 8 02:39:31 2002
54 if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &p1) == FAILURE)
58 apr_array_header_t *arr;
62 if (array_init(return_value) == FAILURE) {
67 static zend_module_entry php_apache_module = {
68 - STANDARD_MODULE_HEADER,
69 + STANDARD_MODULE_HEADER,
73 diff -urN php-4.1.2.org/sapi/apache2filter/sapi_apache2.c php-4.1.2/sapi/apache2filter/sapi_apache2.c
74 --- php-4.1.2.org/sapi/apache2filter/sapi_apache2.c Mon Apr 8 02:40:24 2002
75 +++ php-4.1.2/sapi/apache2filter/sapi_apache2.c Mon Apr 8 02:30:57 2002
78 +----------------------------------------------------------------------+
81 +----------------------------------------------------------------------+
82 - | Copyright (c) 1997-2001 The PHP Group |
83 + | Copyright (c) 1997-2002 The PHP Group |
84 +----------------------------------------------------------------------+
85 | This source file is subject to version 2.02 of the PHP license, |
86 | that is bundled with this package in the file LICENSE, and is |
90 apr_bucket_brigade *bb;
91 + apr_bucket_alloc_t *ba;
97 if (str_length == 0) return 0;
99 - bb = apr_brigade_create(ctx->f->r->pool);
100 + ba = ctx->f->r->connection->bucket_alloc;
101 + bb = apr_brigade_create(ctx->f->r->pool, ba);
102 while (str_length > 0) {
103 now = MIN(str_length, 4096);
104 - b = apr_bucket_transient_create(str, now);
105 + b = apr_bucket_transient_create(str, now, ba);
106 APR_BRIGADE_INSERT_TAIL(bb, b);
110 php_apache_sapi_register_variables(zval *track_vars_array TSRMLS_DC)
112 php_struct *ctx = SG(server_context);
113 - apr_array_header_t *arr = apr_table_elts(ctx->f->r->subprocess_env);
114 + const apr_array_header_t *arr = apr_table_elts(ctx->f->r->subprocess_env);
117 APR_ARRAY_FOREACH_OPEN(arr, key, val)
118 @@ -161,15 +163,20 @@
120 php_struct *ctx = server_context;
121 apr_bucket_brigade *bb;
122 + apr_bucket_alloc_t *ba;
125 + if (!server_context)
128 /* Send a flush bucket down the filter chain. The current default
129 * handler seems to act on the first flush bucket, but ignores
130 * all further flush buckets.
133 - bb = apr_brigade_create(ctx->f->r->pool);
134 - b = apr_bucket_flush_create();
135 + ba = ctx->f->r->connection->bucket_alloc;
136 + bb = apr_brigade_create(ctx->f->r->pool, ba);
137 + b = apr_bucket_flush_create(ba);
138 APR_BRIGADE_INSERT_TAIL(bb, b);
139 if (ap_pass_brigade(ctx->f->next, bb) != APR_SUCCESS) {
140 php_handle_aborted_connection();
144 ctx = SG(server_context);
146 - apr_file_puts(msg, ctx->f->r->server->error_log);
148 + /* We use APLOG_STARTUP because it keeps us from printing the
149 + * data and time information at the beginning of the error log
150 + * line. Not sure if this is correct, but it mirrors what happens
151 + * with Apache 1.3 -- rbb
153 + ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO | APLOG_STARTUP, 0, ctx->f->r->server, "%s", msg);
156 static sapi_module_struct apache2_sapi_module = {
157 @@ -226,11 +238,11 @@
159 /* Initialize filter context */ \
160 SG(server_context) = ctx = apr_pcalloc(f->r->pool, sizeof(*ctx)); \
161 - ctx->bb = apr_brigade_create(f->c->pool); \
162 + ctx->bb = apr_brigade_create(f->c->pool, f->c->bucket_alloc); \
165 static int php_input_filter(ap_filter_t *f, apr_bucket_brigade *bb,
166 - ap_input_mode_t mode, apr_size_t *readbytes)
167 + ap_input_mode_t mode, apr_read_type_e block, apr_off_t readbytes)
171 @@ -240,11 +252,15 @@
175 + if (f->r->proxyreq) {
176 + return ap_get_brigade(f->next, bb, mode, block, readbytes);
179 ctx = SG(server_context);
183 - if ((rv = ap_get_brigade(f->next, bb, mode, readbytes)) != APR_SUCCESS) {
184 + if ((rv = ap_get_brigade(f->next, bb, mode, block, readbytes)) != APR_SUCCESS) {
189 void *conf = ap_get_module_config(f->r->per_dir_config, &php4_module);
192 + if (f->r->proxyreq) {
193 + return ap_pass_brigade(f->next, bb);
196 + /* setup standard CGI variables */
197 + ap_add_common_vars(f->r);
198 + ap_add_cgi_vars(f->r);
200 ctx = SG(server_context);
204 php_execute_script(&zfd TSRMLS_CC);
207 -#define NO_DATA "The PHP Filter did not receive suitable input data"
208 +#define PHP_NO_DATA "The PHP Filter did not receive suitable input data"
210 - eos = apr_bucket_transient_create(NO_DATA, sizeof(NO_DATA)-1);
211 + eos = apr_bucket_transient_create(PHP_NO_DATA, sizeof(PHP_NO_DATA)-1, f->c->bucket_alloc);
212 APR_BRIGADE_INSERT_HEAD(bb, eos);
217 SG(server_context) = 0;
218 /* Pass EOS bucket to next filter to signal end of request */
219 - eos = apr_bucket_eos_create();
220 + eos = apr_bucket_eos_create(f->c->bucket_alloc);
221 APR_BRIGADE_INSERT_TAIL(bb, eos);
223 return ap_pass_brigade(f->next, bb);
224 @@ -391,21 +415,67 @@
229 -php_apache_server_startup(apr_pool_t *pchild, server_rec *s)
230 +static void php_apache_add_version(apr_pool_t *p)
233 + if (PG(expose_php)) {
234 + ap_add_version_component(p, "PHP/" PHP_VERSION);
239 +php_apache_server_startup(apr_pool_t *pconf, apr_pool_t *plog,
240 + apr_pool_t *ptemp, server_rec *s)
242 tsrm_startup(1, 1, 0, NULL);
243 sapi_startup(&apache2_sapi_module);
244 apache2_sapi_module.startup(&apache2_sapi_module);
245 - apr_pool_cleanup_register(pchild, NULL, php_apache_server_shutdown, NULL);
246 + apr_pool_cleanup_register(pconf, NULL, php_apache_server_shutdown, apr_pool_cleanup_null);
247 php_apache_register_module();
248 + php_apache_add_version(pconf);
253 +static void php_add_filter(request_rec *r, ap_filter_t *f)
255 + int output = (f == r->output_filters);
257 + /* for those who still have Set*Filter PHP configured */
259 + if (strcmp(f->frec->name, "PHP") == 0) {
260 + ap_log_error(APLOG_MARK, APLOG_WARNING | APLOG_NOERRNO,
262 + "\"Set%sFilter PHP\" already configured for %s",
263 + output ? "Output" : "Input", r->uri);
270 + ap_add_output_filter("PHP", NULL, r, r->connection);
273 + ap_add_input_filter("PHP", NULL, r, r->connection);
277 +static void php_insert_filter(request_rec *r)
279 + if (r->content_type &&
280 + strcmp(r->content_type, "application/x-httpd-php") == 0) {
281 + php_add_filter(r, r->output_filters);
282 + php_add_filter(r, r->input_filters);
286 static void php_register_hook(apr_pool_t *p)
288 - ap_hook_child_init(php_apache_server_startup, NULL, NULL, APR_HOOK_MIDDLE);
289 - ap_register_output_filter("PHP", php_output_filter, AP_FTYPE_CONTENT);
290 - ap_register_input_filter("PHP", php_input_filter, AP_FTYPE_CONTENT);
291 + ap_hook_post_config(php_apache_server_startup, NULL, NULL, APR_HOOK_MIDDLE);
292 + ap_hook_insert_filter(php_insert_filter, NULL, NULL, APR_HOOK_MIDDLE);
293 + ap_register_output_filter("PHP", php_output_filter, AP_FTYPE_RESOURCE);
294 + ap_register_input_filter("PHP", php_input_filter, AP_FTYPE_RESOURCE);
297 AP_MODULE_DECLARE_DATA module php4_module = {
299 php_dir_cmds, /* command apr_table_t */
300 php_register_hook /* register hooks */
306 + * c-basic-offset: 4
308 + * vim600: sw=4 ts=4 fdm=marker
309 + * vim<600: sw=4 ts=4