Skip to content

Commit 217ea73

Browse files
cmb69kocsismate
andauthored
Use php_error_docref() instead of zend_error() in session.c (phpGH-15505)
Using `php_error_docref()` is preferable since it outputs additional details (which function has been called and whether it is a startup or shutdown error), uses HTML markup, and also provides a link to the documentation, if configured. Since these deprecation warnings have been introduced recently[1][2], i.e. for PHP 8.4, there are no BC concerns. [1] <php@e8ff7c7> [2] <php@b36eac9> Co-authored-by: Máté Kocsis <[email protected]>
1 parent 5dd0575 commit 217ea73

24 files changed

+45
-45
lines changed

ext/session/session.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ static PHP_INI_MH(OnUpdateSidLength) /* {{{ */
752752
SESSION_CHECK_OUTPUT_STATE;
753753
val = ZEND_STRTOL(ZSTR_VAL(new_value), &endptr, 10);
754754
if (val != 32) {
755-
zend_error(E_DEPRECATED, "session.sid_length INI setting is deprecated");
755+
php_error_docref("session.configuration", E_DEPRECATED, "session.sid_length INI setting is deprecated");
756756
}
757757
if (endptr && (*endptr == '\0')
758758
&& val >= 22 && val <= PS_MAX_SID_LENGTH) {
@@ -775,7 +775,7 @@ static PHP_INI_MH(OnUpdateSidBits) /* {{{ */
775775
SESSION_CHECK_OUTPUT_STATE;
776776
val = ZEND_STRTOL(ZSTR_VAL(new_value), &endptr, 10);
777777
if (val != 4) {
778-
zend_error(E_DEPRECATED, "session.sid_bits_per_character INI setting is deprecated");
778+
php_error_docref("session.configuration", E_DEPRECATED, "session.sid_bits_per_character INI setting is deprecated");
779779
}
780780
if (endptr && (*endptr == '\0')
781781
&& val >= 4 && val <=6) {
@@ -2185,7 +2185,7 @@ PHP_FUNCTION(session_set_save_handler)
21852185
RETURN_TRUE;
21862186
}
21872187

2188-
zend_error(E_DEPRECATED, "Calling session_set_save_handler() with more than 2 arguments is deprecated");
2188+
php_error_docref(NULL, E_DEPRECATED, "Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated");
21892189
if (UNEXPECTED(EG(exception))) {
21902190
RETURN_THROWS();
21912191
}

ext/session/tests/bug68063.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ var_dump(session_start());
2222
var_dump(session_id());
2323
?>
2424
--EXPECTF--
25-
Deprecated: session.sid_length INI setting is deprecated in Unknown on line 0
25+
Deprecated: PHP Startup: session.sid_length INI setting is deprecated in Unknown on line 0
2626
bool(true)
2727
string(40) "%s"

ext/session/tests/session_id_basic2.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ echo "Done";
2929
--EXPECTF--
3030
*** Testing session_id() : basic functionality ***
3131

32-
Deprecated: session.sid_bits_per_character INI setting is deprecated in %s on line %d
32+
Deprecated: ini_set(): session.sid_bits_per_character INI setting is deprecated in %s on line %d
3333

34-
Deprecated: session.sid_length INI setting is deprecated in %s on line %d
34+
Deprecated: ini_set(): session.sid_length INI setting is deprecated in %s on line %d
3535
string(120) "%s"
3636

37-
Deprecated: session.sid_length INI setting is deprecated in %s on line %d
37+
Deprecated: ini_set(): session.sid_length INI setting is deprecated in %s on line %d
3838
string(22) "%s"
3939
Done

ext/session/tests/user_session_module/bug31454.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ try {
2121
echo "Done\n";
2222
?>
2323
--EXPECTF--
24-
Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d
24+
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
2525
session_set_save_handler(): Argument #1 ($open) must be a valid callback, first array member is not a valid class name or object
2626
Done

ext/session/tests/user_session_module/bug60634_error_3.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ session_start();
4242

4343
?>
4444
--EXPECTF--
45-
Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d
45+
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
4646
write: goodbye cruel world
4747

4848
Fatal error: Uncaught Error: Call to undefined function undefined_function() in %s:%d

ext/session/tests/user_session_module/bug60634_error_4.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ session_start();
3737

3838
?>
3939
--EXPECTF--
40-
Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d
40+
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
4141
write: goodbye cruel world
4242

4343
Fatal error: Uncaught Exception in %s

ext/session/tests/user_session_module/bug80889a.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ $setHandler = ini_get('session.save_handler');
3131
var_dump($initHandler, $setHandler);
3232
?>
3333
--EXPECTF--
34-
Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d
34+
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
3535

3636
Warning: session_set_save_handler(): Session save handler cannot be changed after headers have already been sent in %s on line %d
3737
string(8) "whatever"

ext/session/tests/user_session_module/gh7787.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Warning: session_write_close(): Failed to write session data using user defined
8282

8383
Warning: session_write_close(): Failed to write session data using user defined save handler. (session.save_path: %S, handler: MySessionHandler::updateTimestamp) in %s on line %d
8484

85-
Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d
85+
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
8686

8787
Warning: session_write_close(): Failed to write session data using user defined save handler. (session.save_path: %S, handler: write) in %s on line %d
8888

ext/session/tests/user_session_module/session_set_save_handler_basic.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ bool(false)
7575
Warning: session_module_name(): Session handler module "foo" cannot be found in %s on line %d
7676
bool(false)
7777

78-
Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d
78+
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
7979
Open [%s,PHPSESSID]
8080
Read [%s,%s]
8181
array(3) {
@@ -98,7 +98,7 @@ array(3) {
9898
}
9999
Starting session again..!
100100

101-
Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d
101+
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
102102
Open [%s,PHPSESSID]
103103
Read [%s,%s]
104104
array(3) {

ext/session/tests/user_session_module/session_set_save_handler_class_002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ session_unset();
8787
--EXPECTF--
8888
*** Testing session_set_save_handler() : full handler implementation ***
8989

90-
Deprecated: Calling session_set_save_handler() with more than 2 arguments is deprecated in %s on line %d
90+
Deprecated: session_set_save_handler(): Providing individual callbacks instead of an object implementing SessionHandlerInterface is deprecated in %s on line %d
9191
string(%d) "%s"
9292
string(4) "user"
9393
array(1) {

0 commit comments

Comments
 (0)