From a6d219630c4128a124f3d9a2e7ca97afb92d5d47 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 2 Oct 2019 16:44:58 -0700 Subject: fix #78624: session_gc return value for user defined session handlers --- NEWS | 4 ++ ext/session/mod_user.c | 15 +++--- ext/session/tests/bug78624.phpt | 61 ++++++++++++++++++++++ .../tests/session_set_save_handler_basic.phpt | 12 +++++ 4 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 ext/session/tests/bug78624.phpt diff --git a/NEWS b/NEWS index 550de2e252..26abd33994 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,10 @@ PHP NEWS . Fixed bug #76809 (SSL settings aren't respected when persistent connections are used). (fabiomsouto) +- Session: + . Fixed bug #78624 (session_gc return value for user defined session + handlers). (bshaffer) + - Standard: . Fixed bug #76342 (file_get_contents waits twice specified timeout). (Thomas Calvet) diff --git a/ext/session/mod_user.c b/ext/session/mod_user.c index 9ab0be13cd..897955166b 100644 --- a/ext/session/mod_user.c +++ b/ext/session/mod_user.c @@ -192,14 +192,15 @@ PS_GC_FUNC(user) if (Z_TYPE(retval) == IS_LONG) { convert_to_long(&retval); - return Z_LVAL(retval); - } - /* This is for older API compatibility */ - if (Z_TYPE(retval) == IS_TRUE) { - return 1; + *nrdels = Z_LVAL(retval); + } else if (Z_TYPE(retval) == IS_TRUE) { + /* This is for older API compatibility */ + *nrdels = 1; + } else { + /* Anything else is some kind of error */ + *nrdels = -1; // Error } - /* Anything else is some kind of error */ - return -1; // Error + return *nrdels; } PS_CREATE_SID_FUNC(user) diff --git a/ext/session/tests/bug78624.phpt b/ext/session/tests/bug78624.phpt new file mode 100644 index 0000000000..9055b5af7b --- /dev/null +++ b/ext/session/tests/bug78624.phpt @@ -0,0 +1,61 @@ +--TEST-- +Test session_set_save_handler() : session_gc() returns the number of deleted records. +--INI-- +session.name=PHPSESSID +session.save_handler=files +--SKIPIF-- + +--FILE-- +