diff --git a/ext/session/session.c b/ext/session/session.c index 884132d885a23..a7a253d8bff41 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -54,6 +54,8 @@ #include "mod_mm.h" #endif +#include "zend_attributes.h" + PHPAPI ZEND_DECLARE_MODULE_GLOBALS(ps) static zend_result php_session_rfc1867_callback(unsigned int event, void *event_data, void **extra); @@ -1502,6 +1504,8 @@ PHPAPI zend_result php_session_reset_id(void) /* zend_hash_str_del(EG(zend_constants), ZEND_STRL("sid")); */ sid = zend_get_constant_str(ZEND_STRL("SID")); + zend_constant *new_sid_constant = NULL; + if (PS(define_sid)) { smart_str var = {0}; @@ -1513,7 +1517,7 @@ PHPAPI zend_result php_session_reset_id(void) zval_ptr_dtor(sid); ZVAL_STR(sid, smart_str_extract(&var)); } else { - REGISTER_STRINGL_CONSTANT("SID", ZSTR_VAL(var.s), ZSTR_LEN(var.s), CONST_DEPRECATED); + new_sid_constant = REGISTER_STRINGL_CONSTANT("SID", ZSTR_VAL(var.s), ZSTR_LEN(var.s), CONST_DEPRECATED); smart_str_free(&var); } } else { @@ -1521,9 +1525,17 @@ PHPAPI zend_result php_session_reset_id(void) zval_ptr_dtor(sid); ZVAL_EMPTY_STRING(sid); } else { - REGISTER_STRINGL_CONSTANT("SID", "", 0, CONST_DEPRECATED); + new_sid_constant = REGISTER_STRINGL_CONSTANT("SID", "", 0, CONST_DEPRECATED); } } + if (new_sid_constant != NULL) { + zend_string *deprecation_reason = zend_string_init("as GET/POST sessions were deprecated", strlen("as GET/POST sessions were deprecated"), 1); + zend_attribute *deprecation_attrib = zend_add_global_constant_attribute(new_sid_constant, ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2); + ZVAL_STR(&deprecation_attrib->args[0].value, ZSTR_KNOWN(ZEND_STR_8_DOT_4)); + deprecation_attrib->args[0].name = ZSTR_KNOWN(ZEND_STR_SINCE); + ZVAL_STR(&deprecation_attrib->args[1].value, deprecation_reason); + deprecation_attrib->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE); + } /* Apply trans sid if sid cookie is not set */ apply_trans_sid = 0; diff --git a/ext/session/tests/015.phpt b/ext/session/tests/015.phpt index 3154022fae861..1a9285c339332 100644 --- a/ext/session/tests/015.phpt +++ b/ext/session/tests/015.phpt @@ -31,5 +31,5 @@ Deprecated: PHP Startup: Disabling session.use_only_cookies INI setting is depre Deprecated: PHP Startup: Enabling session.use_trans_sid INI setting is deprecated in Unknown on line 0 -Deprecated: Constant SID is deprecated in %s on line 6 +Deprecated: Constant SID is deprecated since 8.4, as GET/POST sessions were deprecated in %s on line %d diff --git a/ext/session/tests/bug72940.phpt b/ext/session/tests/bug72940.phpt index 9a927a5419e4a..4977b05a55233 100644 --- a/ext/session/tests/bug72940.phpt +++ b/ext/session/tests/bug72940.phpt @@ -34,12 +34,12 @@ session_destroy(); --EXPECTF-- Deprecated: ini_set(): Disabling session.use_only_cookies INI setting is deprecated in %s on line 6 -Deprecated: Constant SID is deprecated in %s on line 8 +Deprecated: Constant SID is deprecated since 8.4, as GET/POST sessions were deprecated in %s on line %d string(12) "bug72940test" string(0) "" Deprecated: ini_set(): Disabling session.use_only_cookies INI setting is deprecated in %s on line 13 -Deprecated: Constant SID is deprecated in %s on line 15 +Deprecated: Constant SID is deprecated since 8.4, as GET/POST sessions were deprecated in %s on line %d string(11) "bug72940get" string(21) "PHPSESSID=bug72940get" diff --git a/ext/session/tests/deprecations.phpt b/ext/session/tests/deprecations.phpt index 4a2337fb99dad..0db8ce49b7d0c 100644 --- a/ext/session/tests/deprecations.phpt +++ b/ext/session/tests/deprecations.phpt @@ -60,5 +60,5 @@ Deprecated: session_start(): Disabling session.use_only_cookies INI setting is d Deprecated: session_start(): Enabling session.use_trans_sid INI setting is deprecated in %s on line 32 -Deprecated: Constant SID is deprecated in %s on line 34 +Deprecated: Constant SID is deprecated since 8.4, as GET/POST sessions were deprecated in %s on line %d PHPSESSID=%s