]> git.pld-linux.org Git - packages/php.git/blame - php-apache2.patch
- added session-unregister patch to avoid httpd SEGVs with msession module
[packages/php.git] / php-apache2.patch
CommitLineData
1fb38fc0
AM
1diff -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
4@@ -88,7 +88,7 @@
5 php_dir_entry *pe;
6 php_dir_entry *data;
7 char *str;
8- uint str_len;
9+ ulong str_len;
10 ulong num_index;
11
12 phpapdebug((stderr, "Merge dir (%p) (%p)\n", base_conf, new_conf));
13@@ -110,7 +110,7 @@
14 {
15 php_conf_rec *d = dummy;
16 char *str;
17- uint str_len;
18+ ulong str_len;
19 php_dir_entry *data;
20
21 for (zend_hash_internal_pointer_reset(&d->config);
22diff -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
25@@ -1,8 +1,8 @@
26 /*
27 +----------------------------------------------------------------------+
28- | PHP version 4.0 |
29+ | PHP Version 4 |
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 |
36@@ -12,7 +12,7 @@
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 +----------------------------------------------------------------------+
43 */
44
45diff -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
48@@ -38,6 +38,7 @@
49 {
50 zval **p1;
51 php_struct *ctx;
52+ SLS_FETCH();
53
54 if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &p1) == FAILURE)
55 return NULL;
56@@ -109,6 +110,7 @@
57 php_struct *ctx;
58 apr_array_header_t *arr;
59 char *key, *val;
60+ SLS_FETCH();
61
62 if (array_init(return_value) == FAILURE) {
63 RETURN_FALSE;
64@@ -135,7 +137,7 @@
65 };
66
67 static zend_module_entry php_apache_module = {
68- STANDARD_MODULE_HEADER,
69+ STANDARD_MODULE_HEADER,
70 "Apache 2.0",
71 apache_functions,
72 NULL,
73diff -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
76@@ -1,8 +1,8 @@
77 /*
78 +----------------------------------------------------------------------+
79- | PHP version 4.0 |
80+ | PHP Version 4 |
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 |
87@@ -48,6 +48,7 @@
88 {
89 apr_bucket *b;
90 apr_bucket_brigade *bb;
91+ apr_bucket_alloc_t *ba;
92 php_struct *ctx;
93 uint now;
94
95@@ -55,10 +56,11 @@
96
97 if (str_length == 0) return 0;
98
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);
107 str += now;
108 str_length -= now;
109@@ -145,7 +147,7 @@
110 php_apache_sapi_register_variables(zval *track_vars_array TSRMLS_DC)
111 {
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);
115 char *key, *val;
116
117 APR_ARRAY_FOREACH_OPEN(arr, key, val)
118@@ -161,15 +163,20 @@
119 {
120 php_struct *ctx = server_context;
121 apr_bucket_brigade *bb;
122+ apr_bucket_alloc_t *ba;
123 apr_bucket *b;
124
125+ if (!server_context)
126+ return;
127+
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.
131 */
132
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();
141@@ -182,8 +189,13 @@
142 TSRMLS_FETCH();
143
144 ctx = SG(server_context);
145-
146- apr_file_puts(msg, ctx->f->r->server->error_log);
147+
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
152+ */
153+ ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO | APLOG_STARTUP, 0, ctx->f->r->server, "%s", msg);
154 }
155
156 static sapi_module_struct apache2_sapi_module = {
157@@ -226,11 +238,11 @@
158 if (ctx == NULL) { \
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); \
163 }
164
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)
168 {
169 php_struct *ctx;
170 long old_index;
171@@ -240,11 +252,15 @@
172 apr_status_t rv;
173 TSRMLS_FETCH();
174
175+ if (f->r->proxyreq) {
176+ return ap_get_brigade(f->next, bb, mode, block, readbytes);
177+ }
178+
179 ctx = SG(server_context);
180
181 INIT_CTX;
182
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) {
185 return rv;
186 }
187
188@@ -307,6 +323,14 @@
189 void *conf = ap_get_module_config(f->r->per_dir_config, &php4_module);
190 TSRMLS_FETCH();
191
192+ if (f->r->proxyreq) {
193+ return ap_pass_brigade(f->next, bb);
194+ }
195+
196+ /* setup standard CGI variables */
197+ ap_add_common_vars(f->r);
198+ ap_add_cgi_vars(f->r);
199+
200 ctx = SG(server_context);
201 INIT_CTX;
202
203@@ -361,9 +385,9 @@
204 php_execute_script(&zfd TSRMLS_CC);
205 } else {
206
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"
209
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);
213 }
214 }
215@@ -372,7 +396,7 @@
216
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);
222
223 return ap_pass_brigade(f->next, bb);
224@@ -391,21 +415,67 @@
225 return APR_SUCCESS;
226 }
227
228-static void
229-php_apache_server_startup(apr_pool_t *pchild, server_rec *s)
230+static void php_apache_add_version(apr_pool_t *p)
231+{
232+ TSRMLS_FETCH();
233+ if (PG(expose_php)) {
234+ ap_add_version_component(p, "PHP/" PHP_VERSION);
235+ }
236+}
237+
238+static int
239+php_apache_server_startup(apr_pool_t *pconf, apr_pool_t *plog,
240+ apr_pool_t *ptemp, server_rec *s)
241 {
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);
249+
250+ return OK;
251+}
252+
253+static void php_add_filter(request_rec *r, ap_filter_t *f)
254+{
255+ int output = (f == r->output_filters);
256+
257+ /* for those who still have Set*Filter PHP configured */
258+ while (f) {
259+ if (strcmp(f->frec->name, "PHP") == 0) {
260+ ap_log_error(APLOG_MARK, APLOG_WARNING | APLOG_NOERRNO,
261+ 0, r->server,
262+ "\"Set%sFilter PHP\" already configured for %s",
263+ output ? "Output" : "Input", r->uri);
264+ return;
265+ }
266+ f = f->next;
267+ }
268+
269+ if (output) {
270+ ap_add_output_filter("PHP", NULL, r, r->connection);
271+ }
272+ else {
273+ ap_add_input_filter("PHP", NULL, r, r->connection);
274+ }
275+}
276+
277+static void php_insert_filter(request_rec *r)
278+{
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);
283+ }
284 }
285
286 static void php_register_hook(apr_pool_t *p)
287 {
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);
295 }
296
297 AP_MODULE_DECLARE_DATA module php4_module = {
298@@ -417,3 +487,12 @@
299 php_dir_cmds, /* command apr_table_t */
300 php_register_hook /* register hooks */
301 };
302+
303+/*
304+ * Local variables:
305+ * tab-width: 4
306+ * c-basic-offset: 4
307+ * End:
308+ * vim600: sw=4 ts=4 fdm=marker
309+ * vim<600: sw=4 ts=4
310+ */
This page took 0.070592 seconds and 4 git commands to generate.