]> granicus.if.org Git - php/commitdiff
Clean up ext/session errors
authorMáté Kocsis <kocsismate@woohoolabs.com>
Thu, 10 Sep 2020 17:50:41 +0000 (19:50 +0200)
committerMáté Kocsis <kocsismate@woohoolabs.com>
Fri, 11 Sep 2020 09:59:04 +0000 (11:59 +0200)
Closes GH-6111

56 files changed:
ext/session/mod_files.c
ext/session/mod_user.c
ext/session/php_session.h
ext/session/session.c
ext/session/session.stub.php
ext/session/session_arginfo.h
ext/session/tests/014.phpt
ext/session/tests/016.phpt
ext/session/tests/029.phpt
ext/session/tests/bug31454.phpt
ext/session/tests/bug60860.phpt
ext/session/tests/bug66481.phpt
ext/session/tests/bug73100.phpt
ext/session/tests/rfc1867_invalid_settings.phpt
ext/session/tests/rfc1867_invalid_settings_2.phpt
ext/session/tests/rfc1867_sid_invalid.phpt
ext/session/tests/session_cache_limiter_variation1.phpt
ext/session/tests/session_cache_limiter_variation2.phpt
ext/session/tests/session_cache_limiter_variation3.phpt
ext/session/tests/session_decode_variation3.phpt
ext/session/tests/session_encode_error2.phpt
ext/session/tests/session_encode_variation6.phpt
ext/session/tests/session_encode_variation8.phpt
ext/session/tests/session_gc_basic.phpt
ext/session/tests/session_id_error2.phpt
ext/session/tests/session_ini_set.phpt
ext/session/tests/session_module_name_variation1.phpt
ext/session/tests/session_module_name_variation3.phpt
ext/session/tests/session_name_variation1.phpt
ext/session/tests/session_regenerate_id_basic.phpt
ext/session/tests/session_regenerate_id_variation1.phpt
ext/session/tests/session_save_path_variation1.phpt
ext/session/tests/session_set_cookie_params_basic.phpt
ext/session/tests/session_set_cookie_params_variation1.phpt
ext/session/tests/session_set_cookie_params_variation2.phpt
ext/session/tests/session_set_cookie_params_variation3.phpt
ext/session/tests/session_set_cookie_params_variation4.phpt
ext/session/tests/session_set_cookie_params_variation5.phpt
ext/session/tests/session_set_cookie_params_variation6.phpt
ext/session/tests/session_set_cookie_params_variation7.phpt
ext/session/tests/session_set_save_handler_basic.phpt
ext/session/tests/session_set_save_handler_class_012.phpt
ext/session/tests/session_set_save_handler_class_014.phpt
ext/session/tests/session_set_save_handler_closures.phpt
ext/session/tests/session_set_save_handler_error.phpt
ext/session/tests/session_set_save_handler_error3.phpt
ext/session/tests/session_set_save_handler_error4.phpt
ext/session/tests/session_set_save_handler_iface_002.phpt
ext/session/tests/session_set_save_handler_sid_002.phpt
ext/session/tests/session_set_save_handler_type_error.phpt [new file with mode: 0644]
ext/session/tests/session_set_save_handler_variation1.phpt
ext/session/tests/session_set_save_handler_variation2.phpt
ext/session/tests/session_set_save_handler_variation3.phpt
ext/session/tests/session_start_error.phpt [new file with mode: 0644]
ext/session/tests/session_start_variation1.phpt
ext/session/tests/session_start_variation9.phpt

index bac6c4297d81df470a34f897b1fc7e10e3f24e4b..36f9198166d5078f58f5c7c83f7ffaf9d1c9e017 100644 (file)
@@ -168,12 +168,12 @@ static void ps_files_open(ps_files *data, const char *key)
                ps_files_close(data);
 
                if (php_session_valid_key(key) == FAILURE) {
-                       php_error_docref(NULL, E_WARNING, "The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,'");
+                       php_error_docref(NULL, E_WARNING, "Session ID is too long or contains illegal characters. Only the A-Z, a-z, 0-9, \"-\", and \",\" characters are allowed");
                        return;
                }
 
                if (!ps_files_path_create(buf, sizeof(buf), data, key)) {
-                       php_error_docref(NULL, E_WARNING, "Failed to create session data file path. Too short session ID, invalid save_path or path lentgth exceeds MAXPATHLEN(%d)", MAXPATHLEN);
+                       php_error_docref(NULL, E_WARNING, "Failed to create session data file path. Too short session ID, invalid save_path or path length exceeds %d characters", MAXPATHLEN);
                        return;
                }
 
index c3e5c608aa92828847d55e76a3fa9eb407129dcf..b41b742cba87c52c76d5553ee9b0c954870b50b4 100644 (file)
@@ -58,15 +58,18 @@ static void ps_call_handler(zval *func, int argc, zval *argv, zval *retval)
                } else if (Z_TYPE(retval) == IS_FALSE) { \
                        ret = FAILURE; \
         }  else if ((Z_TYPE(retval) == IS_LONG) && (Z_LVAL(retval) == -1)) { \
-                       /* BC for clever users - Deprecate me */ \
+                       if (!EG(exception)) { \
+                               php_error_docref(NULL, E_DEPRECATED, "Session callback must have a return value of type bool, %s returned", zend_zval_type_name(&retval)); \
+                       } \
                        ret = FAILURE; \
                } else if ((Z_TYPE(retval) == IS_LONG) && (Z_LVAL(retval) == 0)) { \
-                       /* BC for clever users - Deprecate me */ \
+                       if (!EG(exception)) { \
+                               php_error_docref(NULL, E_DEPRECATED, "Session callback must have a return value of type bool, %s returned", zend_zval_type_name(&retval)); \
+                       } \
                        ret = SUCCESS; \
                } else { \
                        if (!EG(exception)) { \
-                               php_error_docref(NULL, E_WARNING, \
-                                                "Session callback expects true/false return value"); \
+                               zend_type_error("Session callback must have a return value of type bool, %s returned", zend_zval_type_name(&retval)); \
                        } \
                        ret = FAILURE; \
                        zval_ptr_dtor(&retval); \
@@ -80,8 +83,7 @@ PS_OPEN_FUNC(user)
        STDVARS;
 
        if (Z_ISUNDEF(PSF(open))) {
-               php_error_docref(NULL, E_WARNING,
-                       "user session functions not defined");
+               php_error_docref(NULL, E_WARNING, "User session functions are not defined");
 
                return FAILURE;
        }
index 73f8bf31c8d208c8275c105f8b2abc21dbc8871d..c365975fb5f53514a2578f1a561274cb45b0741d 100644 (file)
@@ -291,7 +291,7 @@ PHPAPI int php_session_reset_id(void);
        HashTable *_ht = Z_ARRVAL_P(Z_REFVAL(PS(http_session_vars)));   \
        ZEND_HASH_FOREACH_KEY(_ht, num_key, key) {                                              \
                if (key == NULL) {                                                                                      \
-                       php_error_docref(NULL, E_NOTICE,                                                \
+                       php_error_docref(NULL, E_WARNING,                                               \
                                        "Skipping numeric key " ZEND_LONG_FMT, num_key);\
                        continue;                                                                                               \
                }                                                                                                                       \
index 9336c05be816c67160575ab601cf3007f688582b..4f12e447baa3390cd0df67debed342829fea788c 100644 (file)
@@ -84,13 +84,13 @@ zend_class_entry *php_session_update_timestamp_iface_entry;
 
 #define SESSION_CHECK_ACTIVE_STATE     \
        if (PS(session_status) == php_session_active) { \
-               php_error_docref(NULL, E_WARNING, "A session is active. You cannot change the session module's ini settings at this time");     \
+               php_error_docref(NULL, E_WARNING, "Session ini settings cannot be changed when a session is active");   \
                return FAILURE; \
        }
 
 #define SESSION_CHECK_OUTPUT_STATE                                                                             \
        if (SG(headers_sent) && stage != ZEND_INI_STAGE_DEACTIVATE) {                                                                                           \
-               php_error_docref(NULL, E_WARNING, "Headers already sent. You cannot change the session module's ini settings at this time");    \
+               php_error_docref(NULL, E_WARNING, "Session ini settings cannot be changed after headers have already been sent");       \
                return FAILURE;                                                                                                 \
        }
 
@@ -160,7 +160,9 @@ PHPAPI int php_session_destroy(void) /* {{{ */
 
        if (PS(id) && PS(mod)->s_destroy(&PS(mod_data), PS(id)) == FAILURE) {
                retval = FAILURE;
-               php_error_docref(NULL, E_WARNING, "Session object destruction failed");
+               if (!EG(exception)) {
+                       php_error_docref(NULL, E_WARNING, "Session object destruction failed");
+               }
        }
 
        php_rshutdown_session_globals();
@@ -393,7 +395,9 @@ static int php_session_initialize(void) /* {{{ */
                /* || PS(mod_data) == NULL */ /* FIXME: open must set valid PS(mod_data) with success */
        ) {
                php_session_abort();
-               php_error_docref(NULL, E_WARNING, "Failed to initialize storage module: %s (path: %s)", PS(mod)->s_name, PS(save_path));
+               if (!EG(exception)) {
+                       php_error_docref(NULL, E_WARNING, "Failed to initialize storage module: %s (path: %s)", PS(mod)->s_name, PS(save_path));
+               }
                return FAILURE;
        }
 
@@ -405,14 +409,17 @@ static int php_session_initialize(void) /* {{{ */
                PS(id) = PS(mod)->s_create_sid(&PS(mod_data));
                if (!PS(id)) {
                        php_session_abort();
-                       zend_throw_error(NULL, "Failed to create session ID: %s (path: %s)", PS(mod)->s_name, PS(save_path));
+                       if (!EG(exception)) {
+                               zend_throw_error(NULL, "Failed to create session ID: %s (path: %s)", PS(mod)->s_name, PS(save_path));
+                       }
                        return FAILURE;
                }
                if (PS(use_cookies)) {
                        PS(send_cookie) = 1;
                }
        } else if (PS(use_strict_mode) && PS(mod)->s_validate_sid &&
-               PS(mod)->s_validate_sid(&PS(mod_data), PS(id)) == FAILURE) {
+               PS(mod)->s_validate_sid(&PS(mod_data), PS(id)) == FAILURE
+       ) {
                if (PS(id)) {
                        zend_string_release_ex(PS(id), 0);
                }
@@ -435,7 +442,9 @@ static int php_session_initialize(void) /* {{{ */
        if (PS(mod)->s_read(&PS(mod_data), PS(id), &val, PS(gc_maxlifetime)) == FAILURE) {
                php_session_abort();
                /* FYI: Some broken save handlers return FAILURE for non-existent session ID, this is incorrect */
-               php_error_docref(NULL, E_WARNING, "Failed to read session data: %s (path: %s)", PS(mod)->s_name, PS(save_path));
+               if (!EG(exception)) {
+                       php_error_docref(NULL, E_WARNING, "Failed to read session data: %s (path: %s)", PS(mod)->s_name, PS(save_path));
+               }
                return FAILURE;
        }
 
@@ -544,7 +553,7 @@ static PHP_INI_MH(OnUpdateSaveHandler) /* {{{ */
 
                /* Do not output error when restoring ini options. */
                if (stage != ZEND_INI_STAGE_DEACTIVATE) {
-                       php_error_docref(NULL, err_type, "Cannot find save handler '%s'", ZSTR_VAL(new_value));
+                       php_error_docref(NULL, err_type, "Session save handler \"%s\" cannot be found", ZSTR_VAL(new_value));
                }
 
                return FAILURE;
@@ -552,7 +561,7 @@ static PHP_INI_MH(OnUpdateSaveHandler) /* {{{ */
 
        /* "user" save handler should not be set by user */
        if (!PS(set_handler) &&  tmp == ps_user_ptr) {
-               php_error_docref(NULL, E_RECOVERABLE_ERROR, "Cannot set 'user' save handler by ini_set() or session_module_name()");
+               php_error_docref(NULL, E_RECOVERABLE_ERROR, "Session save handler \"user\" cannot be set by ini_set() or session_module_name()");
                return FAILURE;
        }
 
@@ -583,7 +592,7 @@ static PHP_INI_MH(OnUpdateSerializer) /* {{{ */
 
                /* Do not output error when restoring ini options. */
                if (stage != ZEND_INI_STAGE_DEACTIVATE) {
-                       php_error_docref(NULL, err_type, "Cannot find serialization handler '%s'", ZSTR_VAL(new_value));
+                       php_error_docref(NULL, err_type, "Serialization handler \"%s\" cannot be found", ZSTR_VAL(new_value));
                }
                return FAILURE;
        }
@@ -660,7 +669,7 @@ static PHP_INI_MH(OnUpdateName) /* {{{ */
 
                /* Do not output error when restoring ini options. */
                if (stage != ZEND_INI_STAGE_DEACTIVATE) {
-                       php_error_docref(NULL, err_type, "session.name cannot be a numeric or empty '%s'", ZSTR_VAL(new_value));
+                       php_error_docref(NULL, err_type, "session.name \"%s\" cannot be numeric or empty", ZSTR_VAL(new_value));
                }
                return FAILURE;
        }
