Skip to content

Commit 3923de9

Browse files
committed
PHP: Make use of zend_stream_init_filename().
Where possible make use of the zend_stream_init_filename() function introduced in PHP 7.4. This is essentially a preparatory patch for switching to using an already opened file-pointer in nxt_php_execute(). While wrapping this new code in a PHP version check with a fallback to our own function is perhaps slightly overkill, it does reduce the diff of the commit that switches to a FILE *. Reviewed-by: Alejandro Colomar <alx@nginx.com> Cc: Andrei Zeliankou <zelenkov@nginx.com> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
1 parent 0686740 commit 3923de9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/nxt_php_sapi.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,10 @@ static nxt_int_t nxt_php_do_301(nxt_unit_request_info_t *req);
106106
static void nxt_php_request_handler(nxt_unit_request_info_t *req);
107107
static void nxt_php_dynamic_request(nxt_php_run_ctx_t *ctx,
108108
nxt_unit_request_t *r);
109+
#if (PHP_VERSION_ID < 70400)
109110
static void nxt_zend_stream_init_filename(zend_file_handle *handle,
110111
const char *filename);
112+
#endif
111113
static void nxt_php_execute(nxt_php_run_ctx_t *ctx, nxt_unit_request_t *r);
112114
nxt_inline void nxt_php_vcwd_chdir(nxt_unit_request_info_t *req, u_char *dir);
113115

@@ -1111,19 +1113,17 @@ nxt_php_dynamic_request(nxt_php_run_ctx_t *ctx, nxt_unit_request_t *r)
11111113
}
11121114

11131115

1116+
#if (PHP_VERSION_ID < 70400)
11141117
static void
11151118
nxt_zend_stream_init_filename(zend_file_handle *handle, const char *filename)
11161119
{
11171120
nxt_memzero(handle, sizeof(zend_file_handle));
1118-
11191121
handle->type = ZEND_HANDLE_FILENAME;
1120-
#if (PHP_VERSION_ID >= 80100)
1121-
handle->filename = zend_string_init(filename, strlen(filename), 0);
1122-
handle->primary_script = 1;
1123-
#else
11241122
handle->filename = filename;
1125-
#endif
11261123
}
1124+
#else
1125+
#define nxt_zend_stream_init_filename zend_stream_init_filename
1126+
#endif
11271127

11281128

11291129
static void

0 commit comments

Comments
 (0)