PHP: Factored out code into a helper function.
We're going to use zend_stream_init_filename in a following commit. To reduce the diff of that change, move the current code that will be replaced, to a function that has the same interface. We use strlen(3) here to be able to use an interface without passing the length, but we will remove that call in a following code, so it has no performance issues. Co-developed-by: Andrew Clayton <a.clayton@nginx.com> Signed-off-by: Alejandro Colomar <alx@nginx.com> Reviewed-by: Andrew Clayton <a.clayton@nginx.com> Cc: Andrei Zeliankou <zelenkov@nginx.com> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
This commit is contained in:
committed by
Andrew Clayton
parent
05c5639458
commit
0686740f20
@@ -106,6 +106,8 @@ static nxt_int_t nxt_php_do_301(nxt_unit_request_info_t *req);
|
|||||||
static void nxt_php_request_handler(nxt_unit_request_info_t *req);
|
static void nxt_php_request_handler(nxt_unit_request_info_t *req);
|
||||||
static void nxt_php_dynamic_request(nxt_php_run_ctx_t *ctx,
|
static void nxt_php_dynamic_request(nxt_php_run_ctx_t *ctx,
|
||||||
nxt_unit_request_t *r);
|
nxt_unit_request_t *r);
|
||||||
|
static void nxt_zend_stream_init_filename(zend_file_handle *handle,
|
||||||
|
const char *filename);
|
||||||
static void nxt_php_execute(nxt_php_run_ctx_t *ctx, nxt_unit_request_t *r);
|
static void nxt_php_execute(nxt_php_run_ctx_t *ctx, nxt_unit_request_t *r);
|
||||||
nxt_inline void nxt_php_vcwd_chdir(nxt_unit_request_info_t *req, u_char *dir);
|
nxt_inline void nxt_php_vcwd_chdir(nxt_unit_request_info_t *req, u_char *dir);
|
||||||
|
|
||||||
@@ -1109,6 +1111,21 @@ nxt_php_dynamic_request(nxt_php_run_ctx_t *ctx, nxt_unit_request_t *r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
nxt_zend_stream_init_filename(zend_file_handle *handle, const char *filename)
|
||||||
|
{
|
||||||
|
nxt_memzero(handle, sizeof(zend_file_handle));
|
||||||
|
|
||||||
|
handle->type = ZEND_HANDLE_FILENAME;
|
||||||
|
#if (PHP_VERSION_ID >= 80100)
|
||||||
|
handle->filename = zend_string_init(filename, strlen(filename), 0);
|
||||||
|
handle->primary_script = 1;
|
||||||
|
#else
|
||||||
|
handle->filename = filename;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nxt_php_execute(nxt_php_run_ctx_t *ctx, nxt_unit_request_t *r)
|
nxt_php_execute(nxt_php_run_ctx_t *ctx, nxt_unit_request_t *r)
|
||||||
{
|
{
|
||||||
@@ -1179,16 +1196,8 @@ nxt_php_execute(nxt_php_run_ctx_t *ctx, nxt_unit_request_t *r)
|
|||||||
nxt_php_vcwd_chdir(ctx->req, ctx->script_dirname.start);
|
nxt_php_vcwd_chdir(ctx->req, ctx->script_dirname.start);
|
||||||
}
|
}
|
||||||
|
|
||||||
nxt_memzero(&file_handle, sizeof(file_handle));
|
nxt_zend_stream_init_filename(&file_handle,
|
||||||
|
(const char *) ctx->script_filename.start);
|
||||||
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);
|
php_execute_script(&file_handle TSRMLS_CC);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user