@@ -725,7 +734,7 @@ static PHP_INI_MH(OnUpdateSidLength) /* {{{ */
                return SUCCESS;
        }
 
-       php_error_docref(NULL, E_WARNING, "session.configuration 'session.sid_length' must be between 22 and 256.");
+       php_error_docref(NULL, E_WARNING, "session.configuration \"session.sid_length\" must be between 22 and 256");
        return FAILURE;
 }
 /* }}} */
@@ -745,7 +754,7 @@ static PHP_INI_MH(OnUpdateSidBits) /* {{{ */
                return SUCCESS;
        }
 
-       php_error_docref(NULL, E_WARNING, "session.configuration 'session.sid_bits_per_character' must be between 4 and 6.");
+       php_error_docref(NULL, E_WARNING, "session.configuration \"session.sid_bits_per_character\" must be between 4 and 6");
        return FAILURE;
 }
 /* }}} */
@@ -766,12 +775,12 @@ static PHP_INI_MH(OnUpdateRfc1867Freq) /* {{{ */
        int tmp;
        tmp = zend_atoi(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
        if(tmp < 0) {
-               php_error_docref(NULL, E_WARNING, "session.upload_progress.freq must be greater than or equal to zero");
+               php_error_docref(NULL, E_WARNING, "session.upload_progress.freq must be greater than or equal to 0");
                return FAILURE;
        }
        if(ZSTR_LEN(new_value) > 0 && ZSTR_VAL(new_value)[ZSTR_LEN(new_value)-1] == '%') {
                if(tmp > 100) {
-                       php_error_docref(NULL, E_WARNING, "session.upload_progress.freq cannot be over 100%%");
+                       php_error_docref(NULL, E_WARNING, "session.upload_progress.freq must be less than or equal to 100%%");
                        return FAILURE;
                }
                PS(rfc1867_freq) = -tmp;
@@ -1225,9 +1234,9 @@ static int php_session_cache_limiter(void) /* {{{ */
 
                php_session_abort();
                if (output_start_filename) {
-                       php_error_docref(NULL, E_WARNING, "Cannot send session cache limiter - headers already sent (output started at %s:%d)", output_start_filename, output_start_lineno);
+                       php_error_docref(NULL, E_WARNING, "Session cache limiter cannot be sent after headers have already been sent (output started at %s:%d)", output_start_filename, output_start_lineno);
                } else {
-                       php_error_docref(NULL, E_WARNING, "Cannot send session cache limiter - headers already sent");
+                       php_error_docref(NULL, E_WARNING, "Session cache limiter cannot be sent after headers have already been sent");
                }
                return -2;
        }
@@ -1303,9 +1312,9 @@ static int php_session_send_cookie(void) /* {{{ */
                int output_start_lineno = php_output_get_start_lineno();
 
                if (output_start_filename) {
-                       php_error_docref(NULL, E_WARNING, "Cannot send session cookie - headers already sent by (output started at %s:%d)", output_start_filename, output_start_lineno);
+                       php_error_docref(NULL, E_WARNING, "Session cookie cannot be sent after headers have already been sent (output started at %s:%d)", output_start_filename, output_start_lineno);
                } else {
-                       php_error_docref(NULL, E_WARNING, "Cannot send session cookie - headers already sent");
+                       php_error_docref(NULL, E_WARNING, "Session cookie cannot be sent after headers have already been sent");
                }
                return FAILURE;
        }
@@ -1497,7 +1506,7 @@ PHPAPI int php_session_start(void) /* {{{ */
 
        switch (PS(session_status)) {
                case php_session_active:
-                       php_error(E_NOTICE, "A session had already been started - ignoring session_start()");
+                       php_error(E_NOTICE, "Ignoring session_start() because a session has already been started");
                        return FAILURE;
                        break;
 
@@ -1506,7 +1515,7 @@ PHPAPI int php_session_start(void) /* {{{ */
                        if (!PS(mod) && value) {
                                PS(mod) = _php_find_ps_module(value);
                                if (!PS(mod)) {
-                                       php_error_docref(NULL, E_WARNING, "Cannot find save handler '%s' - session startup failed", value);
+                                       php_error_docref(NULL, E_WARNING, "Cannot find session save handler \"%s\" - session startup failed", value);
                                        return FAILURE;
                                }
                        }
@@ -1514,7 +1523,7 @@ PHPAPI int php_session_start(void) /* {{{ */
                        if (!PS(serializer) && value) {
                                PS(serializer) = _php_find_ps_serializer(value);
                                if (!PS(serializer)) {
-                                       php_error_docref(NULL, E_WARNING, "Cannot find serialization handler '%s' - session startup failed", value);
+                                       php_error_docref(NULL, E_WARNING, "Cannot find session serialization handler \"%s\" - session startup failed", value);
                                        return FAILURE;
                                }
                        }
@@ -1687,12 +1696,12 @@ PHP_FUNCTION(session_set_cookie_params)
        ZEND_PARSE_PARAMETERS_END();
 
        if (PS(session_status) == php_session_active) {
-               php_error_docref(NULL, E_WARNING, "Cannot change session cookie parameters when session is active");
+               php_error_docref(NULL, E_WARNING, "Session cookie parameters cannot be changed when a session is active");
                RETURN_FALSE;
        }
 
        if (SG(headers_sent)) {
-               php_error_docref(NULL, E_WARNING, "Cannot change session cookie parameters when headers already sent");
+               php_error_docref(NULL, E_WARNING, "Session cookie parameters cannot be changed after headers have already been sent");
                RETURN_FALSE;
        }
 
@@ -1733,16 +1742,16 @@ PHP_FUNCTION(session_set_cookie_params)
                                        samesite = zval_get_string(value);
                                        found++;
                                } else {
-                                       php_error_docref(NULL, E_WARNING, "Unrecognized key '%s' found in the options array", ZSTR_VAL(key));
+                                       php_error_docref(NULL, E_WARNING, "Argument #1 ($lifetime_or_options) contains an unrecognized key \"%s\"", ZSTR_VAL(key));
                                }
                        } else {
-                               php_error_docref(NULL, E_WARNING, "Numeric key found in the options array");
+                               php_error_docref(NULL, E_WARNING, "Argument #1 ($lifetime_or_options) cannot contain numeric keys");
                        }
                } ZEND_HASH_FOREACH_END();
 
                if (found == 0) {
-                       php_error_docref(NULL, E_WARNING, "No valid keys were found in the options array");
-                       RETURN_FALSE;
+                       zend_argument_value_error(1, "must contain at least 1 valid key");
+                       RETURN_THROWS();
                }
        } else {
                lifetime = zval_get_string(lifetime_or_options);
@@ -1849,12 +1858,12 @@ PHP_FUNCTION(session_name)
        }
 
        if (name && PS(session_status) == php_session_active) {
-               php_error_docref(NULL, E_WARNING, "Cannot change session name when session is active");
+               php_error_docref(NULL, E_WARNING, "Session name cannot be changed when a session is active");
                RETURN_FALSE;
        }
 
        if (name && SG(headers_sent)) {
-               php_error_docref(NULL, E_WARNING, "Cannot change session name when headers already sent");
+               php_error_docref(NULL, E_WARNING, "Session name cannot be changed after headers have already been sent");
                RETURN_FALSE;
        }
 
