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;
}
} 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); \
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;
}
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; \
} \
#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; \
}
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();
/* || 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;
}
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);
}
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;
}
/* 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;
/* "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;
}
/* 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;
}
/* 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;
}
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;
}
/* }}} */
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;
}
/* }}} */
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;
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;
}
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;
}
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;
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;
}
}
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;
}
}
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;
}
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);
}
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;
}
}
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;
}
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;
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;
}
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;
}
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);
}
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;
}
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;
}
}
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;
}
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 {
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 &&
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();
}
}
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) {
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);
}
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;
}
}
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;
}
}
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;
}
return ret;
}
-/* {{{ + Begin session */
+/* {{{ Begin session */
PHP_FUNCTION(session_start)
{
zval *options = NULL;
}
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;
}
* 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;
}
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;
}
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;
}
* 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");
}
}
/* }}} */
/**
* @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 {}
/* 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")
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)
--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">
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
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
--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
?>
--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
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"
--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
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%"
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%"
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
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)
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)
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)
--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
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"]=>
-- 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)
-- 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)
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
*** 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
--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
--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)
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) ""
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
--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"
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')
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) " "
*** 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)
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
*** 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)
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
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)
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)
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)
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)
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)
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)
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)
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)
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"));
?>
--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)
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
*** 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]
--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
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 ***
*** 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]
$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";
*** 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
--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')
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)
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
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
--- /dev/null
+--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
*** 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"
*** 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)
*** 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)
--- /dev/null
+--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)
*** 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
*** 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)