forked from oraoto/pib
-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathphp7.4.patch
171 lines (159 loc) · 6.34 KB
/
php7.4.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
diff --git a/third_party/php7.4-src/Zend/zend_portability.h b/third_party/php7.4-src/Zend/zend_portability.h
index 58c42a2..bf1b106 100644
--- a/third_party/php7.4-src/Zend/zend_portability.h
+++ b/third_party/php7.4-src/Zend/zend_portability.h
@@ -424,6 +424,20 @@ char *alloca();
# define LONG_MAX 2147483647L
#endif
+#if defined(__cplusplus) && __cplusplus >= 201103L
+extern "C++" {
+# include <cmath>
+}
+# define zend_isnan std::isnan
+# define zend_isinf std::isinf
+# define zend_finite std::isfinite
+#else
+# include <math.h>
+# define zend_isnan(a) isnan(a)
+# define zend_isinf(a) isinf(a)
+# define zend_finite(a) isfinite(a)
+#endif
+
#ifndef LONG_MIN
# define LONG_MIN (- LONG_MAX - 1)
#endif
diff --git a/third_party/php7.4-src/ext/pdo_sqlite/pdo_sqlite.c b/third_party/php7.4-src/ext/pdo_sqlite/pdo_sqlite.c
index 5c2fd63..9e63eeb 100644
--- a/third_party/php7.4-src/ext/pdo_sqlite/pdo_sqlite.c
+++ b/third_party/php7.4-src/ext/pdo_sqlite/pdo_sqlite.c
@@ -23,8 +23,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/php7.4-src/ext/pdo_sqlite/sqlite_driver.c b/third_party/php7.4-src/ext/pdo_sqlite/sqlite_driver.c
index 0595bd0..ededbf1 100644
--- a/third_party/php7.4-src/ext/pdo_sqlite/sqlite_driver.c
+++ b/third_party/php7.4-src/ext/pdo_sqlite/sqlite_driver.c
@@ -23,8 +23,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/php7.4-src/ext/pdo_sqlite/sqlite_statement.c b/third_party/php7.4-src/ext/pdo_sqlite/sqlite_statement.c
index a8723da..41a7af8 100644
--- a/third_party/php7.4-src/ext/pdo_sqlite/sqlite_statement.c
+++ b/third_party/php7.4-src/ext/pdo_sqlite/sqlite_statement.c
@@ -23,8 +23,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/php7.4-src/ext/phar/Makefile.frag b/third_party/php7.4-src/ext/phar/Makefile.frag
index 58789ca..dd5e6a7 100644
--- a/third_party/php7.4-src/ext/phar/Makefile.frag
+++ b/third_party/php7.4-src/ext/phar/Makefile.frag
@@ -31,13 +31,13 @@ $(builddir)/phar/phar.inc: $(srcdir)/phar/phar.inc
$(builddir)/phar.php: $(srcdir)/build_precommand.php $(srcdir)/phar/*.inc $(srcdir)/phar/*.php $(SAPI_CLI_PATH)
-@echo "Generating phar.php"
- @$(PHP_PHARCMD_EXECUTABLE) $(PHP_PHARCMD_SETTINGS) $(srcdir)/build_precommand.php > $(builddir)/phar.php
+ -@$(PHP_PHARCMD_EXECUTABLE) $(PHP_PHARCMD_SETTINGS) $(srcdir)/build_precommand.php > $(builddir)/phar.php
$(builddir)/phar.phar: $(builddir)/phar.php $(builddir)/phar/phar.inc $(srcdir)/phar/*.inc $(srcdir)/phar/*.php $(SAPI_CLI_PATH)
-@echo "Generating phar.phar"
-@rm -f $(builddir)/phar.phar
-@rm -f $(srcdir)/phar.phar
- @$(PHP_PHARCMD_EXECUTABLE) $(PHP_PHARCMD_SETTINGS) $(builddir)/phar.php pack -f $(builddir)/phar.phar -a pharcommand -c auto -x \\.svn -p 0 -s $(srcdir)/phar/phar.php -h sha1 -b "$(PHP_PHARCMD_BANG)" $(srcdir)/phar/
+ -@$(PHP_PHARCMD_EXECUTABLE) $(PHP_PHARCMD_SETTINGS) $(builddir)/phar.php pack -f $(builddir)/phar.phar -a pharcommand -c auto -x \\.svn -p 0 -s $(srcdir)/phar/phar.php -h sha1 -b "$(PHP_PHARCMD_BANG)" $(srcdir)/phar/
-@chmod +x $(builddir)/phar.phar
install-pharcmd: pharcmd
diff --git a/third_party/php7.4-src/main/fastcgi.c b/third_party/php7.4-src/main/fastcgi.c
index f8044ff..f4537a4 100644
--- a/third_party/php7.4-src/main/fastcgi.c
+++ b/third_party/php7.4-src/main/fastcgi.c
@@ -560,6 +560,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/php7.4-src/sapi/cgi/cgi_main.c b/third_party/php7.4-src/sapi/cgi/cgi_main.c
index cd79475..5c0039d 100644
--- a/third_party/php7.4-src/sapi/cgi/cgi_main.c
+++ b/third_party/php7.4-src/sapi/cgi/cgi_main.c
@@ -25,6 +25,7 @@
#include "php_globals.h"
#include "php_variables.h"
#include "zend_modules.h"
+#include <emscripten.h>
#include "SAPI.h"
@@ -1911,7 +1912,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;
}
@@ -1987,8 +1989,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 */
@@ -2709,3 +2713,18 @@ parent_out:
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/php7.4-src/sapi/embed/php_embed.c b/third_party/php7.4-src/sapi/embed/php_embed.c
index 4c7dec6..65762b8 100644
--- a/third_party/php7.4-src/sapi/embed/php_embed.c
+++ b/third_party/php7.4-src/sapi/embed/php_embed.c
@@ -211,8 +211,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;