@@ -1879,12 +1888,12 @@ PHP_FUNCTION(session_module_name)
        }
 
        if (name && PS(session_status) == php_session_active) {
-               php_error_docref(NULL, E_WARNING, "Cannot change save handler module when session is active");
+               php_error_docref(NULL, E_WARNING, "Session save handler module cannot be changed when a session is active");
                RETURN_FALSE;
        }
 
        if (name && SG(headers_sent)) {
-               php_error_docref(NULL, E_WARNING, "Cannot change save handler module when headers already sent");
+               php_error_docref(NULL, E_WARNING, "Session save handler module cannot be changed after headers have already been sent");
                RETURN_FALSE;
        }
 
@@ -1897,7 +1906,7 @@ PHP_FUNCTION(session_module_name)
 
        if (name) {
                if (!_php_find_ps_module(ZSTR_VAL(name))) {
-                       php_error_docref(NULL, E_WARNING, "Cannot find named PHP session module (%s)", ZSTR_VAL(name));
+                       php_error_docref(NULL, E_WARNING, "Session handler module \"%s\" cannot be found", ZSTR_VAL(name));
 
                        zval_ptr_dtor_str(return_value);
                        RETURN_FALSE;
@@ -1916,12 +1925,12 @@ PHP_FUNCTION(session_module_name)
 
 static int save_handler_check_session() {
        if (PS(session_status) == php_session_active) {
-               php_error_docref(NULL, E_WARNING, "Cannot change save handler when session is active");
+               php_error_docref(NULL, E_WARNING, "Session save handler cannot be changed when a session is active");
                return FAILURE;
        }
 
        if (SG(headers_sent)) {
-               php_error_docref(NULL, E_WARNING, "Cannot change save handler when headers already sent");
+               php_error_docref(NULL, E_WARNING, "Session save handler cannot be changed after headers have already been sent");
                return FAILURE;
        }
 
@@ -1963,7 +1972,7 @@ PHP_FUNCTION(session_set_save_handler)
                                add_next_index_zval(&PS(mod_user_names).names[i], obj);
                                add_next_index_str(&PS(mod_user_names).names[i], zend_string_copy(func_name));
                        } else {
-                               php_error_docref(NULL, E_ERROR, "Session handler's function table is corrupt");
+                               php_error_docref(NULL, E_ERROR, "Session save handler function table is corrupt");
                                RETURN_FALSE;
                        }
 
@@ -2051,23 +2060,23 @@ PHP_FUNCTION(session_set_save_handler)
                RETURN_THROWS();
        }
 
-       if (save_handler_check_session() == FAILURE) {
-               RETURN_FALSE;
-       }
-
-       /* remove shutdown function */
-       remove_user_shutdown_function("session_shutdown", sizeof("session_shutdown") - 1);
-
        /* At this point argc can only be between 6 and PS_NUM_APIS */
        for (i = 0; i < argc; i++) {
                if (!zend_is_callable(&args[i], 0, NULL)) {
                        zend_string *name = zend_get_callable_name(&args[i]);
-                       php_error_docref(NULL, E_WARNING, "Argument %d is not a valid callback", i+1);
-                       zend_string_release_ex(name, 0);
-                       RETURN_FALSE;
+                       zend_argument_type_error(i + 1, "must be a valid callback, function \"%s\" not found or invalid function name", ZSTR_VAL(name));
+                       zend_string_release(name);
+                       RETURN_THROWS();
                }
        }
 
+       if (save_handler_check_session() == FAILURE) {
+               RETURN_FALSE;
+       }
+
+       /* remove shutdown function */
+       remove_user_shutdown_function("session_shutdown", sizeof("session_shutdown") - 1);
+
        if (PS(mod) && PS(mod) != &ps_mod_user) {
                ini_name = zend_string_init("session.save_handler", sizeof("session.save_handler") - 1, 0);
                ini_val = zend_string_init("user", sizeof("user") - 1, 0);
@@ -2100,12 +2109,12 @@ PHP_FUNCTION(session_save_path)
        }
 
        if (name && PS(session_status) == php_session_active) {
-               php_error_docref(NULL, E_WARNING, "Cannot change save path when session is active");
+               php_error_docref(NULL, E_WARNING, "Session save path cannot be changed when a session is active");
                RETURN_FALSE;
        }
 
        if (name && SG(headers_sent)) {
-               php_error_docref(NULL, E_WARNING, "Cannot change save path when headers already sent");
+               php_error_docref(NULL, E_WARNING, "Session save path cannot be changed after headers have already been sent");
                RETURN_FALSE;
        }
 
@@ -2129,13 +2138,13 @@ PHP_FUNCTION(session_id)
                RETURN_THROWS();
        }
 
-       if (name && PS(use_cookies) && SG(headers_sent)) {
-               php_error_docref(NULL, E_WARNING, "Cannot change session id when headers already sent");
+       if (name && PS(session_status) == php_session_active) {
+               php_error_docref(NULL, E_WARNING, "Session ID cannot be changed when a session is active");
                RETURN_FALSE;
        }
 
-       if (name && PS(session_status) == php_session_active) {
-               php_error_docref(NULL, E_WARNING, "Cannot change session id when session is active");
+       if (name && PS(use_cookies) && SG(headers_sent)) {
+               php_error_docref(NULL, E_WARNING, "Session ID cannot be changed after headers have already been sent");
                RETURN_FALSE;
        }
 
@@ -2172,12 +2181,12 @@ PHP_FUNCTION(session_regenerate_id)
        }
 
        if (PS(session_status) != php_session_active) {
-               php_error_docref(NULL, E_WARNING, "Cannot regenerate session id - session is not active");
+               php_error_docref(NULL, E_WARNING, "Session ID cannot be regenerated when there is no active session");
                RETURN_FALSE;
        }
 
        if (SG(headers_sent)) {
-               php_error_docref(NULL, E_WARNING, "Cannot regenerate session id - headers already sent");
+               php_error_docref(NULL, E_WARNING, "Session ID cannot be regenerated after headers have already been sent");
                RETURN_FALSE;
        }
 
@@ -2186,7 +2195,9 @@ PHP_FUNCTION(session_regenerate_id)
                if (PS(mod)->s_destroy(&PS(mod_data), PS(id)) == FAILURE) {
                        PS(mod)->s_close(&PS(mod_data));
                        PS(session_status) = php_session_none;
-                       php_error_docref(NULL, E_WARNING, "Session object destruction failed.  ID: %s (path: %s)", PS(mod)->s_name, PS(save_path));
+                       if (!EG(exception)) {
+                               php_error_docref(NULL, E_WARNING, "Session object destruction failed. ID: %s (path: %s)", PS(mod)->s_name, PS(save_path));
+                       }
                        RETURN_FALSE;
                }
        } else {
@@ -2217,14 +2228,18 @@ PHP_FUNCTION(session_regenerate_id)
 
        if (PS(mod)->s_open(&PS(mod_data), PS(save_path), PS(session_name)) == FAILURE) {
                PS(session_status) = php_session_none;
-               zend_throw_error(NULL, "Failed to open session: %s (path: %s)", PS(mod)->s_name, PS(save_path));
+               if (!EG(exception)) {
+                       zend_throw_error(NULL, "Failed to open session: %s (path: %s)", PS(mod)->s_name, PS(save_path));
+               }
                RETURN_THROWS();
        }
 
        PS(id) = PS(mod)->s_create_sid(&PS(mod_data));
        if (!PS(id)) {
                PS(session_status) = php_session_none;
-               zend_throw_error(NULL, "Failed to create new session ID: %s (path: %s)", PS(mod)->s_name, PS(save_path));
+               if (!EG(exception)) {
+                       zend_throw_error(NULL, "Failed to create new session ID: %s (path: %s)", PS(mod)->s_name, PS(save_path));
+               }
                RETURN_THROWS();
        }
        if (PS(use_strict_mode) && PS(mod)->s_validate_sid &&
@@ -2234,7 +2249,9 @@ PHP_FUNCTION(session_regenerate_id)
                if (!PS(id)) {
                        PS(mod)->s_close(&PS(mod_data));
                        PS(session_status) = php_session_none;
-                       zend_throw_error(NULL, "Failed to create session ID by collision: %s (path: %s)", PS(mod)->s_name, PS(save_path));
+                       if (!EG(exception)) {
+                               zend_throw_error(NULL, "Failed to create session ID by collision: %s (path: %s)", PS(mod)->s_name, PS(save_path));
+                       }
                        RETURN_THROWS();
                }
        }
@@ -2242,7 +2259,9 @@ PHP_FUNCTION(session_regenerate_id)
        if (PS(mod)->s_read(&PS(mod_data), PS(id), &data, PS(gc_maxlifetime)) == FAILURE) {
                PS(mod)->s_close(&PS(mod_data));
                PS(session_status) = php_session_none;
-               zend_throw_error(NULL, "Failed to create(read) session ID: %s (path: %s)", PS(mod)->s_name, PS(save_path));
+               if (!EG(exception)) {
+                       zend_throw_error(NULL, "Failed to create(read) session ID: %s (path: %s)", PS(mod)->s_name, PS(save_path));
+               }
                RETURN_THROWS();
        }
        if (data) {
@@ -2274,7 +2293,7 @@ PHP_FUNCTION(session_create_id)
        if (prefix && ZSTR_LEN(prefix)) {
                if (php_session_valid_key(ZSTR_VAL(prefix)) == FAILURE) {
                        /* E_ERROR raised for security reason. */
-                       php_error_docref(NULL, E_WARNING, "Prefix cannot contain special characters. Only aphanumeric, ',', '-' are allowed");
+                       php_error_docref(NULL, E_WARNING, "Prefix cannot contain special characters. Only the A-Z, a-z, 0-9, \"-\", and \",\" characters are allowed");
                        RETURN_FALSE;
                } else {
                        smart_str_append(&id, prefix);
@@ -2325,12 +2344,12 @@ PHP_FUNCTION(session_cache_limiter)
        }
 
        if (limiter && PS(session_status) == php_session_active) {
-               php_error_docref(NULL, E_WARNING, "Cannot change cache limiter when session is active");
+               php_error_docref(NULL, E_WARNING, "Session cache limiter cannot be changed when a session is active");
                RETURN_FALSE;
        }
 
        if (limiter && SG(headers_sent)) {
-               php_error_docref(NULL, E_WARNING, "Cannot change cache limiter when headers already sent");
+               php_error_docref(NULL, E_WARNING, "Session cache limiter cannot be changed after headers have already been sent");
                RETURN_FALSE;
        }
 
@@ -2355,12 +2374,12 @@ PHP_FUNCTION(session_cache_expire)
        }
 
        if (!expires_is_null && PS(session_status) == php_session_active) {
-               php_error_docref(NULL, E_WARNING, "Cannot change cache expire when session is active");
+               php_error_docref(NULL, E_WARNING, "Session cache expiration cannot be changed when a session is active");
                RETURN_LONG(PS(cache_expire));
        }
 
        if (!expires_is_null && SG(headers_sent)) {
-               php_error_docref(NULL, E_WARNING, "Cannot change cache expire when headers already sent");
+               php_error_docref(NULL, E_WARNING, "Session cache expiration cannot be changed after headers have already been sent");
                RETURN_FALSE;
        }
 
@@ -2404,7 +2423,7 @@ PHP_FUNCTION(session_decode)
        }
 
        if (PS(session_status) != php_session_active) {
-               php_error_docref(NULL, E_WARNING, "Session is not active. You cannot decode session data");
+               php_error_docref(NULL, E_WARNING, "Session data cannot be decoded when there is no active session");
                RETURN_FALSE;
        }
 
@@ -2427,7 +2446,7 @@ static int php_session_start_set_ini(zend_string *varname, zend_string *new_valu
        return ret;
 }
 
-/* {{{ +   Begin session */
+/* {{{ Begin session */
 PHP_FUNCTION(session_start)
 {
        zval *options = NULL;
@@ -2441,7 +2460,7 @@ PHP_FUNCTION(session_start)
        }
 
        if (PS(session_status) == php_session_active) {
-               php_error_docref(NULL, E_NOTICE, "A session had already been started - ignoring");
+               php_error_docref(NULL, E_NOTICE, "Ignoring session_start() because a session is already active");
                RETURN_TRUE;
        }
 
@@ -2451,7 +2470,7 @@ PHP_FUNCTION(session_start)
         * module is unable to rewrite output.
         */
        if (PS(use_cookies) && SG(headers_sent)) {
-               php_error_docref(NULL, E_WARNING, "Cannot start session when headers already sent");
+               php_error_docref(NULL, E_WARNING, "Session cannot be started after headers have already been sent");
                RETURN_FALSE;
        }
 
@@ -2470,14 +2489,16 @@ PHP_FUNCTION(session_start)
                                                        zend_string *tmp_val;
                                                        zend_string *val = zval_get_tmp_string(value, &tmp_val);
                                                        if (php_session_start_set_ini(str_idx, val) == FAILURE) {
-                                                               php_error_docref(NULL, E_WARNING, "Setting option '%s' failed", ZSTR_VAL(str_idx));
+                                                               php_error_docref(NULL, E_WARNING, "Setting option \"%s\" failed", ZSTR_VAL(str_idx));
                                                        }
                                                        zend_tmp_string_release(tmp_val);
                                                }
                                                break;
                                        default:
