forked from oraoto/pib
-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathphp8.2.patch
311 lines (286 loc) · 11.8 KB
/
php8.2.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
diff --git a/third_party/php8.2-src/Zend/zend_atomic.h b/third_party/php8.2-src/Zend/zend_atomic.h
index 617cde0..fe9cba5 100644
--- a/third_party/php8.2-src/Zend/zend_atomic.h
+++ b/third_party/php8.2-src/Zend/zend_atomic.h
@@ -23,7 +23,7 @@
((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || (__GNUC__ > (x)))
/* Builtins are used to avoid library linkage */
-#if __has_feature(c_atomic)
+#if 0
#define HAVE_C11_ATOMICS 1
#elif ZEND_GCC_PREREQ(4, 7)
#define HAVE_GNUC_ATOMICS 1
diff --git a/third_party/php8.2-src/ext/openssl/openssl.c b/third_party/php8.2-src/ext/openssl/openssl.c
index f9c7f8c..2219409 100644
--- a/third_party/php8.2-src/ext/openssl/openssl.c
+++ b/third_party/php8.2-src/ext/openssl/openssl.c
@@ -1277,8 +1277,8 @@ PHP_MINIT_FUNCTION(openssl)
/* override the default tcp socket provider */
php_stream_xport_register("tcp", php_openssl_ssl_socket_factory);
- php_register_url_stream_wrapper("https", &php_stream_http_wrapper);
- php_register_url_stream_wrapper("ftps", &php_stream_ftp_wrapper);
+ // php_register_url_stream_wrapper("https", &php_stream_http_wrapper);
+ // php_register_url_stream_wrapper("ftps", &php_stream_ftp_wrapper);
REGISTER_INI_ENTRIES();
diff --git a/third_party/php8.2-src/ext/pdo/config.m4 b/third_party/php8.2-src/ext/pdo/config.m4
index 9b9a3e3..1148123 100644
--- a/third_party/php8.2-src/ext/pdo/config.m4
+++ b/third_party/php8.2-src/ext/pdo/config.m4
@@ -4,15 +4,14 @@ PHP_ARG_ENABLE([pdo],
[Disable PHP Data Objects support])],
[yes])
-if test "$PHP_PDO" != "no"; then
-
- dnl Make sure $PHP_PDO is 'yes' when it's not 'no' :)
- PHP_PDO=yes
+dnl Make sure $PHP_PDO is 'yes' when it's not 'no' :)
+PHP_PDO=yes
+if test "$PHP_PDO" != "no"; then
+ dnl so we always include the known-good working hack.
PHP_NEW_EXTENSION(pdo, pdo.c pdo_dbh.c pdo_stmt.c pdo_sql_parser.c pdo_sqlstate.c, $ext_shared)
PHP_ADD_EXTENSION_DEP(pdo, spl, true)
PHP_INSTALL_HEADERS(ext/pdo, [php_pdo.h php_pdo_driver.h php_pdo_error.h])
- dnl so we always include the known-good working hack.
PHP_ADD_MAKEFILE_FRAGMENT
fi
diff --git a/third_party/php8.2-src/ext/pdo_sqlite/config.m4 b/third_party/php8.2-src/ext/pdo_sqlite/config.m4
index 64311ea..57cfa19 100644
--- a/third_party/php8.2-src/ext/pdo_sqlite/config.m4
+++ b/third_party/php8.2-src/ext/pdo_sqlite/config.m4
@@ -10,25 +10,8 @@ if test "$PHP_PDO_SQLITE" != "no"; then
AC_MSG_ERROR([PDO is not enabled! Add --enable-pdo to your configure line.])
fi
- PHP_CHECK_PDO_INCLUDES
-
- PKG_CHECK_MODULES([SQLITE], [sqlite3 >= 3.7.7])
-
- PHP_EVAL_INCLINE($SQLITE_CFLAGS)
- PHP_EVAL_LIBLINE($SQLITE_LIBS, PDO_SQLITE_SHARED_LIBADD)
- AC_DEFINE(HAVE_PDO_SQLITELIB, 1, [Define to 1 if you have the pdo_sqlite extension enabled.])
-
- PHP_CHECK_LIBRARY(sqlite3, sqlite3_close_v2, [
- AC_DEFINE(HAVE_SQLITE3_CLOSE_V2, 1, [have sqlite3_close_v2])
- ], [], [$PDO_SQLITE_SHARED_LIBADD])
-
- PHP_CHECK_LIBRARY(sqlite3, sqlite3_column_table_name, [
- AC_DEFINE(HAVE_SQLITE3_COLUMN_TABLE_NAME, 1, [have sqlite3_column_table_name])
- ], [], [$PDO_SQLITE_SHARED_LIBADD])
-
- PHP_SUBST(PDO_SQLITE_SHARED_LIBADD)
PHP_NEW_EXTENSION(pdo_sqlite, pdo_sqlite.c sqlite_driver.c sqlite_statement.c,
- $ext_shared,,-I$pdo_cv_inc_path)
+ $ext_shared,,)
PHP_ADD_EXTENSION_DEP(pdo_sqlite, pdo)
fi
diff --git a/third_party/php8.2-src/ext/pdo_sqlite/pdo_sqlite.c b/third_party/php8.2-src/ext/pdo_sqlite/pdo_sqlite.c
index 81761b1..0942423 100644
--- a/third_party/php8.2-src/ext/pdo_sqlite/pdo_sqlite.c
+++ b/third_party/php8.2-src/ext/pdo_sqlite/pdo_sqlite.c
@@ -21,8 +21,8 @@
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
-#include "pdo/php_pdo.h"
-#include "pdo/php_pdo_driver.h"
+#include "../pdo/php_pdo.h"
+#include "../pdo/php_pdo_driver.h"
#include "php_pdo_sqlite.h"
#include "php_pdo_sqlite_int.h"
#include "zend_exceptions.h"
diff --git a/third_party/php8.2-src/ext/pdo_sqlite/sqlite_driver.c b/third_party/php8.2-src/ext/pdo_sqlite/sqlite_driver.c
index de5170a..2ea31b6 100644
--- a/third_party/php8.2-src/ext/pdo_sqlite/sqlite_driver.c
+++ b/third_party/php8.2-src/ext/pdo_sqlite/sqlite_driver.c
@@ -21,8 +21,8 @@
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
-#include "pdo/php_pdo.h"
-#include "pdo/php_pdo_driver.h"
+#include "../pdo/php_pdo.h"
+#include "../pdo/php_pdo_driver.h"
#include "php_pdo_sqlite.h"
#include "php_pdo_sqlite_int.h"
#include "zend_exceptions.h"
diff --git a/third_party/php8.2-src/ext/pdo_sqlite/sqlite_statement.c b/third_party/php8.2-src/ext/pdo_sqlite/sqlite_statement.c
index 90de059..8dc0ad3 100644
--- a/third_party/php8.2-src/ext/pdo_sqlite/sqlite_statement.c
+++ b/third_party/php8.2-src/ext/pdo_sqlite/sqlite_statement.c
@@ -21,8 +21,8 @@
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
-#include "pdo/php_pdo.h"
-#include "pdo/php_pdo_driver.h"
+#include "../pdo/php_pdo.h"
+#include "../pdo/php_pdo_driver.h"
#include "php_pdo_sqlite.h"
#include "php_pdo_sqlite_int.h"
diff --git a/third_party/php8.2-src/ext/sqlite3/config0.m4 b/third_party/php8.2-src/ext/sqlite3/config0.m4
index 2373d13..b94508f 100644
--- a/third_party/php8.2-src/ext/sqlite3/config0.m4
+++ b/third_party/php8.2-src/ext/sqlite3/config0.m4
@@ -5,26 +5,6 @@ PHP_ARG_WITH([sqlite3],
[yes])
if test $PHP_SQLITE3 != "no"; then
- PKG_CHECK_MODULES([SQLITE], [sqlite3 >= 3.7.7])
-
- PHP_EVAL_INCLINE($SQLITE_CFLAGS)
- PHP_EVAL_LIBLINE($SQLITE_LIBS, SQLITE3_SHARED_LIBADD)
- AC_DEFINE(HAVE_SQLITE3, 1, [Define to 1 if you have the sqlite3 extension enabled.])
-
- PHP_CHECK_LIBRARY(sqlite3, sqlite3_errstr, [
- AC_DEFINE(HAVE_SQLITE3_ERRSTR, 1, [have sqlite3_errstr function])
- ], [], [$SQLITE3_SHARED_LIBADD])
-
- PHP_CHECK_LIBRARY(sqlite3, sqlite3_expanded_sql, [
- AC_DEFINE(HAVE_SQLITE3_EXPANDED_SQL, 1, [have sqlite3_expanded_sql function])
- ], [], [$SQLITE3_SHARED_LIBADD])
-
- PHP_CHECK_LIBRARY(sqlite3,sqlite3_load_extension,
- [],
- [AC_DEFINE(SQLITE_OMIT_LOAD_EXTENSION, 1, [have sqlite3 with extension support])],
- [$SQLITE3_SHARED_LIBADD]
- )
-
PHP_NEW_EXTENSION(sqlite3, sqlite3.c, $ext_shared,,-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
PHP_SUBST(SQLITE3_SHARED_LIBADD)
fi
diff --git a/third_party/php8.2-src/ext/standard/basic_functions.c b/third_party/php8.2-src/ext/standard/basic_functions.c
index 6967307..d3601f6 100755
--- a/third_party/php8.2-src/ext/standard/basic_functions.c
+++ b/third_party/php8.2-src/ext/standard/basic_functions.c
@@ -355,8 +355,8 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */
php_register_url_stream_wrapper("glob", &php_glob_stream_wrapper);
#endif
php_register_url_stream_wrapper("data", &php_stream_rfc2397_wrapper);
- php_register_url_stream_wrapper("http", &php_stream_http_wrapper);
- php_register_url_stream_wrapper("ftp", &php_stream_ftp_wrapper);
+ // php_register_url_stream_wrapper("http", &php_stream_http_wrapper);
+ // php_register_url_stream_wrapper("ftp", &php_stream_ftp_wrapper);
BASIC_MINIT_SUBMODULE(hrtime)
diff --git a/third_party/php8.2-src/ext/standard/credits.c b/third_party/php8.2-src/ext/standard/credits.c
index 4e8722d..1343330 100644
--- a/third_party/php8.2-src/ext/standard/credits.c
+++ b/third_party/php8.2-src/ext/standard/credits.c
@@ -33,6 +33,11 @@ PHPAPI ZEND_COLD void php_print_credits(int flag) /* {{{ */
PUTS("PHP Credits\n");
}
+ php_info_print_table_start();
+ php_info_print_table_header(1, "php-wasm");
+ php_info_print_table_row(1, "Sean Morris & Oraoto");
+ php_info_print_table_end();
+
if (flag & PHP_CREDITS_GROUP) {
/* Group */
diff --git a/third_party/php8.2-src/ext/tokenizer/tokenizer.c b/third_party/php8.2-src/ext/tokenizer/tokenizer.c
index 20124db..33327c1 100644
--- a/third_party/php8.2-src/ext/tokenizer/tokenizer.c
+++ b/third_party/php8.2-src/ext/tokenizer/tokenizer.c
@@ -319,7 +319,7 @@ static void add_token(
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &token);
}
-static bool tokenize(zval *return_value, zend_string *source, zend_class_entry *token_class)
+bool tokenize(zval *return_value, zend_string *source, zend_class_entry *token_class)
{
zval source_zval;
zend_lex_state original_lex_state;
diff --git a/third_party/php8.2-src/main/fastcgi.c b/third_party/php8.2-src/main/fastcgi.c
index a77491f..7f9778f 100644
--- a/third_party/php8.2-src/main/fastcgi.c
+++ b/third_party/php8.2-src/main/fastcgi.c
@@ -553,6 +553,7 @@ void fcgi_shutdown(void)
{
if (is_initialized) {
zend_hash_destroy(&fcgi_mgmt_vars);
+ is_initialized = 0;
}
is_fastcgi = 0;
if (allowed_clients) {
diff --git a/third_party/php8.2-src/sapi/cgi/Makefile.frag b/third_party/php8.2-src/sapi/cgi/Makefile.frag
index 79e2afe..0956f43 100644
--- a/third_party/php8.2-src/sapi/cgi/Makefile.frag
+++ b/third_party/php8.2-src/sapi/cgi/Makefile.frag
@@ -1,7 +1,7 @@
cgi: $(SAPI_CGI_PATH)
$(SAPI_CGI_PATH): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_FASTCGI_OBJS) $(PHP_CGI_OBJS)
- $(BUILD_CGI)
+ $(BUILD_CGI) $(WASM_SHARED_LIBS)
install-cgi: $(SAPI_CGI_PATH)
@echo "Installing PHP CGI binary: $(INSTALL_ROOT)$(bindir)/"
diff --git a/third_party/php8.2-src/sapi/cgi/cgi_main.c b/third_party/php8.2-src/sapi/cgi/cgi_main.c
index b454680..e98bf3e 100644
--- a/third_party/php8.2-src/sapi/cgi/cgi_main.c
+++ b/third_party/php8.2-src/sapi/cgi/cgi_main.c
@@ -18,7 +18,7 @@
| Dmitry Stogov <[email protected]> |
+----------------------------------------------------------------------+
*/
-
+#include <emscripten.h>
#include "php.h"
#include "php_globals.h"
#include "php_variables.h"
@@ -1858,7 +1858,8 @@ int main(int argc, char *argv[])
SG(request_info).path_translated = NULL;
#endif
- cgi_sapi_module.executable_location = argv[0];
+ // cgi_sapi_module.executable_location = argv[0];
+ cgi_sapi_module.executable_location = NULL;
if (!cgi && !fastcgi && !bindpath) {
cgi_sapi_module.additional_functions = additional_functions;
}
@@ -1934,8 +1935,10 @@ consult the installation file that came with this distribution, or visit \n\
}
/* make php call us to get _ENV vars */
- php_php_import_environment_variables = php_import_environment_variables;
- php_import_environment_variables = cgi_php_import_environment_variables;
+ if(php_import_environment_variables != cgi_php_import_environment_variables) {
+ php_php_import_environment_variables = php_import_environment_variables;
+ php_import_environment_variables = cgi_php_import_environment_variables;
+ }
if (fastcgi) {
/* How many times to run PHP scripts before dying */
@@ -2640,3 +2643,18 @@ consult the installation file that came with this distribution, or visit \n\
return exit_status;
}
/* }}} */
+
+void EMSCRIPTEN_KEEPALIVE wasm_sapi_cgi_init(void)
+{
+ putenv("USE_ZEND_ALLOC=0");
+}
+
+char* EMSCRIPTEN_KEEPALIVE wasm_sapi_cgi_getenv(char *name)
+{
+ return getenv(name);
+}
+
+char* EMSCRIPTEN_KEEPALIVE wasm_sapi_cgi_putenv(char *name, char *value)
+{
+ return _sapi_cgi_putenv(name, strlen(name), value);
+}
diff --git a/third_party/php8.2-src/sapi/cli/Makefile.frag b/third_party/php8.2-src/sapi/cli/Makefile.frag
index aa1d642..649533d 100644
--- a/third_party/php8.2-src/sapi/cli/Makefile.frag
+++ b/third_party/php8.2-src/sapi/cli/Makefile.frag
@@ -1,7 +1,7 @@
cli: $(SAPI_CLI_PATH)
$(SAPI_CLI_PATH): $(PHP_GLOBAL_OBJS) $(PHP_BINARY_OBJS) $(PHP_CLI_OBJS)
- $(BUILD_CLI)
+ $(BUILD_CLI) $(WASM_SHARED_LIBS)
install-cli: $(SAPI_CLI_PATH)
@echo "Installing PHP CLI binary: $(INSTALL_ROOT)$(bindir)/"
diff --git a/third_party/php8.2-src/sapi/embed/php_embed.c b/third_party/php8.2-src/sapi/embed/php_embed.c
index 4b94bd9..fc44d30 100644
--- a/third_party/php8.2-src/sapi/embed/php_embed.c
+++ b/third_party/php8.2-src/sapi/embed/php_embed.c
@@ -243,8 +243,8 @@ EMBED_SAPI_API int php_embed_init(int argc, char **argv)
return FAILURE;
}
- SG(headers_sent) = 1;
- SG(request_info).no_headers = 1;
+ SG(headers_sent) = 0;
+ SG(request_info).no_headers = 0;
php_register_variable("PHP_SELF", "-", NULL);
return SUCCESS;