@@ -1917,24 +1917,28 @@ PHP_FUNCTION(session_module_name)
1917
1917
}
1918
1918
/* }}} */
1919
1919
1920
- /* {{{ proto bool session_set_save_handler(string open, string close, string read, string write, string destroy, string gc, string create_sid)
1921
- Sets user-level functions */
1922
- PHP_FUNCTION (session_set_save_handler )
1923
- {
1924
- zval * args = NULL ;
1925
- int i , num_args , argc = ZEND_NUM_ARGS ();
1926
- zend_string * ini_name , * ini_val ;
1927
-
1920
+ static int save_handler_check_session () {
1928
1921
if (PS (session_status ) == php_session_active ) {
1929
1922
php_error_docref (NULL , E_WARNING , "Cannot change save handler when session is active" );
1930
- RETURN_FALSE ;
1923
+ return FAILURE ;
1931
1924
}
1932
1925
1933
1926
if (SG (headers_sent )) {
1934
1927
php_error_docref (NULL , E_WARNING , "Cannot change save handler when headers already sent" );
1935
- RETURN_FALSE ;
1928
+ return FAILURE ;
1936
1929
}
1937
1930
1931
+ return SUCCESS ;
1932
+ }
1933
+
1934
+ /* {{{ proto bool session_set_save_handler(string open, string close, string read, string write, string destroy, string gc, string create_sid)
1935
+ Sets user-level functions */
1936
+ PHP_FUNCTION (session_set_save_handler )
1937
+ {
1938
+ zval * args = NULL ;
1939
+ int i , num_args , argc = ZEND_NUM_ARGS ();
1940
+ zend_string * ini_name , * ini_val ;
1941
+
1938
1942
if (argc > 0 && argc <= 2 ) {
1939
1943
zval * obj = NULL ;
1940
1944
zend_string * func_name ;
@@ -1945,6 +1949,10 @@ PHP_FUNCTION(session_set_save_handler)
1945
1949
RETURN_THROWS ();
1946
1950
}
1947
1951
1952
+ if (save_handler_check_session () == FAILURE ) {
1953
+ RETURN_FALSE ;
1954
+ }
1955
+
1948
1956
/* For compatibility reason, implemented interface is not checked */
1949
1957
/* Find implemented methods - SessionHandlerInterface */
1950
1958
i = 0 ;
@@ -2047,6 +2055,10 @@ PHP_FUNCTION(session_set_save_handler)
2047
2055
RETURN_THROWS ();
2048
2056
}
2049
2057
2058
+ if (save_handler_check_session () == FAILURE ) {
2059
+ RETURN_FALSE ;
2060
+ }
2061
+
2050
2062
/* remove shutdown function */
2051
2063
remove_user_shutdown_function ("session_shutdown" , sizeof ("session_shutdown" ) - 1 );
2052
2064
0 commit comments