-                                               php_error_docref(NULL, E_WARNING, "Option(%s) value must be string, boolean or long", ZSTR_VAL(str_idx));
-                                               break;
+                                               zend_type_error("%s(): Option \"%s\" must be of type string|int|bool, %s given",
+                                                       get_active_function_name(), ZSTR_VAL(str_idx), zend_zval_type_name(value)
+                                               );
+                                               RETURN_THROWS();
                                }
                        }
                        (void) num_idx;
@@ -2547,7 +2568,7 @@ PHP_FUNCTION(session_gc)
        }
 
        if (PS(session_status) != php_session_active) {
-               php_error_docref(NULL, E_WARNING, "Session is not active");
+               php_error_docref(NULL, E_WARNING, "Session cannot be garbage collected when there is no active session");
                RETURN_FALSE;
        }
 
@@ -2647,7 +2668,7 @@ PHP_FUNCTION(session_register_shutdown)
                 * session then tough luck.
                 */
                php_session_flush(1);
-               php_error_docref(NULL, E_WARNING, "Unable to register session flush function");
+               php_error_docref(NULL, E_WARNING, "Session shutdown function cannot be registered");
        }
 }
 /* }}} */
index e70669d5a8819864eb1232762d3772738595ffc1..b8f9f33eba628f21150746713bcec98527a6e0ca 100644 (file)
@@ -42,15 +42,8 @@ function session_commit(): bool {}
 /**
  * @param callable|object $open
  * @param callable|bool $close
- * @param callable $read
- * @param callable $write
- * @param callable $destroy
- * @param callable $gc
- * @param callable $create_sid
- * @param callable $validate_sid
- * @param callable $update_timestamp
  */
-function session_set_save_handler($open, $close = UNKNOWN, $read = UNKNOWN, $write = UNKNOWN, $destroy = UNKNOWN, $gc = UNKNOWN, $create_sid = UNKNOWN, $validate_sid = UNKNOWN, $update_timestamp = UNKNOWN): bool {}
+function session_set_save_handler($open, $close = UNKNOWN, callable $read = UNKNOWN, callable $write = UNKNOWN, callable $destroy = UNKNOWN, callable $gc = UNKNOWN, callable $create_sid = UNKNOWN, callable $validate_sid = UNKNOWN, callable $update_timestamp = UNKNOWN): bool {}
 
 function session_cache_limiter(?string $cache_limiter = null): string|false {}
 
index 622eb4cfb52a393626f37fe0f88e9c9ea5b9d6c1..c47dee63154fe13ae998ff1586e14eab7fab9734 100644 (file)
@@ -1,5 +1,5 @@
 /* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 9e4a4b1d719197772b283abfb1e515180d7b8bb0 */
+ * Stub hash: 22b829d3cdd092c393c924f323cd19bea1517579 */
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_name, 0, 0, MAY_BE_STRING|MAY_BE_FALSE)
        ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, name, IS_STRING, 1, "null")
@@ -60,13 +60,13 @@ ZEND_END_ARG_INFO()
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_session_set_save_handler, 0, 1, _IS_BOOL, 0)
        ZEND_ARG_INFO(0, open)
        ZEND_ARG_INFO(0, close)
-       ZEND_ARG_INFO(0, read)
-       ZEND_ARG_INFO(0, write)
-       ZEND_ARG_INFO(0, destroy)
-       ZEND_ARG_INFO(0, gc)
-       ZEND_ARG_INFO(0, create_sid)
-       ZEND_ARG_INFO(0, validate_sid)
-       ZEND_ARG_INFO(0, update_timestamp)
+       ZEND_ARG_TYPE_INFO(0, read, IS_CALLABLE, 0)
+       ZEND_ARG_TYPE_INFO(0, write, IS_CALLABLE, 0)
+       ZEND_ARG_TYPE_INFO(0, destroy, IS_CALLABLE, 0)
+       ZEND_ARG_TYPE_INFO(0, gc, IS_CALLABLE, 0)
+       ZEND_ARG_TYPE_INFO(0, create_sid, IS_CALLABLE, 0)
+       ZEND_ARG_TYPE_INFO(0, validate_sid, IS_CALLABLE, 0)
+       ZEND_ARG_TYPE_INFO(0, update_timestamp, IS_CALLABLE, 0)
 ZEND_END_ARG_INFO()
 
 ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_cache_limiter, 0, 0, MAY_BE_STRING|MAY_BE_FALSE)
index cbf22b142d6147251b036c0a4f4b4ba351f49b58..d8369cfec59830dac22dce2a822ec2540352585e 100644 (file)
@@ -33,8 +33,8 @@ session_destroy();
 --EXPECTF--
 <a href="/link">
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line %d
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 <a href="/link">
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line %d
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 <a href="/link">
index aa7ba1cebb9791726ea10cf83168f241aac1b001..8a076a1d9f434a6fde3641301d1695e9a0672cca 100644 (file)
@@ -22,7 +22,7 @@ session_write_close();
 print "I live\n";
 ?>
 --EXPECTF--
-Warning: session_start(): Failed to create session data file path. Too short session ID, invalid save_path or path lentgth exceeds MAXPATHLEN(%d) in %s on line 4
+Warning: session_start(): Failed to create session data file path. Too short session ID, invalid save_path or path length exceeds %d characters in %s on line %d
 
 Warning: session_start(): Failed to read session data: files (path: 123;:/really%scompletely:::/invalid;;,23123;213) in %s on line 4
 I live
index 23676ecbda61d288d0a443e7039fec55453a9fce..518ead85d66e118f235a5327de2741f7315b93e0 100644 (file)
@@ -14,7 +14,7 @@ session_decode("userid|s:5:\"mazen\";chatRoom|s:1:\"1\";");
 print "I live\n";
 ?>
 --EXPECTF--
-Warning: session_decode(): Session is not active. You cannot decode session data in %s on line %d
+Warning: session_decode(): Session data cannot be decoded when there is no active session in %s on line %d
 
-Warning: session_decode(): Session is not active. You cannot decode session data in %s on line %d
+Warning: session_decode(): Session data cannot be decoded when there is no active session in %s on line %d
 I live
index 9e99135e5fda3f2f38c7ba330d56cc07f37a9c46..4ae0dbd7f560cdaf0d4c3dea6b1551163bca8ab6 100644 (file)
@@ -5,16 +5,21 @@ Bug #31454 (session_set_save_handler crashes PHP when supplied non-existent obje
 --FILE--
 <?php
 
