diff --git a/NEWS b/NEWS index 58a236345b2..dd1ffa2caaf 100644 --- a/NEWS +++ b/NEWS @@ -32,6 +32,10 @@ PHP NEWS . Fixed bug #78272 (calling preg_match() before pcntl_fork() will freeze child process). (Nikita) +- 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 9f45eff3f97..86c4bb0e30a 100644 --- a/ext/session/mod_user.c +++ b/ext/session/mod_user.c @@ -190,14 +190,15 @@ PS_GC_FUNC(user) if (Z_TYPE(retval) == IS_LONG) { convert_to_long(&retval); - return Z_LVAL(retval); + *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 } - /* This is for older API compatibility */ - if (Z_TYPE(retval) == IS_TRUE) { - return 1; - } - /* 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 00000000000..9055b5af7b8 --- /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-- +