Skip to content

Commit 251542b

Browse files
committed
Un-deprecate simple add/replace header API, use it
Suggestion from Jakub.
1 parent 97c2add commit 251542b

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

ext/session/session.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,6 @@ static void php_session_remove_cookie(void) {
13511351

13521352
static zend_result php_session_send_cookie(void)
13531353
{
1354-
sapi_header_line header_line = {0};
13551354
smart_str ncookie = {0};
13561355
zend_string *date_fmt = NULL;
13571356
zend_string *e_id;
@@ -1417,9 +1416,9 @@ static zend_result php_session_send_cookie(void)
14171416
smart_str_0(&ncookie);
14181417

14191418
php_session_remove_cookie(); /* remove already sent session ID cookie */
1420-
header_line.line = ZSTR_VAL(ncookie.s);
1421-
header_line.line_len = ZSTR_LEN(ncookie.s);
1422-
sapi_header_op(SAPI_HEADER_ADD, &header_line);
1419+
/* 'replace' must be 0 here, else a previous Set-Cookie
1420+
header, probably sent with setcookie() will be replaced! */
1421+
sapi_add_header_ex(estrndup(ZSTR_VAL(ncookie.s), ZSTR_LEN(ncookie.s)), ZSTR_LEN(ncookie.s), 0, 0);
14231422
smart_str_free(&ncookie);
14241423

14251424
return SUCCESS;

main/SAPI.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ typedef enum { /* Parameter: */
200200
BEGIN_EXTERN_C()
201201
SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg);
202202

203-
/* Deprecated functions. Use sapi_header_op instead. */
204203
SAPI_API int sapi_add_header_ex(const char *header_line, size_t header_line_len, bool duplicate, bool replace);
205204
#define sapi_add_header(a, b, c) sapi_add_header_ex((a),(b),(c),1)
206205

0 commit comments

Comments
 (0)