-session_set_save_handler(
-    array(&$arf, 'open'),
-    array(&$arf, 'close'),
-    array(&$arf, 'read'),
-    array(&$arf, 'write'),
-    array(&$arf, 'destroy'),
-    array(&$arf, 'gc'));
+try {
+    session_set_save_handler(
+        array(&$arf, 'open'),
+        array(&$arf, 'close'),
+        array(&$arf, 'read'),
+        array(&$arf, 'write'),
+        array(&$arf, 'destroy'),
+        array(&$arf, 'gc')
+    );
+} catch (TypeError $exception) {
+    echo $exception->getMessage() . "\n";
+}
 
 echo "Done\n";
 ?>
---EXPECTF--
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %sbug31454.php on line %d
+--EXPECT--
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "Array" not found or invalid function name
 Done
index e2b961c387e079a03438e3c177ca753f88e83ab7..487fba53074c6c72a29794d9c4139806189dd0a5 100644 (file)
@@ -15,5 +15,5 @@ echo "ok\n";
 
 ?>
 --EXPECT--
-Recoverable fatal error: PHP Startup: Cannot set 'user' save handler by ini_set() or session_module_name() in Unknown on line 0
+Recoverable fatal error: PHP Startup: Session save handler "user" cannot be set by ini_set() or session_module_name() in Unknown on line 0
 ok
index 626b4977592da6b988c27af7ea7dfa7a2800331d..ba0f2d28b10f55c0a37ab361f0c506f3010cc0a2 100644 (file)
@@ -13,6 +13,6 @@ var_dump(session_name("foo"));
 var_dump(session_name("bar"));
 ?>
 --EXPECT--
-Warning: PHP Startup: session.name cannot be a numeric or empty '' in Unknown on line 0
+Warning: PHP Startup: session.name "" cannot be numeric or empty in Unknown on line 0
 string(9) "PHPSESSID"
 string(3) "foo"
index 9334bbf16e37263b1e0b693f72b159a9852685be..a59e9f41cc1235a4d8d55717d486df3910e79915 100644 (file)
@@ -20,7 +20,7 @@ session_module_name("user");
 --EXPECTF--
 bool(true)
 
-Warning: session_module_name(): Cannot change save handler module when session is active in %s on line 4
+Warning: session_module_name(): Session save handler module cannot be changed when a session is active in %s on line %d
 bool(true)
 
-Recoverable fatal error: session_module_name(): Cannot set 'user' save handler by ini_set() or session_module_name() in %s on line 7
+Recoverable fatal error: session_module_name(): Session save handler "user" cannot be set by ini_set() or session_module_name() in %s on line %d
index fcdb40d3ba247ccc18005fe4e2bf09b707f5d721..bfec37c9cd11701c924f9c541185b35b2545385e 100644 (file)
@@ -12,5 +12,5 @@ include('skipif.inc');
 var_dump(ini_get("session.upload_progress.freq"));
 ?>
 --EXPECTF--
-Warning: PHP Startup: session.upload_progress.freq must be greater than or equal to zero in %s
+Warning: PHP Startup: session.upload_progress.freq must be greater than or equal to 0 in Unknown on line 0
 string(%d) "1%"
index cafe0070761c209e94d29ced0ac513c67f47d830..bf8e6cc2dd0cc03e8bb65e0429eee578fee1ace2 100644 (file)
@@ -12,5 +12,5 @@ include('skipif.inc');
 var_dump(ini_get("session.upload_progress.freq"));
 ?>
 --EXPECTF--
-Warning: PHP Startup: session.upload_progress.freq cannot be over 100% in %s
+Warning: PHP Startup: session.upload_progress.freq must be less than or equal to 100% in Unknown on line 0
 string(%d) "1%"
index b75a9f64708d35b84cd0a8bc2a175e9287509262..4d8372c538149945d12e41c4ab3c261a2d52aad3 100644 (file)
@@ -45,14 +45,18 @@ var_dump($_FILES);
 var_dump($_SESSION["upload_progress_" . basename(__FILE__)]);
 session_destroy();
 ?>
+--CLEAN--
+<?php
+@unlink(__DIR__ . DIRECTORY_SEPARATOR . "rfc1867_sid_invalid.post.txt");
+?>
 --EXPECTF--
-Warning: Unknown: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0
+Warning: Unknown: Session ID is too long or contains illegal characters. Only the A-Z, a-z, 0-9, "-", and "," characters are allowed in Unknown on line 0
 
 Warning: Unknown: Failed to read session data: files (path: ) in Unknown on line 0
 
 Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0
 
-Warning: Unknown: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0
+Warning: Unknown: Session ID is too long or contains illegal characters. Only the A-Z, a-z, 0-9, "-", and "," characters are allowed in Unknown on line 0
 
 Warning: Unknown: Failed to read session data: files (path: ) in Unknown on line 0
 
index 1ef15d7ff5d4ba28afd41fec164546a434110bcc..3241cb3cdb73a06216de70be8ed915e053f82605 100644 (file)
@@ -28,7 +28,7 @@ string(7) "nocache"
 bool(true)
 string(7) "nocache"
 
-Warning: session_cache_limiter(): Cannot change cache limiter when session is active in %s on line %d
+Warning: session_cache_limiter(): Session cache limiter cannot be changed when a session is active in %s on line %d
 bool(false)
 string(7) "nocache"
 bool(true)
index 695f63ebca8e8667440c703c1fe3a8e5ef22049a..00724a3f9a707a012027f035d2c83e925edce635 100644 (file)
@@ -27,7 +27,7 @@ string(7) "nocache"
 bool(true)
 string(7) "nocache"
 
-Warning: session_cache_limiter(): Cannot change cache limiter when session is active in %s on line %d
+Warning: session_cache_limiter(): Session cache limiter cannot be changed when a session is active in %s on line %d
 bool(false)
 string(7) "nocache"
 bool(true)
index f37af43936f61b73cbaa0fb9a88784b3073210ad..8f4e9296d1c7c2849405e71b2038efd577b0dbfb 100644 (file)
@@ -26,7 +26,7 @@ string(7) "nocache"
 bool(true)
 string(7) "nocache"
 
-Warning: session_cache_limiter(): Cannot change cache limiter when session is active in %s on line %d
+Warning: session_cache_limiter(): Session cache limiter cannot be changed when a session is active in %s on line %d
 bool(false)
 string(7) "nocache"
 bool(true)
index 9494edd3394b153aded195723ae819c92b1fb477..ef4eab2bd23d17bcc127c252f129dde9c57d58e9 100644 (file)
@@ -28,7 +28,7 @@ ob_end_flush();
 --EXPECTF--
 *** Testing session_decode() : variation ***
 
-Warning: session_start(): Cannot find serialization handler 'blah' - session startup failed in %s on line %d
+Warning: session_start(): Cannot find session serialization handler "blah" - session startup failed in %s on line %d
 bool(false)
 
 Warning: Undefined variable $_SESSION in %s on line %d
@@ -42,7 +42,7 @@ array(3) {
   float(123.456)
 }
 
