Skip to content

Commit 52ebe9a

Browse files
committed
Add cli check pathes for 80
1 parent e5f0cb8 commit 52ebe9a

File tree

2 files changed

+174
-126
lines changed

2 files changed

+174
-126
lines changed

patches/cli_checks.patch

Lines changed: 0 additions & 126 deletions
This file was deleted.

patches/cli_checks_80.patch

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c
2+
index bc5a6b2e23..710515b6c1 100644
3+
--- a/TSRM/tsrm_win32.c
4+
+++ b/TSRM/tsrm_win32.c
5+
@@ -531,7 +531,7 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd,
6+
}
7+
8+
dwCreateFlags = NORMAL_PRIORITY_CLASS;
9+
- if (strcmp(sapi_module.name, "cli") != 0) {
10+
+ if (strcmp(sapi_module.name, "cli") != 0 && strcmp(sapi_module.name, "micro") != 0) {
11+
dwCreateFlags |= CREATE_NO_WINDOW;
12+
}
13+
14+
diff --git a/ext/ffi/ffi.c b/ext/ffi/ffi.c
15+
index fc8bb9a1b0..2fd083d912 100644
16+
--- a/ext/ffi/ffi.c
17+
+++ b/ext/ffi/ffi.c
18+
@@ -4935,7 +4935,7 @@ ZEND_MINIT_FUNCTION(ffi)
19+
20+
REGISTER_INI_ENTRIES();
21+
22+
- FFI_G(is_cli) = strcmp(sapi_module.name, "cli") == 0;
23+
+ FFI_G(is_cli) = strcmp(sapi_module.name, "cli") == 0 || strcmp(sapi_module.name, "micro") == 0;
24+
25+
INIT_NS_CLASS_ENTRY(ce, "FFI", "Exception", NULL);
26+
zend_ffi_exception_ce = zend_register_internal_class_ex(&ce, zend_ce_error);
27+
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
28+
index c195ad7d2c..eef18fd10a 100644
29+
--- a/ext/opcache/ZendAccelerator.c
30+
+++ b/ext/opcache/ZendAccelerator.c
31+
@@ -2622,7 +2622,7 @@ static inline int accel_find_sapi(void)
32+
}
33+
}
34+
if (ZCG(accel_directives).enable_cli && (
35+
- strcmp(sapi_module.name, "cli") == 0
36+
+ strcmp(sapi_module.name, "cli") == 0 || strcmp(sapi_module.name, "micro") == 0
37+
|| strcmp(sapi_module.name, "phpdbg") == 0)) {
38+
return SUCCESS;
39+
}
40+
@@ -2916,7 +2916,7 @@ static int accel_startup(zend_extension *extension)
41+
42+
#ifdef HAVE_HUGE_CODE_PAGES
43+
if (ZCG(accel_directives).huge_code_pages &&
44+
- (strcmp(sapi_module.name, "cli") == 0 ||
45+
+ (strcmp(sapi_module.name, "cli") == 0 || strcmp(sapi_module.name, "micro") == 0 ||
46+
strcmp(sapi_module.name, "cli-server") == 0 ||
47+
strcmp(sapi_module.name, "cgi-fcgi") == 0 ||
48+
strcmp(sapi_module.name, "fpm-fcgi") == 0)) {
49+
@@ -2928,7 +2928,7 @@ static int accel_startup(zend_extension *extension)
50+
if (accel_find_sapi() == FAILURE) {
51+
accel_startup_ok = 0;
52+
if (!ZCG(accel_directives).enable_cli &&
53+
- strcmp(sapi_module.name, "cli") == 0) {
54+
+ (strcmp(sapi_module.name, "cli") == 0 || strcmp(sapi_module.name, "micro") == 0)) {
55+
zps_startup_failure("Opcode Caching is disabled for CLI", NULL, accelerator_remove_cb);
56+
} else {
57+
zps_startup_failure("Opcode Caching is only supported in Apache, FPM, FastCGI and LiteSpeed SAPIs", NULL, accelerator_remove_cb);
58+
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
59+
index d9b9d94c6f..744c715b38 100644
60+
--- a/ext/pcre/php_pcre.c
61+
+++ b/ext/pcre/php_pcre.c
62+
@@ -291,7 +291,7 @@ static PHP_GINIT_FUNCTION(pcre) /* {{{ */
63+
64+
/* If we're on the CLI SAPI, there will only be one request, so we don't need the
65+
* cache to survive after RSHUTDOWN. */
66+
- pcre_globals->per_request_cache = strcmp(sapi_module.name, "cli") == 0;
67+
+ pcre_globals->per_request_cache = strcmp(sapi_module.name, "cli") == 0 || strcmp(sapi_module.name, "micro") == 0;
68+
if (!pcre_globals->per_request_cache) {
69+
zend_hash_init(&pcre_globals->pcre_cache, 0, NULL, php_free_pcre_cache, 1);
70+
}
71+
diff --git a/ext/readline/readline_cli.c b/ext/readline/readline_cli.c
72+
index 2930796ae7..20ad2706c7 100644
73+
--- a/ext/readline/readline_cli.c
74+
+++ b/ext/readline/readline_cli.c
75+
@@ -721,7 +721,7 @@ typedef cli_shell_callbacks_t *(__cdecl *get_cli_shell_callbacks)(void);
76+
get_cli_shell_callbacks get_callbacks; \
77+
HMODULE hMod = GetModuleHandle("php.exe"); \
78+
(cb) = NULL; \
79+
- if (strlen(sapi_module.name) >= 3 && 0 == strncmp("cli", sapi_module.name, 3)) { \
80+
+ if (0 == strncmp("cli", sapi_module.name, 3) || 0 == strncmp("micro", sapi_module.name, 5)) { \
81+
get_callbacks = (get_cli_shell_callbacks)GetProcAddress(hMod, "php_cli_get_shell_callbacks"); \
82+
if (get_callbacks) { \
83+
(cb) = get_callbacks(); \
84+
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c
85+
index cd91e68fd3..f270eb5a15 100644
86+
--- a/ext/sqlite3/sqlite3.c
87+
+++ b/ext/sqlite3/sqlite3.c
88+
@@ -400,7 +400,7 @@ PHP_METHOD(SQLite3, loadExtension)
89+
90+
#ifdef ZTS
91+
if ((strncmp(sapi_module.name, "cgi", 3) != 0) &&
92+
- (strcmp(sapi_module.name, "cli") != 0) &&
93+
+ (strcmp(sapi_module.name, "cli") != 0) && (strcmp(sapi_module.name, "micro") != 0) &&
94+
(strncmp(sapi_module.name, "embed", 5) != 0)
95+
) { php_sqlite3_error(db_obj, "Not supported in multithreaded Web servers");
96+
RETURN_FALSE;
97+
diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c
98+
index c5743c3361..b2dd79f5c4 100644
99+
--- a/ext/standard/php_fopen_wrapper.c
100+
+++ b/ext/standard/php_fopen_wrapper.c
101+
@@ -242,7 +242,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
102+
}
103+
return NULL;
104+
}
105+
- if (!strcmp(sapi_module.name, "cli")) {
106+
+ if (!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "micro")) {
107+
static int cli_in = 0;
108+
fd = STDIN_FILENO;
109+
if (cli_in) {
110+
@@ -258,7 +258,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
111+
pipe_requested = 1;
112+
#endif
113+
} else if (!strcasecmp(path, "stdout")) {
114+
- if (!strcmp(sapi_module.name, "cli")) {
115+
+ if (!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "micro")) {
116+
static int cli_out = 0;
117+
fd = STDOUT_FILENO;
118+
if (cli_out++) {
119+
@@ -274,7 +274,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
120+
pipe_requested = 1;
121+
#endif
122+
} else if (!strcasecmp(path, "stderr")) {
123+
- if (!strcmp(sapi_module.name, "cli")) {
124+
+ if (!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "micro")) {
125+
static int cli_err = 0;
126+
fd = STDERR_FILENO;
127+
if (cli_err++) {
128+
@@ -295,7 +295,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa
129+
zend_long fildes_ori;
130+
int dtablesize;
131+
132+
- if (strcmp(sapi_module.name, "cli")) {
133+
+ if (strcmp(sapi_module.name, "cli") && strcmp(sapi_module.name, "micro")) {
134+
if (options & REPORT_ERRORS) {
135+
php_error_docref(NULL, E_WARNING, "Direct access to file descriptors is only available from command-line PHP");
136+
}
137+
diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c
138+
index 03b55c3eac..5bb0472f76 100644
139+
--- a/ext/standard/proc_open.c
140+
+++ b/ext/standard/proc_open.c
141+
@@ -1136,7 +1136,7 @@ PHP_FUNCTION(proc_open)
142+
}
143+
144+
dwCreateFlags = NORMAL_PRIORITY_CLASS;
145+
- if(strcmp(sapi_module.name, "cli") != 0) {
146+
+ if(strcmp(sapi_module.name, "cli") != 0 && strcmp(sapi_module.name, "micro") != 0) {
147+
dwCreateFlags |= CREATE_NO_WINDOW;
148+
}
149+
if (create_process_group) {
150+
diff --git a/main/main.c b/main/main.c
151+
index 7bd5400760..f0a71d7915 100644
152+
--- a/main/main.c
153+
+++ b/main/main.c
154+
@@ -480,7 +480,7 @@ static PHP_INI_DISP(display_errors_mode)
155+
mode = php_get_display_errors_mode(tmp_value, tmp_value_length);
156+
157+
/* Display 'On' for other SAPIs instead of STDOUT or STDERR */
158+
- cgi_or_cli = (!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "cgi") || !strcmp(sapi_module.name, "phpdbg"));
159+
+ cgi_or_cli = (!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "cgi") || !strcmp(sapi_module.name, "phpdbg") || !strcmp(sapi_module.name, "micro"));
160+
161+
switch (mode) {
162+
case PHP_DISPLAY_ERRORS_STDERR:
163+
diff --git a/win32/console.c b/win32/console.c
164+
index 7833dd97d3..1fa8e4cea9 100644
165+
--- a/win32/console.c
166+
+++ b/win32/console.c
167+
@@ -111,6 +111,6 @@ PHP_WINUTIL_API BOOL php_win32_console_is_own(void)
168+
169+
PHP_WINUTIL_API BOOL php_win32_console_is_cli_sapi(void)
170+
{/*{{{*/
171+
- return strlen(sapi_module.name) >= sizeof("cli") - 1 && !strncmp(sapi_module.name, "cli", sizeof("cli") - 1);
172+
+ return !strncmp(sapi_module.name, "cli", sizeof("cli") - 1) || !strncmp(sapi_module.name, "micro", sizeof("micro") - 1);
173+
}/*}}}*/
174+

0 commit comments

Comments
 (0)