summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_php_sapi.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/nxt_php_sapi.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/nxt_php_sapi.c b/src/nxt_php_sapi.c
index 8fbe7f65..3fb3b0db 100644
--- a/src/nxt_php_sapi.c
+++ b/src/nxt_php_sapi.c
@@ -163,7 +163,8 @@ static const zend_function_entry nxt_php_ext_functions[] = {
};
-zif_handler nxt_php_chdir_handler;
+zif_handler nxt_php_chdir_handler;
+zend_auto_global *nxt_php_server_ag;
static zend_module_entry nxt_php_unit_module = {
@@ -211,6 +212,7 @@ ZEND_NAMED_FUNCTION(nxt_php_chdir)
PHP_FUNCTION(fastcgi_finish_request)
{
+ zend_auto_global *ag;
nxt_php_run_ctx_t *ctx;
if (nxt_slow_path(zend_parse_parameters_none() == FAILURE)) {
@@ -240,6 +242,16 @@ PHP_FUNCTION(fastcgi_finish_request)
php_header(TSRMLS_C);
#endif
+ ag = nxt_php_server_ag;
+
+ if (ag->armed) {
+#ifdef NXT_PHP7
+ ag->armed = ag->auto_global_callback(ag->name);
+#else
+ ag->armed = ag->auto_global_callback(ag->name, ag->name_len TSRMLS_CC);
+#endif
+ }
+
nxt_unit_request_done(ctx->req, NXT_UNIT_OK);
ctx->req = NULL;
@@ -411,6 +423,19 @@ nxt_php_setup(nxt_task_t *task, nxt_process_t *process,
nxt_php_set_options(task, value, ZEND_INI_USER);
}
+#ifdef NXT_PHP7
+ nxt_php_server_ag = zend_hash_str_find_ptr(CG(auto_globals), "_SERVER",
+ nxt_length("_SERVER"));
+#else
+ zend_hash_quick_find(CG(auto_globals), "_SERVER", sizeof("_SERVER"),
+ zend_hash_func("_SERVER", sizeof("_SERVER")),
+ (void **) &nxt_php_server_ag);
+#endif
+ if (nxt_slow_path(nxt_php_server_ag == NULL)) {
+ nxt_alert(task, "failed to find $_SERVER auto global");
+ return NXT_ERROR;
+ }
+
return NXT_OK;
}
@@ -1076,10 +1101,20 @@ nxt_php_execute(nxt_php_run_ctx_t *ctx, nxt_unit_request_t *r)
nxt_memzero(&file_handle, sizeof(file_handle));
file_handle.type = ZEND_HANDLE_FILENAME;
+#if (PHP_VERSION_ID >= 80100)
+ file_handle.filename = zend_string_init((char *) ctx->script_filename.start,
+ ctx->script_filename.length, 0);
+ file_handle.primary_script = 1;
+#else
file_handle.filename = (char *) ctx->script_filename.start;
+#endif
php_execute_script(&file_handle TSRMLS_CC);
+#if (PHP_VERSION_ID >= 80100)
+ zend_destroy_file_handle(&file_handle);
+#endif
+
/* Prevention of consuming possible unread request body. */
#if (PHP_VERSION_ID < 50600)
read_post = sapi_module.read_post;