-Warning: session_decode(): Session is not active. You cannot decode session data in %s on line %d
+Warning: session_decode(): Session data cannot be decoded when there is no active session in %s on line %d
 bool(false)
 array(3) {
   ["foo"]=>
index 9cca3ffea47377964cf0c20305da1907f08b56f4..a2d3d0ca309a65c4f2b10a845b290546f3c50d42 100644 (file)
@@ -98,63 +98,63 @@ ob_end_flush();
 -- Iteration 1 --
 bool(true)
 
-Notice: session_encode(): Skipping numeric key 0 in %s on line %d
+Warning: session_encode(): Skipping numeric key 0 in %s on line %d
 bool(false)
 bool(true)
 
 -- Iteration 2 --
 bool(true)
 
-Notice: session_encode(): Skipping numeric key 1 in %s on line %d
+Warning: session_encode(): Skipping numeric key 1 in %s on line %d
 bool(false)
 bool(true)
 
 -- Iteration 3 --
 bool(true)
 
-Notice: session_encode(): Skipping numeric key 12345 in %s on line %d
+Warning: session_encode(): Skipping numeric key 12345 in %s on line %d
 bool(false)
 bool(true)
 
 -- Iteration 4 --
 bool(true)
 
-Notice: session_encode(): Skipping numeric key -2345 in %s on line %d
+Warning: session_encode(): Skipping numeric key -2345 in %s on line %d
 bool(false)
 bool(true)
 
 -- Iteration 5 --
 bool(true)
 
-Notice: session_encode(): Skipping numeric key 10 in %s on line %d
+Warning: session_encode(): Skipping numeric key 10 in %s on line %d
 bool(false)
 bool(true)
 
 -- Iteration 6 --
 bool(true)
 
-Notice: session_encode(): Skipping numeric key -10 in %s on line %d
+Warning: session_encode(): Skipping numeric key -10 in %s on line %d
 bool(false)
 bool(true)
 
 -- Iteration 7 --
 bool(true)
 
-Notice: session_encode(): Skipping numeric key %s in %s on line %d
+Warning: session_encode(): Skipping numeric key %s in %s on line %d
 bool(false)
 bool(true)
 
 -- Iteration 8 --
 bool(true)
 
-Notice: session_encode(): Skipping numeric key 0 in %s on line %d
+Warning: session_encode(): Skipping numeric key 0 in %s on line %d
 bool(false)
 bool(true)
 
 -- Iteration 9 --
 bool(true)
 
-Notice: session_encode(): Skipping numeric key 0 in %s on line %d
+Warning: session_encode(): Skipping numeric key 0 in %s on line %d
 bool(false)
 bool(true)
 
@@ -171,28 +171,28 @@ bool(true)
 -- Iteration 12 --
 bool(true)
 
-Notice: session_encode(): Skipping numeric key 1 in %s on line %d
+Warning: session_encode(): Skipping numeric key 1 in %s on line %d
 bool(false)
 bool(true)
 
 -- Iteration 13 --
 bool(true)
 
-Notice: session_encode(): Skipping numeric key 0 in %s on line %d
+Warning: session_encode(): Skipping numeric key 0 in %s on line %d
 bool(false)
 bool(true)
 
 -- Iteration 14 --
 bool(true)
 
-Notice: session_encode(): Skipping numeric key 1 in %s on line %d
+Warning: session_encode(): Skipping numeric key 1 in %s on line %d
 bool(false)
 bool(true)
 
 -- Iteration 15 --
 bool(true)
 
-Notice: session_encode(): Skipping numeric key 0 in %s on line %d
+Warning: session_encode(): Skipping numeric key 0 in %s on line %d
 bool(false)
 bool(true)
 
@@ -242,7 +242,7 @@ bool(true)
 
 Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
 
-Notice: session_encode(): Skipping numeric key %d in %s on line %d
+Warning: session_encode(): Skipping numeric key %d in %s on line %d
 bool(false)
 bool(true)
 Done
index b334842feada3d713ed7ef1343142739cba3546b..5305d483b5b02028b3eab15f60fcd595f9136bac 100644 (file)
@@ -29,17 +29,17 @@ ob_end_flush();
 *** Testing session_encode() : variation ***
 bool(true)
 
-Notice: session_encode(): Skipping numeric key 0 in %s on line %d
+Warning: session_encode(): Skipping numeric key 0 in %s on line %d
 bool(false)
 bool(true)
 bool(true)
 
-Notice: session_encode(): Skipping numeric key 1234567890 in %s on line %d
+Warning: session_encode(): Skipping numeric key 1234567890 in %s on line %d
 bool(false)
 bool(true)
 bool(true)
 
-Notice: session_encode(): Skipping numeric key -1234567890 in %s on line %d
+Warning: session_encode(): Skipping numeric key -1234567890 in %s on line %d
 bool(false)
 bool(true)
 Done
index 2ffa79335be1a9197bc7071d50e5bf59b916beaf..8b867b6b636e58879fc6abb650c86d0c3df21a23 100644 (file)
@@ -23,7 +23,7 @@ ob_end_flush();
 --EXPECTF--
 *** Testing session_encode() : variation ***
 
-Warning: session_start(): Cannot find serialization handler 'blah' - session startup failed in %s on line %d
+Warning: session_start(): Cannot find session serialization handler "blah" - session startup failed in %s on line %d
 bool(false)
 
 Warning: session_encode(): Cannot encode non-existent session in %s on line %d
index b98c7e43e1a482a02ae04d1dd026326e0ef58aca..103b784c8f423529393633e377b283b6010ffc00 100644 (file)
@@ -22,7 +22,7 @@ ob_end_flush();
 --EXPECTF--
 *** Testing session_gc() : basic functionality ***
 
-Warning: session_gc(): Session is not active in %s on line %d
+Warning: session_gc(): Session cannot be garbage collected when there is no active session in %s on line %d
 bool(false)
 bool(true)
 int(%d)
index c017d73d6bba30fdc39cd1a58e3e2405f5d822fc..23a9a59a2bccab65eeb230e32b11edd6b9a5a5c0 100644 (file)
@@ -29,7 +29,7 @@ string(4) "test"
 string(10) "1234567890"
 bool(true)
 
-Warning: session_id(): Cannot change session id when session is active in %s on line %d
+Warning: session_id(): Session ID cannot be changed when a session is active in %s on line %d
 bool(false)
 bool(true)
 string(0) ""
index 58c3f837a7ea2bca24a062866fd46b90bc0d9226..0335d5823986d454ec826b8335b905de2611a752 100644 (file)
@@ -116,67 +116,67 @@ string(1) "4"
 string(1) "1"
 string(15) "session started"
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 38
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 39
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 40
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 bool(false)
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 42
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 43
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 44
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 45
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 46
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 47
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 48
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 49
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 50
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 51
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 52
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 53
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 54
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 55
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 56
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 57
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 58
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 
-Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in %s on line 59
+Warning: ini_set(): Session ini settings cannot be changed when a session is active in %s on line %d
 bool(false)
 Done
index 05c972fb91c36648bd903896af6230e4dbb60653..fff325ad964d21acf5cb3c54d0c192e23e56ac71 100644 (file)
@@ -20,7 +20,7 @@ ob_end_flush();
 --EXPECTF--
 *** Testing session_module_name() : variation ***
 
-Warning: session_module_name(): Cannot find named PHP session module (blah) in %s on line %d
+Warning: session_module_name(): Session handler module "blah" cannot be found in %s on line %d
 bool(false)
 bool(true)
 string(%d) "%s"
index 481229eebca97bbffa9a6b10481550203a739008..2be7b636de3d6176931b097ec76f54bff65c8a79 100644 (file)
@@ -36,8 +36,6 @@ ob_end_flush();
 string(5) "files"
 string(4) "user"
 
-Warning: session_start(): Failed to initialize storage module: user (path: ) in %s on line %d
-
 Fatal error: Uncaught Exception: Stop...! in %s:%d
 Stack trace:
 #0 [internal function]: open('', 'PHPSESSID')
index 35db378ea523902770c899b53c9786c6fca03f1e..71849de565bebaa69af84d61ec454db4f129467d 100644 (file)
@@ -47,7 +47,7 @@ string(1) "   "
 bool(true)
 string(1) "    "
 
-Warning: session_name(): session.name cannot be a numeric or empty '' in %s on line %d
+Warning: session_name(): session.name "" cannot be numeric or empty in %s on line %d
 string(1) "    "
 bool(true)
 string(1) "    "
index 8d221ef006e6531da466daff65908c7946d8f0af..9be5a65b1b0b0cba2e658251ae64c7f710fcf13f 100644 (file)
@@ -26,7 +26,7 @@ ob_end_flush();
 *** Testing session_regenerate_id() : basic functionality ***
 string(0) ""
 
-Warning: session_regenerate_id(): Cannot regenerate session id - session is not active in %s on line %d
+Warning: session_regenerate_id(): Session ID cannot be regenerated when there is no active session in %s on line %d
 bool(false)
 string(0) ""
 bool(true)
@@ -34,7 +34,7 @@ bool(true)
 string(%d) "%s"
 bool(true)
 
-Warning: session_regenerate_id(): Cannot regenerate session id - session is not active in %s on line %d
+Warning: session_regenerate_id(): Session ID cannot be regenerated when there is no active session in %s on line %d
 bool(false)
 string(0) ""
 Done
index 1967cff01843cbb3cf5e9a07eb98f22a3f3a7f61..806f20696eb39edda9bb852a84b51a170f15e807 100644 (file)
@@ -26,7 +26,7 @@ ob_end_flush();
 *** Testing session_regenerate_id() : variation ***
 string(0) ""
 
-Warning: session_regenerate_id(): Cannot regenerate session id - session is not active in %s on line %d
+Warning: session_regenerate_id(): Session ID cannot be regenerated when there is no active session in %s on line %d
 bool(false)
 string(0) ""
 bool(true)
@@ -34,7 +34,7 @@ bool(true)
 string(%d) "%s"
 bool(true)
 
-Warning: session_regenerate_id(): Cannot regenerate session id - session is not active in %s on line %d
+Warning: session_regenerate_id(): Session ID cannot be regenerated when there is no active session in %s on line %d
 bool(false)
 string(0) ""
 Done
index 8475b2d2e4a5022e252cdab93390232629431fee..8dbddca98da279df437c6776a8e75d771453c3d7 100644 (file)
@@ -38,7 +38,7 @@ string(%d) "%stests"
 bool(true)
 string(%d) "%stests"
 
-Warning: session_save_path(): Cannot change save path when session is active in %s on line %d
+Warning: session_save_path(): Session save path cannot be changed when a session is active in %s on line %d
 bool(false)
 string(%d) "%stests"
 bool(true)
index 79bf7a9ea9467e56b4e4f98bee7655e302c395c4..21f04ef17ff6faa2fc9ad977105d24f2bc39eac1 100644 (file)
@@ -23,7 +23,7 @@ ob_end_flush();
 bool(true)
 bool(true)
 
-Warning: session_set_cookie_params(): Cannot change session cookie parameters when session is active in %s on line %d
+Warning: session_set_cookie_params(): Session cookie parameters cannot be changed when a session is active in %s on line %d
 bool(false)
 bool(true)
 bool(true)
index bad85d3aaf0fac7fece6d66d7066e827e1218696..7b2c474d1a60ad06db5dcacf4496f90f7aa85a0b 100644 (file)
@@ -36,7 +36,7 @@ string(4) "3600"
 bool(true)
 string(4) "3600"
 
-Warning: session_set_cookie_params(): Cannot change session cookie parameters when session is active in %s on line %d
+Warning: session_set_cookie_params(): Session cookie parameters cannot be changed when a session is active in %s on line %d
 bool(false)
 string(4) "3600"
 bool(true)
index ac80c10c10bf127dd9278f4e33c07f9ede3f2bb6..ca3f0aa887777371b4094c59b04d2971335e58e8 100644 (file)
@@ -34,7 +34,7 @@ string(4) "/foo"
 bool(true)
 string(4) "/foo"
 
-Warning: session_set_cookie_params(): Cannot change session cookie parameters when session is active in %s on line %d
+Warning: session_set_cookie_params(): Session cookie parameters cannot be changed when a session is active in %s on line %d
 bool(false)
 string(4) "/foo"
 bool(true)
index 1ba46eae7d7acf163399477e8236006892e99505..166730f89a538484df790acbfc4af218051b0f91 100644 (file)
@@ -34,7 +34,7 @@ string(4) "blah"
 bool(true)
 string(4) "blah"
 
-Warning: session_set_cookie_params(): Cannot change session cookie parameters when session is active in %s on line %d
+Warning: session_set_cookie_params(): Session cookie parameters cannot be changed when a session is active in %s on line %d
 bool(false)
 string(4) "blah"
 bool(true)
index 16606f9f611b5cfd9faa76acf1b8d9aa248ab05e..380defcd2ccb3d689e7c88b6dda2b21b18011a88 100644 (file)
@@ -34,7 +34,7 @@ string(1) "0"
 bool(true)
 string(1) "0"
 
-Warning: session_set_cookie_params(): Cannot change session cookie parameters when session is active in %s on line %d
+Warning: session_set_cookie_params(): Session cookie parameters cannot be changed when a session is active in %s on line %d
 bool(false)
 string(1) "0"
 bool(true)
index a73c834ed7559c303ea8b6bf8c1670cdef15e8e0..390937258be1ec1fe4d9008f9d29065e73cf1e04 100644 (file)
@@ -34,7 +34,7 @@ string(1) "0"
 bool(true)
 string(1) "0"
 
-Warning: session_set_cookie_params(): Cannot change session cookie parameters when session is active in %s on line %d
+Warning: session_set_cookie_params(): Session cookie parameters cannot be changed when a session is active in %s on line %d
 bool(false)
 string(1) "0"
 bool(true)
index 983e8e68adabf7c643fdcdd147137975d3e38196..9d9f116d422af3abaa81aa3accb390d2e4621472 100644 (file)
@@ -34,7 +34,7 @@ string(7) "nothing"
 bool(true)
 string(7) "nothing"
 
-Warning: session_set_cookie_params(): Cannot change session cookie parameters when session is active in %s on line %d
+Warning: session_set_cookie_params(): Session cookie parameters cannot be changed when a session is active in %s on line %d
 bool(false)
 string(7) "nothing"
 bool(true)
index bd5aec592bb72220cc9523f3bc7ed47b6f1b72b8..25feabf1fd29c7b1dd0bc0778baff7ebdd6a1ca5 100644 (file)
@@ -17,8 +17,17 @@ ob_start();
 echo "*** Testing session_set_cookie_params() : array parameter variation ***\n";
 
 // Invalid cases
-var_dump(session_set_cookie_params([]));
-var_dump(session_set_cookie_params(["unknown_key" => true, "secure_invalid" => true]));
+try {
+    session_set_cookie_params([]);
+} catch (ValueError $exception) {
+    echo $exception->getMessage() . "\n";
+}
+
+try {
+    session_set_cookie_params(["unknown_key" => true, "secure_invalid" => true]);
+} catch (ValueError $exception) {
+    echo $exception->getMessage() . "\n";
+}
 
 var_dump(ini_get("session.cookie_secure"));
 var_dump(ini_get("session.cookie_samesite"));
@@ -39,16 +48,12 @@ ob_end_flush();
 ?>
 --EXPECTF--
 *** Testing session_set_cookie_params() : array parameter variation ***
+session_set_cookie_params(): Argument #1 ($lifetime_or_options) must contain at least 1 valid key
 
-Warning: session_set_cookie_params(): No valid keys were found in the options array in %s
-bool(false)
-
-Warning: session_set_cookie_params(): Unrecognized key 'unknown_key' found in the options array in %s
+Warning: session_set_cookie_params(): Argument #1 ($lifetime_or_options) contains an unrecognized key "unknown_key" in %s on line %d
 
-Warning: session_set_cookie_params(): Unrecognized key 'secure_invalid' found in the options array in %s
-
-Warning: session_set_cookie_params(): No valid keys were found in the options array in %s
-bool(false)
+Warning: session_set_cookie_params(): Argument #1 ($lifetime_or_options) contains an unrecognized key "secure_invalid" in %s on line %d
+session_set_cookie_params(): Argument #1 ($lifetime_or_options) must contain at least 1 valid key
 string(1) "0"
 string(0) ""
 bool(true)
@@ -59,7 +64,7 @@ bool(true)
 string(2) "42"
 string(1) "/"
 
-Warning: session_set_cookie_params(): Cannot pass arguments after the options array in %s
+Warning: session_set_cookie_params(): Cannot pass arguments after the options array in %s on line %d
 bool(false)
 string(1) "/"
 Done
index 2a451c0644b55a55638001660768691390ac85d8..459f03c825a6b1892c69955a912913986eba05c3 100644 (file)
@@ -60,13 +60,13 @@ ob_end_flush();
 *** Testing session_set_save_handler() : basic functionality ***
 string(%d) "%s"
 
-Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d
+Warning: session_module_name(): Session handler module "" cannot be found in %s on line %d
 bool(false)
 
-Warning: session_module_name(): Cannot find named PHP session module (blah) in %s on line %d
+Warning: session_module_name(): Session handler module "blah" cannot be found in %s on line %d
 bool(false)
 
-Warning: session_module_name(): Cannot find named PHP session module (foo) in %s on line %d
+Warning: session_module_name(): Session handler module "foo" cannot be found in %s on line %d
 bool(false)
 Open [%s,PHPSESSID]
 Read [%s,%s]
index 601ca32b7f9df50a90a5e58313fd996314159e96..0849013a8ff6942c0a2d23a8827ab6186121528b 100644 (file)
@@ -43,8 +43,6 @@ var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i
 --EXPECTF--
 *** Testing session_set_save_handler() : incorrect arguments for existing handler open ***
 Open 
-
-Warning: session_start(): Failed to initialize storage module: user (path: ) in %s on line %d
 SessionHandler::open() expects exactly 2 arguments, 0 given
 
 Warning: Undefined variable $_SESSION in %s on line %d
index 6bb1fca5332c02cef9f7878a7e8f235dbffabc2c..6eee4f8b6a31ff0360d46b437ba3343ed8d4414c 100644 (file)
@@ -21,5 +21,5 @@ session_set_save_handler($handler);
 session_start();
 ?>
 --EXPECT--
-Recoverable fatal error: PHP Startup: Cannot set 'user' save handler by ini_set() or session_module_name() in Unknown on line 0
+Recoverable fatal error: PHP Startup: Session save handler "user" cannot be set by ini_set() or session_module_name() in Unknown on line 0
 *** Testing session_set_save_handler() : calling default handler when save_handler=user ***
index df5cfa6e7663bdeec63a7c7920eda76fed837bbd..535850ac3749aa5099d1467bddd22d1581c492e8 100644 (file)
@@ -47,13 +47,13 @@ ob_end_flush();
 *** Testing session_set_save_handler() : using closures as callbacks ***
 string(%d) "%s"
 
-Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d
+Warning: session_module_name(): Session handler module "" cannot be found in %s on line %d
 bool(false)
 
-Warning: session_module_name(): Cannot find named PHP session module (blah) in %s on line %d
+Warning: session_module_name(): Session handler module "blah" cannot be found in %s on line %d
 bool(false)
 
-Warning: session_module_name(): Cannot find named PHP session module (foo) in %s on line %d
+Warning: session_module_name(): Session handler module "foo" cannot be found in %s on line %d
 bool(false)
 Open [%s,PHPSESSID]
 Read [%s,%s]
index e47523c8723229e61b44282a1545b670a560b4c9..34ee886012f8ce24de61b60855360f72804433a3 100644 (file)
@@ -78,9 +78,13 @@ $inputs = array(
 $iterator = 1;
 foreach($inputs as $input) {
     echo "\n-- Iteration $iterator --\n";
-    var_dump(session_set_save_handler($input, NULL, NULL, NULL, NULL, NULL));
+    try {
+        session_set_save_handler($input, NULL, NULL, NULL, NULL, NULL);
+    } catch (TypeError $exception) {
+        echo $exception->getMessage() . "\n";
+    }
     $iterator++;
-};
+}
 
 fclose($fp);
 echo "Done";
@@ -90,122 +94,74 @@ ob_end_flush();
 *** Testing session_set_save_handler() : error functionality ***
 
 -- Iteration 1 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "0" not found or invalid function name
 
 -- Iteration 2 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "1" not found or invalid function name
 
 -- Iteration 3 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "12345" not found or invalid function name
 
 -- Iteration 4 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "-2345" not found or invalid function name
 
 -- Iteration 5 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "10.5" not found or invalid function name
 
 -- Iteration 6 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "-10.5" not found or invalid function name
 
 -- Iteration 7 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "123456789000" not found or invalid function name
 
 -- Iteration 8 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "1.23456789E-9" not found or invalid function name
 
 -- Iteration 9 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "0.5" not found or invalid function name
 
 -- Iteration 10 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "" not found or invalid function name
 
 -- Iteration 11 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "" not found or invalid function name
 
 -- Iteration 12 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "1" not found or invalid function name
 
 -- Iteration 13 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "" not found or invalid function name
 
 -- Iteration 14 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "1" not found or invalid function name
 
 -- Iteration 15 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "" not found or invalid function name
 
 -- Iteration 16 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "" not found or invalid function name
 
 -- Iteration 17 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "" not found or invalid function name
 
 -- Iteration 18 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "Nothing" not found or invalid function name
 
 -- Iteration 19 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "Nothing" not found or invalid function name
 
 -- Iteration 20 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "Hello World!" not found or invalid function name
 
 -- Iteration 21 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "classA::__invoke" not found or invalid function name
 
 -- Iteration 22 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "" not found or invalid function name
 
 -- Iteration 23 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "" not found or invalid function name
 
 -- Iteration 24 --
-
-Warning: session_set_save_handler(): Argument 1 is not a valid callback in %s on line %d
-bool(false)
+session_set_save_handler(): Argument #1 ($open) must be a valid callback, function "Resource id #%d" not found or invalid function name
 Done
index a57734e411248f03ab85fd77bcb5288ea6b19b6d..bcf08fdc23d8fb87b454cd11a82f175addc49bd3 100644 (file)
@@ -29,8 +29,6 @@ ob_end_flush();
 --EXPECTF--
 *** Testing session_set_save_handler() : error functionality ***
 
-Warning: session_start(): Failed to initialize storage module: user (path: ) in %s on line %d
-
 Fatal error: Uncaught Exception: Do something bad..! in %s:%d
 Stack trace:
 #0 [internal function]: open('', 'PHPSESSID')
index 2b39cb55004ff7c53704e968330a83cce851a789..289a0712bed753ae6413b005f487307b3aa55086 100644 (file)
@@ -11,28 +11,54 @@ echo "*** Testing session_set_save_handler() : error functionality ***\n";
 
 function callback() { return true; }
 
+try {
+    session_set_save_handler("callback", "callback", "callback", "callback", "callback", "callback");
+} catch (TypeError $exception) {
+    echo $exception->getMessage() . "\n";
+}
+
+try {
+    session_set_save_handler("callback", "echo", "callback", "callback", "callback", "callback");
+} catch (TypeError $exception) {
+    echo $exception->getMessage() . "\n";
+}
+
+try {
+    session_set_save_handler("callback", "callback", "echo", "callback", "callback", "callback");
+} catch (TypeError $exception) {
+    echo $exception->getMessage() . "\n";
+}
+
+try {
+    session_set_save_handler("callback", "callback", "callback", "echo", "callback", "callback");
+} catch (TypeError $exception) {
+    echo $exception->getMessage() . "\n";
+}
+
+try {
+    session_set_save_handler("callback", "callback", "callback", "callback", "echo", "callback");
+} catch (TypeError $exception) {
+    echo $exception->getMessage() . "\n";
+}
+
+try {
+    session_set_save_handler("callback", "callback", "callback", "callback", "callback", "echo");
+} catch (TypeError $exception) {
+    echo $exception->getMessage() . "\n";
+}
+
 session_set_save_handler("callback", "callback", "callback", "callback", "callback", "callback");
-session_set_save_handler("callback", "echo", "callback", "callback", "callback", "callback");
-session_set_save_handler("callback", "callback", "echo", "callback", "callback", "callback");
-session_set_save_handler("callback", "callback", "callback", "echo", "callback", "callback");
-session_set_save_handler("callback", "callback", "callback", "callback", "echo", "callback");
-session_set_save_handler("callback", "callback", "callback", "callback", "callback", "echo");
-session_set_save_handler("callback", "callback", "callback", "callback", "callback", "callback");
+
 var_dump(session_start());
 ob_end_flush();
 ?>
 --EXPECTF--
 *** Testing session_set_save_handler() : error functionality ***
-
-Warning: session_set_save_handler(): Argument 2 is not a valid callback in %s on line %d
-
-Warning: session_set_save_handler(): Argument 3 is not a valid callback in %s on line %d
-
-Warning: session_set_save_handler(): Argument 4 is not a valid callback in %s on line %d
-
-Warning: session_set_save_handler(): Argument 5 is not a valid callback in %s on line %d
-
-Warning: session_set_save_handler(): Argument 6 is not a valid callback in %s on line %d
+session_set_save_handler(): Argument #2 ($close) must be a valid callback, function "echo" not found or invalid function name
+session_set_save_handler(): Argument #3 ($read) must be a valid callback, function "echo" not found or invalid function name
+session_set_save_handler(): Argument #4 ($write) must be a valid callback, function "echo" not found or invalid function name
+session_set_save_handler(): Argument #5 ($destroy) must be a valid callback, function "echo" not found or invalid function name
+session_set_save_handler(): Argument #6 ($gc) must be a valid callback, function "echo" not found or invalid function name
 
 Warning: session_start(): Failed to read session data: user (%s) in %s on line %d
 bool(false)
index eed5ee2f8d342c94209009aec6d7759a708ffa41..10971a2b5f031dc23e454749c49ed7305cc340d6 100644 (file)
@@ -83,3 +83,5 @@ session_start();
 bool(true)
 session_set_save_handler(): Argument #1 ($open) must be of type SessionHandlerInterface, MySession2 given
 good handler writing
+
+Deprecated: Unknown: Session callback must have a return value of type bool, int returned in Unknown on line 0
index 5f288fd826e96ad3f7c07147fa2543e881aa08d3..6321c5a5681c83517379314b21c744e4b1e19ab8 100644 (file)
@@ -78,10 +78,5 @@ session_unset();
 Fatal error: Uncaught Error: Session id must be a string in %s:%d
 Stack trace:
 #0 %s(%d): session_start()
-#1 {main}
-
-Next Error: Failed to create session ID: user (path: %s) in %s:%d
-Stack trace:
-#0 %s(%d): session_start()
 #1 {main}
   thrown in %s on line %d
diff --git a/ext/session/tests/session_set_save_handler_type_error.phpt b/ext/session/tests/session_set_save_handler_type_error.phpt
new file mode 100644 (file)
index 0000000..67c4753
--- /dev/null
@@ -0,0 +1,58 @@
+--TEST--
+Test session_set_save_handler() function: interface wrong
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--INI--
+session.name=PHPSESSID
+session.save_handler=files
+--FILE--
+<?php
+
+$validCallback = function () { return true; };
+$deprecatedCallback = function () { return 0; };
+$exceptionCallback = function () { return []; };
+
+ob_start();
+
+try {
+    $ret = session_set_save_handler($exceptionCallback, $validCallback, $validCallback, $validCallback, $validCallback, $validCallback);
+    session_start();
+} catch (TypeError $exception) {
+    echo $exception->getMessage() . "\n";
+}
+
+try {
+    $ret = session_set_save_handler($deprecatedCallback, $validCallback, $validCallback, $validCallback, $validCallback, $validCallback);
+    session_start();
+} catch (TypeError $exception) {
+    echo $exception->getMessage() . "\n";
+}
+
+try {
+    $ret = session_set_save_handler($validCallback, $exceptionCallback, $validCallback, $validCallback, $validCallback, $validCallback);
+    session_start();
+} catch (TypeError $exception) {
+    echo $exception->getMessage() . "\n";
+}
+
+try {
+    $ret = session_set_save_handler($validCallback, $deprecatedCallback, $exceptionCallback, $validCallback, $validCallback, $validCallback);
+    session_start();
+} catch (TypeError $exception) {
+    echo $exception->getMessage() . "\n";
+}
+
+ob_end_flush();
+
+?>
+--EXPECTF--
+Session callback must have a return value of type bool, array returned
+
+Deprecated: session_start(): Session callback must have a return value of type bool, int returned in %s on line %d
+
+Warning: session_start(): Failed to read session data: user (%s) in %s on line %d
+Session callback must have a return value of type bool, array returned
+
+Deprecated: session_start(): Session callback must have a return value of type bool, int returned in %s on line %d
+
+Warning: session_start(): Failed to read session data: user (%s) in %s on line %d
index e192ac8838992a65016d02020056462db73083e9..7e3a749aade73a56244f961143a38cf68b511a8b 100644 (file)
@@ -23,11 +23,11 @@ ob_end_flush();
 *** Testing session_set_save_handler() : variation ***
 string(%d) "%s"
 
-Warning: session_module_name(): Cannot find named PHP session module () in %s on line %d
+Warning: session_module_name(): Session handler module "" cannot be found in %s on line %d
 bool(false)
 string(%d) "%s"
 
-Warning: session_module_name(): Cannot find named PHP session module (blah) in %s on line %d
+Warning: session_module_name(): Session handler module "blah" cannot be found in %s on line %d
 bool(false)
 string(%d) "%s"
 string(%d) "%s"
index 394d85e7b167b6bbdac70a993e03a00e0ecb4f7c..224846466e1af8e17e8a8f4165be0d77facb4fe5 100644 (file)
@@ -22,6 +22,6 @@ ob_end_flush();
 *** Testing session_set_save_handler() : variation ***
 bool(true)
 
-Warning: session_set_save_handler(): Cannot change save handler when session is active in %s on line %d
+Warning: session_set_save_handler(): Session save handler cannot be changed when a session is active in %s on line %d
 bool(false)
 bool(true)
index 50fa6f62e05de1fa02c2310b290368a5eda5b57e..be825cbe7234f24c4f7ec0f5f7a932f64dbc677b 100644 (file)
@@ -24,8 +24,8 @@ ob_end_flush();
 *** Testing session_set_save_handler() : variation ***
 int(2)
 
-Warning: session_save_path(): Cannot change save path when session is active in %s on line %d
+Warning: session_save_path(): Session save path cannot be changed when a session is active in %s on line %d
 
-Warning: session_set_save_handler(): Cannot change save handler when session is active in %s on line %d
+Warning: session_set_save_handler(): Session save handler cannot be changed when a session is active in %s on line %d
 bool(false)
 bool(true)
diff --git a/ext/session/tests/session_start_error.phpt b/ext/session/tests/session_start_error.phpt
new file mode 100644 (file)
index 0000000..ccfdada
--- /dev/null
@@ -0,0 +1,25 @@
+--TEST--
+Test session_start() errors
+--SKIPIF--
+<?php include('skipif.inc'); ?>
+--FILE--
+<?php
+
+ob_start();
+
+try {
+    session_start(['option' => new stdClass()]);
+} catch (TypeError $exception) {
+    echo $exception->getMessage() . "\n";
+}
+
+var_dump(session_start(['option' => false]));
+
+ob_end_flush();
+
+?>
+--EXPECTF--
+session_start(): Option "option" must be of type string|int|bool, stdClass given
+
+Warning: session_start(): Setting option "option" failed in %s on line %d
+bool(true)
index b34abbacddce7ba138a8dc96ae79467876aad4f4..aac1e513899c6c80ce11fa16bf5e53fb61b00014 100644 (file)
@@ -23,15 +23,15 @@ ob_end_flush();
 *** Testing session_start() : variation ***
 bool(true)
 
-Notice: session_start(): A session had already been started - ignoring in %s on line %d
+Notice: session_start(): Ignoring session_start() because a session is already active in %s on line %d
 bool(true)
 
-Notice: session_start(): A session had already been started - ignoring in %s on line %d
+Notice: session_start(): Ignoring session_start() because a session is already active in %s on line %d
 bool(true)
 
-Notice: session_start(): A session had already been started - ignoring in %s on line %d
+Notice: session_start(): Ignoring session_start() because a session is already active in %s on line %d
 bool(true)
 
-Notice: session_start(): A session had already been started - ignoring in %s on line %d
+Notice: session_start(): Ignoring session_start() because a session is already active in %s on line %d
 bool(true)
 Done
index 99740c0b92af5508728d950c68442996592c3041..7e5c465a35b5a11b5e32d74b2d7f09c1377fc4c5 100644 (file)
@@ -24,7 +24,7 @@ ob_end_flush();
 *** Testing session_start() : variation ***
 string(%d) "%s"
 
-Notice: session_start(): A session had already been started - ignoring in %s on line %d
+Notice: session_start(): Ignoring session_start() because a session is already active in %s on line %d
 bool(true)
 string(%d) "%s"
 bool(true)