diff options
author | Ondřej Surý <ondrej@sury.org> | 2012-02-01 21:25:15 +0100 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2012-02-01 21:25:15 +0100 |
commit | 96fb2ff5760132a915766f1d9ec7c63001feacd8 (patch) | |
tree | 160904a89a8f3522fa4e47632db101b045e7814a /ext/session | |
parent | 8f1428d29ef91d74b4d272af171675f2971eb15b (diff) | |
download | php-96fb2ff5760132a915766f1d9ec7c63001feacd8.tar.gz |
Imported Upstream version 5.4.0~rc6upstream/5.4.0_rc6
Diffstat (limited to 'ext/session')
76 files changed, 3428 insertions, 2293 deletions
diff --git a/ext/session/config.m4 b/ext/session/config.m4 index 8e2cba26d..580a6df10 100644 --- a/ext/session/config.m4 +++ b/ext/session/config.m4 @@ -1,5 +1,5 @@ dnl -dnl $Id: config.m4 305038 2010-11-02 20:51:02Z felipe $ +dnl $Id: config.m4 316688 2011-09-13 22:28:15Z arpad $ dnl PHP_ARG_ENABLE(session, whether to enable PHP sessions, @@ -11,7 +11,7 @@ PHP_ARG_WITH(mm,for mm support, if test "$PHP_SESSION" != "no"; then PHP_PWRITE_TEST PHP_PREAD_TEST - PHP_NEW_EXTENSION(session, session.c mod_files.c mod_mm.c mod_user.c, $ext_shared) + PHP_NEW_EXTENSION(session, mod_user_class.c session.c mod_files.c mod_mm.c mod_user.c, $ext_shared) PHP_ADD_EXTENSION_DEP(session, hash, true) PHP_ADD_EXTENSION_DEP(session, spl) PHP_SUBST(SESSION_SHARED_LIBADD) diff --git a/ext/session/config.w32 b/ext/session/config.w32 index 5c65651d9..1f87442b2 100644 --- a/ext/session/config.w32 +++ b/ext/session/config.w32 @@ -1,10 +1,10 @@ -// $Id: config.w32 312200 2011-06-16 01:21:01Z pajoye $ +// $Id: config.w32 316688 2011-09-13 22:28:15Z arpad $ // vim:ft=javascript ARG_ENABLE("session", "session support", "yes"); if (PHP_SESSION == "yes") { - EXTENSION("session", "session.c mod_files.c mod_mm.c mod_user.c", false /* never shared */); + EXTENSION("session", "mod_user_class.c session.c mod_files.c mod_mm.c mod_user.c", false /* never shared */); AC_DEFINE("HAVE_PHP_SESSION", 1, "Session support"); PHP_INSTALL_HEADERS("ext/session/", "mod_mm.h php_session.h mod_files.h mod_user.h"); } diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c index a7aac29d2..df1c22fe0 100644 --- a/ext/session/mod_files.c +++ b/ext/session/mod_files.c @@ -171,20 +171,14 @@ static void ps_files_open(ps_files *data, const char *key TSRMLS_DC) if (data->fd != -1) { #ifndef PHP_WIN32 /* check to make sure that the opened file is not a symlink, linking to data outside of allowable dirs */ - if (PG(safe_mode) || PG(open_basedir)) { + if (PG(open_basedir)) { struct stat sbuf; if (fstat(data->fd, &sbuf)) { close(data->fd); return; } - if ( - S_ISLNK(sbuf.st_mode) && - ( - php_check_open_basedir(buf TSRMLS_CC) || - (PG(safe_mode) && !php_checkuid(buf, NULL, CHECKUID_CHECK_FILE_AND_DIR)) - ) - ) { + if (S_ISLNK(sbuf.st_mode) && php_check_open_basedir(buf TSRMLS_CC)) { close(data->fd); return; } @@ -274,9 +268,6 @@ PS_OPEN_FUNC(files) /* if save path is an empty string, determine the temporary dir */ save_path = php_get_temporary_directory(); - if (PG(safe_mode) && (!php_checkuid(save_path, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { - return FAILURE; - } if (php_check_open_basedir(save_path TSRMLS_CC)) { return FAILURE; } @@ -320,6 +311,9 @@ PS_OPEN_FUNC(files) data->basedir_len = strlen(save_path); data->basedir = estrndup(save_path, data->basedir_len); + if (PS_GET_MOD_DATA()) { + ps_close_files(mod_data TSRMLS_CC); + } PS_SET_MOD_DATA(data); return SUCCESS; @@ -399,7 +393,7 @@ PS_WRITE_FUNC(files) /* Truncate file if the amount of new data is smaller than the existing data set. */ if (vallen < (int)data->st_size) { - ftruncate(data->fd, 0); + php_ignore_value(ftruncate(data->fd, 0)); } #if defined(HAVE_PWRITE) diff --git a/ext/session/mod_user.c b/ext/session/mod_user.c index 8a6ff8609..476e9f656 100644 --- a/ext/session/mod_user.c +++ b/ext/session/mod_user.c @@ -62,15 +62,10 @@ static zval *ps_call_handler(zval *func, int argc, zval **argv TSRMLS_DC) return retval; } -#define STDVARS1 \ +#define STDVARS \ zval *retval; \ int ret = FAILURE -#define STDVARS \ - STDVARS1; \ - char *mdata = PS_GET_MOD_DATA(); \ - if (!mdata) { return FAILURE; } - #define PSF(a) PS(mod_user_names).name.ps_##a #define FINISH \ @@ -84,32 +79,28 @@ static zval *ps_call_handler(zval *func, int argc, zval **argv TSRMLS_DC) PS_OPEN_FUNC(user) { zval *args[2]; - static char dummy = 0; - STDVARS1; + STDVARS; SESS_ZVAL_STRING((char*)save_path, args[0]); SESS_ZVAL_STRING((char*)session_name, args[1]); retval = ps_call_handler(PSF(open), 2, args TSRMLS_CC); - if (retval) { - /* This is necessary to fool the session module. Yes, it's safe to - * use a static. Neither mod_user nor the session module itself will - * ever touch this pointer. It could be set to 0xDEADBEEF for all the - * difference it makes, but for the sake of paranoia it's set to some - * valid value. */ - PS_SET_MOD_DATA(&dummy); - } + PS(mod_user_implemented) = 1; FINISH; } PS_CLOSE_FUNC(user) { - STDVARS1; + STDVARS; - retval = ps_call_handler(PSF(close), 0, NULL TSRMLS_CC); + if (!PS(mod_user_implemented)) { + /* already closed */ + return SUCCESS; + } - PS_SET_MOD_DATA(NULL); + retval = ps_call_handler(PSF(close), 0, NULL TSRMLS_CC); + PS(mod_user_implemented) = 0; FINISH; } diff --git a/ext/session/mod_user_class.c b/ext/session/mod_user_class.c new file mode 100644 index 000000000..70d2f40df --- /dev/null +++ b/ext/session/mod_user_class.c @@ -0,0 +1,144 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2012 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: Arpad Ray <arpad@php.net> | + +----------------------------------------------------------------------+ + */ + +/* $Id$ */ + +#include "php.h" +#include "php_session.h" + +#define PS_SANITY_CHECK \ + if (PS(default_mod) == NULL) { \ + php_error_docref(NULL TSRMLS_CC, E_CORE_ERROR, "Cannot call default session handler"); \ + RETURN_FALSE; \ + } + +#define PS_SANITY_CHECK_IS_OPEN \ + PS_SANITY_CHECK; \ + if (!PS(mod_user_is_open)) { \ + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Parent session handler is not open"); \ + RETURN_FALSE; \ + } + +/* {{{ proto bool SessionHandler::open(string save_path, string session_name) + Wraps the old open handler */ +PHP_METHOD(SessionHandler, open) +{ + char *save_path = NULL, *session_name = NULL; + int save_path_len, session_name_len; + + PS_SANITY_CHECK; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &save_path, &save_path_len, &session_name, &session_name_len) == FAILURE) { + return; + } + + PS(mod_user_is_open) = 1; + RETVAL_BOOL(SUCCESS == PS(default_mod)->s_open(&PS(mod_data), save_path, session_name TSRMLS_CC)); +} +/* }}} */ + +/* {{{ proto bool SessionHandler::close() + Wraps the old close handler */ +PHP_METHOD(SessionHandler, close) +{ + PS_SANITY_CHECK_IS_OPEN; + + // don't return on failure, since not closing the default handler + // could result in memory leaks or other nasties + zend_parse_parameters_none(); + + PS(mod_user_is_open) = 0; + RETVAL_BOOL(SUCCESS == PS(default_mod)->s_close(&PS(mod_data) TSRMLS_CC)); +} +/* }}} */ + +/* {{{ proto bool SessionHandler::read(string id) + Wraps the old read handler */ +PHP_METHOD(SessionHandler, read) +{ + char *key, *val; + int key_len, val_len; + + PS_SANITY_CHECK_IS_OPEN; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { + return; + } + + if (PS(default_mod)->s_read(&PS(mod_data), key, &val, &val_len TSRMLS_CC) == FAILURE) { + RETVAL_FALSE; + return; + } + + RETVAL_STRINGL(val, val_len, 1); + efree(val); + return; +} +/* }}} */ + +/* {{{ proto bool SessionHandler::write(string id, string data) + Wraps the old write handler */ +PHP_METHOD(SessionHandler, write) +{ + char *key, *val; + int key_len, val_len; + + PS_SANITY_CHECK_IS_OPEN; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &key, &key_len, &val, &val_len) == FAILURE) { + return; + } + + RETVAL_BOOL(SUCCESS == PS(default_mod)->s_write(&PS(mod_data), key, val, val_len TSRMLS_CC)); +} +/* }}} */ + +/* {{{ proto bool SessionHandler::destroy(string id) + Wraps the old destroy handler */ +PHP_METHOD(SessionHandler, destroy) +{ + char *key; + int key_len; + + PS_SANITY_CHECK_IS_OPEN; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) { + return; + } + + PS(mod_user_is_open) = 0; + RETVAL_BOOL(SUCCESS == PS(default_mod)->s_destroy(&PS(mod_data), key TSRMLS_CC)); +} +/* }}} */ + +/* {{{ proto bool SessionHandler::gc(int maxlifetime) + Wraps the old gc handler */ +PHP_METHOD(SessionHandler, gc) +{ + long maxlifetime; + int nrdels; + + PS_SANITY_CHECK_IS_OPEN; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &maxlifetime) == FAILURE) { + return; + } + + RETVAL_BOOL(SUCCESS == PS(default_mod)->s_gc(&PS(mod_data), maxlifetime, &nrdels TSRMLS_CC)); +} +/* }}} */ diff --git a/ext/session/package.xml b/ext/session/package.xml index fdf85fc44..03fcbf66d 100644 --- a/ext/session/package.xml +++ b/ext/session/package.xml @@ -40,6 +40,7 @@ package.xml added to support installation using pear installer <file role="src" name="mod_mm.c"/> <file role="src" name="mod_mm.h"/> <file role="src" name="mod_user.c"/> + <file role="src" name="mod_user_class.c"/> <file role="src" name="mod_user.h"/> <file role="src" name="php_session.h"/> <file role="src" name="session.c"/> diff --git a/ext/session/php_session.h b/ext/session/php_session.h index 07cb89dc5..223d7d65f 100644 --- a/ext/session/php_session.h +++ b/ext/session/php_session.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_session.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id: php_session.h 321738 2012-01-04 01:16:45Z arpad $ */ #ifndef PHP_SESSION_H #define PHP_SESSION_H @@ -95,6 +95,26 @@ typedef enum { php_session_active } php_session_status; +typedef struct _php_session_rfc1867_progress { + + size_t sname_len; + zval sid; + smart_str key; + + long update_step; + long next_update; + double next_update_time; + zend_bool cancel_upload; + zend_bool apply_trans_sid; + size_t content_length; + + zval *data; /* the array exported to session data */ + zval *post_bytes_processed; /* data["bytes_processed"] */ + zval *files; /* data["files"] array */ + zval *current_file; /* array of currently uploading file */ + zval *current_file_bytes_processed; +} php_session_rfc1867_progress; + typedef struct _php_ps_globals { char *save_path; char *session_name; @@ -109,6 +129,7 @@ typedef struct _php_ps_globals { zend_bool cookie_secure; zend_bool cookie_httponly; ps_module *mod; + ps_module *default_mod; void *mod_data; php_session_status session_status; long gc_probability; @@ -127,8 +148,8 @@ typedef struct _php_ps_globals { zval *ps_gc; } name; } mod_user_names; - zend_bool bug_compat; /* Whether to behave like PHP 4.2 and earlier */ - zend_bool bug_compat_warn; /* Whether to warn about it */ + int mod_user_implemented; + int mod_user_is_open; const struct ps_serializer_struct *serializer; zval *http_session_vars; zend_bool auto_start; @@ -145,6 +166,14 @@ typedef struct _php_ps_globals { int send_cookie; int define_sid; zend_bool invalid_session_id; /* allows the driver to report about an invalid session id and request id regeneration */ + + php_session_rfc1867_progress *rfc1867_progress; + zend_bool rfc1867_enabled; /* session.upload_progress.enabled */ + zend_bool rfc1867_cleanup; /* session.upload_progress.cleanup */ + smart_str rfc1867_prefix; /* session.upload_progress.prefix */ + smart_str rfc1867_name; /* session.upload_progress.name */ + long rfc1867_freq; /* session.upload_progress.freq */ + double rfc1867_min_freq; /* session.upload_progress.min_freq */ } php_ps_globals; typedef php_ps_globals zend_ps_globals; @@ -242,4 +271,17 @@ PHPAPI ZEND_EXTERN_MODULE_GLOBALS(ps) void php_session_auto_start(void *data); void php_session_shutdown(void *data); +#define PS_CLASS_NAME "SessionHandler" +extern zend_class_entry *php_session_class_entry; + +#define PS_IFACE_NAME "SessionHandlerInterface" +extern zend_class_entry *php_session_iface_entry; + +extern PHP_METHOD(SessionHandler, open); +extern PHP_METHOD(SessionHandler, close); +extern PHP_METHOD(SessionHandler, read); +extern PHP_METHOD(SessionHandler, write); +extern PHP_METHOD(SessionHandler, destroy); +extern PHP_METHOD(SessionHandler, gc); + #endif diff --git a/ext/session/session.c b/ext/session/session.c index 19fa3cc38..b9a1ac6ed 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: session.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id: session.c 321738 2012-01-04 01:16:45Z arpad $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -29,7 +29,7 @@ # include "win32/winutil.h" # include "win32/time.h" #else -#include <sys/time.h> +# include <sys/time.h> #endif #include <sys/stat.h> @@ -37,6 +37,8 @@ #include "php_ini.h" #include "SAPI.h" +#include "rfc1867.h" +#include "php_variables.h" #include "php_session.h" #include "ext/standard/md5.h" #include "ext/standard/sha1.h" @@ -48,6 +50,7 @@ #include "ext/standard/info.h" #include "ext/standard/php_smart_str.h" #include "ext/standard/url.h" +#include "ext/standard/basic_functions.h" #include "mod_files.h" #include "mod_user.h" @@ -58,6 +61,15 @@ PHPAPI ZEND_DECLARE_MODULE_GLOBALS(ps); +static int php_session_rfc1867_callback(unsigned int event, void *event_data, void **extra TSRMLS_DC); +static int (*php_session_rfc1867_orig_callback)(unsigned int event, void *event_data, void **extra TSRMLS_DC); + +/* SessionHandler class */ +zend_class_entry *php_session_class_entry; + +/* SessionHandlerInterface */ +zend_class_entry *php_session_iface_entry; + /* *********** * Helpers * *********** */ @@ -77,6 +89,7 @@ static inline void php_rinit_session_globals(TSRMLS_D) /* {{{ */ PS(id) = NULL; PS(session_status) = php_session_none; PS(mod_data) = NULL; + PS(mod_user_is_open) = 0; /* Do NOT init PS(mod_user_names) here! */ PS(http_session_vars) = NULL; } @@ -90,7 +103,7 @@ static inline void php_rshutdown_session_globals(TSRMLS_D) /* {{{ */ PS(http_session_vars) = NULL; } /* Do NOT destroy PS(mod_user_names) here! */ - if (PS(mod_data)) { + if (PS(mod_data) || PS(mod_user_implemented)) { zend_try { PS(mod)->s_close(&PS(mod_data) TSRMLS_CC); } zend_end_try(); @@ -132,76 +145,18 @@ PHPAPI void php_add_session_var(char *name, size_t namelen TSRMLS_DC) /* {{{ */ return; } - /* Set up a proper reference between $_SESSION["x"] and $x. */ - - if (PG(register_globals)) { - zval **sym_global = NULL; - - if (zend_hash_find(&EG(symbol_table), name, namelen + 1, (void *) &sym_global) == SUCCESS) { - if ((Z_TYPE_PP(sym_global) == IS_ARRAY && Z_ARRVAL_PP(sym_global) == &EG(symbol_table)) || *sym_global == PS(http_session_vars)) { - return; - } - } + if (sym_track == NULL) { + zval *empty_var; - if (sym_global == NULL && sym_track == NULL) { - zval *empty_var; - - ALLOC_INIT_ZVAL(empty_var); /* this sets refcount to 1 */ - Z_SET_REFCOUNT_P(empty_var, 0); /* our module does not maintain a ref */ - /* The next call will increase refcount by NR_OF_SYM_TABLES==2 */ - zend_set_hash_symbol(empty_var, name, namelen, 1, 2, Z_ARRVAL_P(PS(http_session_vars)), &EG(symbol_table)); - } else if (sym_global == NULL) { - SEPARATE_ZVAL_IF_NOT_REF(sym_track); - zend_set_hash_symbol(*sym_track, name, namelen, 1, 1, &EG(symbol_table)); - } else if (sym_track == NULL) { - SEPARATE_ZVAL_IF_NOT_REF(sym_global); - zend_set_hash_symbol(*sym_global, name, namelen, 1, 1, Z_ARRVAL_P(PS(http_session_vars))); - } - } else { - if (sym_track == NULL) { - zval *empty_var; - - ALLOC_INIT_ZVAL(empty_var); - ZEND_SET_SYMBOL_WITH_LENGTH(Z_ARRVAL_P(PS(http_session_vars)), name, namelen+1, empty_var, 1, 0); - } + ALLOC_INIT_ZVAL(empty_var); + ZEND_SET_SYMBOL_WITH_LENGTH(Z_ARRVAL_P(PS(http_session_vars)), name, namelen+1, empty_var, 1, 0); } } /* }}} */ PHPAPI void php_set_session_var(char *name, size_t namelen, zval *state_val, php_unserialize_data_t *var_hash TSRMLS_DC) /* {{{ */ { - if (PG(register_globals)) { - zval **old_symbol; - if (zend_hash_find(&EG(symbol_table),name,namelen+1,(void *)&old_symbol) == SUCCESS) { - if ((Z_TYPE_PP(old_symbol) == IS_ARRAY && Z_ARRVAL_PP(old_symbol) == &EG(symbol_table)) || *old_symbol == PS(http_session_vars)) { - return; - } - - /* A global symbol with the same name exists already. That - * symbol might have been created by other means (e.g. $_GET). - * - * hash_update in zend_set_hash_symbol is not good, because - * it will leave referenced variables (such as local instances - * of a global variable) dangling. - * - * BTW: if you use register_globals references between - * session-vars won't work because of this very reason! */ - - REPLACE_ZVAL_VALUE(old_symbol,state_val,1); - - /* The following line will update the reference table used for - * unserialization. It is optional, because some storage - * formats may not be able to represent references. */ - - if (var_hash) { - PHP_VAR_UNSERIALIZE_ZVAL_CHANGED(var_hash,state_val,*old_symbol); - } - - zend_set_hash_symbol(*old_symbol, name, namelen, 1, 1, Z_ARRVAL_P(PS(http_session_vars))); - } else { - zend_set_hash_symbol(state_val, name, namelen, 1, 2, Z_ARRVAL_P(PS(http_session_vars)), &EG(symbol_table)); - } - } else IF_SESSION_VARS() { + IF_SESSION_VARS() { zend_set_hash_symbol(state_val, name, namelen, PZVAL_IS_REF(state_val), 1, Z_ARRVAL_P(PS(http_session_vars))); } } @@ -213,20 +168,6 @@ PHPAPI int php_get_session_var(char *name, size_t namelen, zval ***state_var TSR IF_SESSION_VARS() { ret = zend_hash_find(Z_ARRVAL_P(PS(http_session_vars)), name, namelen + 1, (void **) state_var); - - /* If register_globals is enabled, and - * if there is an entry for the slot in $_SESSION, and - * if that entry is still set to NULL, and - * if the global var exists, then - * we prefer the same key in the global sym table. */ - - if (PG(register_globals) && ret == SUCCESS && Z_TYPE_PP(*state_var) == IS_NULL) { - zval **tmp; - - if (zend_hash_find(&EG(symbol_table), name, namelen + 1, (void **) &tmp) == SUCCESS) { - *state_var = tmp; - } - } } return ret; } @@ -236,8 +177,7 @@ static void php_session_track_init(TSRMLS_D) /* {{{ */ { zval *session_vars = NULL; - /* Unconditionally destroy existing arrays -- possible dirty data */ - zend_delete_global_variable("HTTP_SESSION_VARS", sizeof("HTTP_SESSION_VARS")-1 TSRMLS_CC); + /* Unconditionally destroy existing array -- possible dirty data */ zend_delete_global_variable("_SESSION", sizeof("_SESSION")-1 TSRMLS_CC); if (PS(http_session_vars)) { @@ -248,13 +188,7 @@ static void php_session_track_init(TSRMLS_D) /* {{{ */ array_init(session_vars); PS(http_session_vars) = session_vars; - if (PG(register_long_arrays)) { - ZEND_SET_GLOBAL_VAR_WITH_LENGTH("HTTP_SESSION_VARS", sizeof("HTTP_SESSION_VARS"), PS(http_session_vars), 3, 1); - ZEND_SET_GLOBAL_VAR_WITH_LENGTH("_SESSION", sizeof("_SESSION"), PS(http_session_vars), 3, 1); - } - else { - ZEND_SET_GLOBAL_VAR_WITH_LENGTH("_SESSION", sizeof("_SESSION"), PS(http_session_vars), 2, 1); - } + ZEND_SET_GLOBAL_VAR_WITH_LENGTH("_SESSION", sizeof("_SESSION"), PS(http_session_vars), 2, 1); } /* }}} */ @@ -541,64 +475,12 @@ new_session: } /* }}} */ -static int migrate_global(HashTable *ht, HashPosition *pos TSRMLS_DC) /* {{{ */ -{ - char *str; - uint str_len; - ulong num_key; - int n; - zval **val; - int ret = 0; - - n = zend_hash_get_current_key_ex(ht, &str, &str_len, &num_key, 0, pos); - - switch (n) { - case HASH_KEY_IS_STRING: - if (zend_hash_find(&EG(symbol_table), str, str_len, (void **) &val) == SUCCESS && - val && Z_TYPE_PP(val) != IS_NULL - ) { - ZEND_SET_SYMBOL_WITH_LENGTH(ht, str, str_len, *val, Z_REFCOUNT_PP(val) + 1, 1); - ret = 1; - } - break; - case HASH_KEY_IS_LONG: - php_error_docref(NULL TSRMLS_CC, E_NOTICE, "The session bug compatibility code will not " - "try to locate the global variable $%lu due to its " - "numeric nature", num_key); - break; - } - return ret; -} -/* }}} */ - static void php_session_save_current_state(TSRMLS_D) /* {{{ */ { int ret = FAILURE; IF_SESSION_VARS() { - if (PS(bug_compat) && !PG(register_globals)) { - HashTable *ht = Z_ARRVAL_P(PS(http_session_vars)); - HashPosition pos; - zval **val; - int do_warn = 0; - - zend_hash_internal_pointer_reset_ex(ht, &pos); - - while (zend_hash_get_current_data_ex(ht, (void **) &val, &pos) != FAILURE) { - if (Z_TYPE_PP(val) == IS_NULL) { - if (migrate_global(ht, &pos TSRMLS_CC)) { - do_warn = 1; - } - } - zend_hash_move_forward_ex(ht, &pos); - } - - if (do_warn && PS(bug_compat_warn)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively"); - } - } - - if (PS(mod_data)) { + if (PS(mod_data) || PS(mod_user_implemented)) { char *val; int vallen; @@ -620,7 +502,7 @@ static void php_session_save_current_state(TSRMLS_D) /* {{{ */ } } - if (PS(mod_data)) { + if (PS(mod_data) || PS(mod_user_implemented)) { PS(mod)->s_close(&PS(mod_data) TSRMLS_CC); } } @@ -652,6 +534,8 @@ static PHP_INI_MH(OnUpdateSaveHandler) /* {{{ */ } return FAILURE; } + + PS(default_mod) = PS(mod); PS(mod) = tmp; return SUCCESS; @@ -721,10 +605,6 @@ static PHP_INI_MH(OnUpdateSaveDir) /* {{{ */ p = new_value; } - if (PG(safe_mode) && *p && (!php_checkuid(p, NULL, CHECKUID_CHECK_FILE_AND_DIR))) { - return FAILURE; - } - if (PG(open_basedir) && *p && php_check_open_basedir(p TSRMLS_CC)) { return FAILURE; } @@ -783,11 +663,48 @@ static PHP_INI_MH(OnUpdateHashFunc) /* {{{ */ } /* }}} */ +static PHP_INI_MH(OnUpdateRfc1867Freq) /* {{{ */ +{ + int tmp; + tmp = zend_atoi(new_value, new_value_length); + if(tmp < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "session.upload_progress.freq must be greater than or equal to zero"); + return FAILURE; + } + if(new_value_length > 0 && new_value[new_value_length-1] == '%') { + if(tmp > 100) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "session.upload_progress.freq cannot be over 100%%"); + return FAILURE; + } + PS(rfc1867_freq) = -tmp; + } else { + PS(rfc1867_freq) = tmp; + } + return SUCCESS; +} /* }}} */ + +static ZEND_INI_MH(OnUpdateSmartStr) /* {{{ */ +{ + smart_str *p; +#ifndef ZTS + char *base = (char *) mh_arg2; +#else + char *base; + + base = (char *) ts_resource(*((int *) mh_arg2)); +#endif + + p = (smart_str *) (base+(size_t) mh_arg1); + + smart_str_sets(p, new_value); + + return SUCCESS; +} +/* }}} */ + /* {{{ PHP_INI */ PHP_INI_BEGIN() - STD_PHP_INI_BOOLEAN("session.bug_compat_42", "1", PHP_INI_ALL, OnUpdateBool, bug_compat, php_ps_globals, ps_globals) - STD_PHP_INI_BOOLEAN("session.bug_compat_warn", "1", PHP_INI_ALL, OnUpdateBool, bug_compat_warn, php_ps_globals, ps_globals) STD_PHP_INI_ENTRY("session.save_path", "", PHP_INI_ALL, OnUpdateSaveDir,save_path, php_ps_globals, ps_globals) STD_PHP_INI_ENTRY("session.name", "PHPSESSID", PHP_INI_ALL, OnUpdateString, session_name, php_ps_globals, ps_globals) PHP_INI_ENTRY("session.save_handler", "files", PHP_INI_ALL, OnUpdateSaveHandler) @@ -804,14 +721,35 @@ PHP_INI_BEGIN() STD_PHP_INI_BOOLEAN("session.use_cookies", "1", PHP_INI_ALL, OnUpdateBool, use_cookies, php_ps_globals, ps_globals) STD_PHP_INI_BOOLEAN("session.use_only_cookies", "1", PHP_INI_ALL, OnUpdateBool, use_only_cookies, php_ps_globals, ps_globals) STD_PHP_INI_ENTRY("session.referer_check", "", PHP_INI_ALL, OnUpdateString, extern_referer_chk, php_ps_globals, ps_globals) +#if HAVE_DEV_URANDOM + STD_PHP_INI_ENTRY("session.entropy_file", "/dev/urandom", PHP_INI_ALL, OnUpdateString, entropy_file, php_ps_globals, ps_globals) + STD_PHP_INI_ENTRY("session.entropy_length", "32", PHP_INI_ALL, OnUpdateLong, entropy_length, php_ps_globals, ps_globals) +#elif HAVE_DEV_ARANDOM + STD_PHP_INI_ENTRY("session.entropy_file", "/dev/arandom", PHP_INI_ALL, OnUpdateString, entropy_file, php_ps_globals, ps_globals) + STD_PHP_INI_ENTRY("session.entropy_length", "32", PHP_INI_ALL, OnUpdateLong, entropy_length, php_ps_globals, ps_globals) +#else STD_PHP_INI_ENTRY("session.entropy_file", "", PHP_INI_ALL, OnUpdateString, entropy_file, php_ps_globals, ps_globals) STD_PHP_INI_ENTRY("session.entropy_length", "0", PHP_INI_ALL, OnUpdateLong, entropy_length, php_ps_globals, ps_globals) +#endif STD_PHP_INI_ENTRY("session.cache_limiter", "nocache", PHP_INI_ALL, OnUpdateString, cache_limiter, php_ps_globals, ps_globals) STD_PHP_INI_ENTRY("session.cache_expire", "180", PHP_INI_ALL, OnUpdateLong, cache_expire, php_ps_globals, ps_globals) PHP_INI_ENTRY("session.use_trans_sid", "0", PHP_INI_ALL, OnUpdateTransSid) PHP_INI_ENTRY("session.hash_function", "0", PHP_INI_ALL, OnUpdateHashFunc) STD_PHP_INI_ENTRY("session.hash_bits_per_character", "4", PHP_INI_ALL, OnUpdateLong, hash_bits_per_character, php_ps_globals, ps_globals) + /* Upload progress */ + STD_PHP_INI_BOOLEAN("session.upload_progress.enabled", + "1", ZEND_INI_PERDIR, OnUpdateBool, rfc1867_enabled, php_ps_globals, ps_globals) + STD_PHP_INI_BOOLEAN("session.upload_progress.cleanup", + "1", ZEND_INI_PERDIR, OnUpdateBool, rfc1867_cleanup, php_ps_globals, ps_globals) + STD_PHP_INI_ENTRY("session.upload_progress.prefix", + "upload_progress_", ZEND_INI_PERDIR, OnUpdateSmartStr, rfc1867_prefix, php_ps_globals, ps_globals) + STD_PHP_INI_ENTRY("session.upload_progress.name", + "PHP_SESSION_UPLOAD_PROGRESS", ZEND_INI_PERDIR, OnUpdateSmartStr, rfc1867_name, php_ps_globals, ps_globals) + STD_PHP_INI_ENTRY("session.upload_progress.freq", "1%", ZEND_INI_PERDIR, OnUpdateRfc1867Freq, rfc1867_freq, php_ps_globals, ps_globals) + STD_PHP_INI_ENTRY("session.upload_progress.min_freq", + "1", ZEND_INI_PERDIR, OnUpdateReal, rfc1867_min_freq,php_ps_globals, ps_globals) + /* Commented out until future discussion */ /* PHP_INI_ENTRY("session.encode_sources", "globals,track", PHP_INI_ALL, NULL) */ PHP_INI_END() @@ -1188,8 +1126,8 @@ static int php_session_cache_limiter(TSRMLS_D) /* {{{ */ if (PS(cache_limiter)[0] == '\0') return 0; if (SG(headers_sent)) { - char *output_start_filename = php_get_output_start_filename(TSRMLS_C); - int output_start_lineno = php_get_output_start_lineno(TSRMLS_C); + const char *output_start_filename = php_output_get_start_filename(TSRMLS_C); + int output_start_lineno = php_output_get_start_lineno(TSRMLS_C); if (output_start_filename) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot send session cache limiter - headers already sent (output started at %s:%d)", output_start_filename, output_start_lineno); @@ -1228,8 +1166,8 @@ static void php_session_send_cookie(TSRMLS_D) /* {{{ */ char *e_session_name, *e_id; if (SG(headers_sent)) { - char *output_start_filename = php_get_output_start_filename(TSRMLS_C); - int output_start_lineno = php_get_output_start_lineno(TSRMLS_C); + const char *output_start_filename = php_output_get_start_filename(TSRMLS_C); + int output_start_lineno = php_output_get_start_lineno(TSRMLS_C); if (output_start_filename) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot send session cookie - headers already sent by (output started at %s:%d)", output_start_filename, output_start_lineno); @@ -1492,7 +1430,7 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */ php_session_cache_limiter(TSRMLS_C); - if (PS(mod_data) && PS(gc_probability) > 0) { + if ((PS(mod_data) || PS(mod_user_implemented)) && PS(gc_probability) > 0) { int nrdels = -1; nrand = (int) ((float) PS(gc_divisor) * php_combined_lcg(TSRMLS_C)); @@ -1627,7 +1565,7 @@ static PHP_FUNCTION(session_module_name) zval_dtor(return_value); RETURN_FALSE; } - if (PS(mod_data)) { + if (PS(mod_data) || PS(mod_user_implemented)) { PS(mod)->s_close(&PS(mod_data) TSRMLS_CC); } PS(mod_data) = NULL; @@ -1649,14 +1587,85 @@ static PHP_FUNCTION(session_set_save_handler) RETURN_FALSE; } - if (argc != 6) { + if (argc != 1 && argc != 2 && argc != 6) { WRONG_PARAM_COUNT; } + if (argc <= 2) { + zval *obj = NULL, *callback = NULL; + zend_uint func_name_len; + char *func_name; + HashPosition pos; + zend_function *default_mptr, *current_mptr; + ulong func_index; + php_shutdown_function_entry shutdown_function_entry; + zend_bool register_shutdown = 1; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|b", &obj, php_session_iface_entry, ®ister_shutdown) == FAILURE) { + RETURN_FALSE; + } + + /* Find implemented methods */ + zend_hash_internal_pointer_reset_ex(&php_session_class_entry->function_table, &pos); + i = 0; + while (zend_hash_get_current_data_ex(&php_session_class_entry->function_table, (void **) &default_mptr, &pos) == SUCCESS) { + zend_hash_get_current_key_ex(&php_session_class_entry->function_table, &func_name, &func_name_len, &func_index, 0, &pos); + + if (zend_hash_find(&Z_OBJCE_P(obj)->function_table, func_name, func_name_len, (void **)¤t_mptr) == SUCCESS) { + if (PS(mod_user_names).names[i] != NULL) { + zval_ptr_dtor(&PS(mod_user_names).names[i]); + } + + MAKE_STD_ZVAL(callback); + array_init_size(callback, 2); + Z_ADDREF_P(obj); + add_next_index_zval(callback, obj); + add_next_index_stringl(callback, func_name, func_name_len - 1, 1); + PS(mod_user_names).names[i] = callback; + } else { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Session handler's function table is corrupt"); + RETURN_FALSE; + } + + zend_hash_move_forward_ex(&php_session_class_entry->function_table, &pos); + ++i; + } + + if (register_shutdown) { + /* create shutdown function */ + shutdown_function_entry.arg_count = 1; + shutdown_function_entry.arguments = (zval **) safe_emalloc(sizeof(zval *), 1, 0); + + MAKE_STD_ZVAL(callback); + ZVAL_STRING(callback, "session_register_shutdown", 1); + shutdown_function_entry.arguments[0] = callback; + + /* add shutdown function, removing the old one if it exists */ + if (!register_user_shutdown_function("session_shutdown", sizeof("session_shutdown"), &shutdown_function_entry TSRMLS_CC)) { + zval_ptr_dtor(&callback); + efree(shutdown_function_entry.arguments); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to register session shutdown function"); + RETURN_FALSE; + } + } else { + /* remove shutdown function */ + remove_user_shutdown_function("session_shutdown", sizeof("session_shutdown") TSRMLS_CC); + } + + if (PS(mod) && PS(session_status) == php_session_none && PS(mod) != &ps_mod_user) { + zend_alter_ini_entry("session.save_handler", sizeof("session.save_handler"), "user", sizeof("user")-1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); + } + + RETURN_TRUE; + } + if (zend_parse_parameters(argc TSRMLS_CC, "+", &args, &num_args) == FAILURE) { return; } + /* remove shutdown function */ + remove_user_shutdown_function("session_shutdown", sizeof("session_shutdown") TSRMLS_CC); + for (i = 0; i < 6; i++) { if (!zend_is_callable(*args[i], 0, &name TSRMLS_CC)) { efree(args); @@ -1666,8 +1675,10 @@ static PHP_FUNCTION(session_set_save_handler) } efree(name); } - - zend_alter_ini_entry("session.save_handler", sizeof("session.save_handler"), "user", sizeof("user")-1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); + + if (PS(mod) && PS(mod) != &ps_mod_user) { + zend_alter_ini_entry("session.save_handler", sizeof("session.save_handler"), "user", sizeof("user")-1, PHP_INI_USER, PHP_INI_STAGE_RUNTIME); + } for (i = 0; i < 6; i++) { if (PS(mod_user_names).names[i] != NULL) { @@ -1807,37 +1818,6 @@ static PHP_FUNCTION(session_cache_expire) } /* }}} */ -/* {{{ static void php_register_var(zval** entry TSRMLS_DC) */ -static void php_register_var(zval** entry TSRMLS_DC) -{ - zval **value; - - if (Z_TYPE_PP(entry) == IS_ARRAY) { - if (Z_ARRVAL_PP(entry)->nApplyCount > 1) { - return; - } - - zend_hash_internal_pointer_reset(Z_ARRVAL_PP(entry)); - Z_ARRVAL_PP(entry)->nApplyCount++; - - while (zend_hash_get_current_data(Z_ARRVAL_PP(entry), (void**)&value) == SUCCESS) { - php_register_var(value TSRMLS_CC); - zend_hash_move_forward(Z_ARRVAL_PP(entry)); - } - - Z_ARRVAL_PP(entry)->nApplyCount--; - } else { - convert_to_string_ex(entry); - - if ((strcmp(Z_STRVAL_PP(entry), "HTTP_SESSION_VARS") != 0) && - (strcmp(Z_STRVAL_PP(entry), "_SESSION") != 0) - ) { - PS_ADD_VARL(Z_STRVAL_PP(entry), Z_STRLEN_PP(entry)); - } - } -} -/* }}} */ - /* {{{ proto string session_encode(void) Serializes the current setup and returns the serialized representation */ static PHP_FUNCTION(session_encode) @@ -1919,20 +1899,6 @@ static PHP_FUNCTION(session_unset) SEPARATE_ZVAL_IF_NOT_REF(&PS(http_session_vars)); ht_sess_var = Z_ARRVAL_P(PS(http_session_vars)); - if (PG(register_globals)) { - uint str_len; - char *str; - ulong num_key; - HashPosition pos; - - zend_hash_internal_pointer_reset_ex(ht_sess_var, &pos); - - while (zend_hash_get_current_key_ex(ht_sess_var, &str, &str_len, &num_key, 0, &pos) == HASH_KEY_IS_STRING) { - zend_delete_global_variable(str, str_len - 1 TSRMLS_CC); - zend_hash_move_forward_ex(ht_sess_var, &pos); - } - } - /* Clean $_SESSION. */ zend_hash_clean(ht_sess_var); } @@ -1947,85 +1913,52 @@ static PHP_FUNCTION(session_write_close) } /* }}} */ -/* {{{ proto bool session_register(mixed var_names [, mixed ...]) - Adds varname(s) to the list of variables which are freezed at the session end */ -static PHP_FUNCTION(session_register) +/* {{{ proto int session_status(void) + Returns the current session status */ +static PHP_FUNCTION(session_status) { - zval ***args = NULL; - int num_args, i; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "+", &args, &num_args) == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) { return; } - if (PS(session_status) == php_session_none || PS(session_status) == php_session_disabled) { - php_session_start(TSRMLS_C); - } - - if (PS(session_status) == php_session_disabled) { - if (args) { - efree(args); - } - RETURN_FALSE; - } - - for (i = 0; i < num_args; i++) { - if (Z_TYPE_PP(args[i]) == IS_ARRAY) { - SEPARATE_ZVAL(args[i]); - } - php_register_var(args[i] TSRMLS_CC); - } - - if (args) { - efree(args); - } - - RETURN_TRUE; + RETURN_LONG(PS(session_status)); } /* }}} */ -/* {{{ proto bool session_unregister(string varname) - Removes varname from the list of variables which are freezed at the session end */ -static PHP_FUNCTION(session_unregister) +/* {{{ proto void session_register_shutdown(void) + Registers session_write_close() as a shutdown function */ +static PHP_FUNCTION(session_register_shutdown) { - char *p_name; - int p_name_len; + php_shutdown_function_entry shutdown_function_entry; + zval *callback; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &p_name, &p_name_len) == FAILURE) { - return; - } - - IF_SESSION_VARS() { - SEPARATE_ZVAL_IF_NOT_REF(&PS(http_session_vars)); - PS_DEL_VARL(p_name, p_name_len); - } - - RETURN_TRUE; -} -/* }}} */ + /* This function is registered itself as a shutdown function by + * session_set_save_handler($obj). The reason we now register another + * shutdown function is in case the user registered their own shutdown + * function after calling session_set_save_handler(), which expects + * the session still to be available. + */ -/* {{{ proto bool session_is_registered(string varname) - Checks if a variable is registered in session */ -static PHP_FUNCTION(session_is_registered) -{ - zval *p_var; - char *p_name; - int p_name_len; + shutdown_function_entry.arg_count = 1; + shutdown_function_entry.arguments = (zval **) safe_emalloc(sizeof(zval *), 1, 0); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &p_name, &p_name_len) == FAILURE) { - return; - } + MAKE_STD_ZVAL(callback); + ZVAL_STRING(callback, "session_write_close", 1); + shutdown_function_entry.arguments[0] = callback; - if (PS(session_status) == php_session_none) { - RETURN_FALSE; - } + if (!append_user_shutdown_function(shutdown_function_entry TSRMLS_CC)) { + zval_ptr_dtor(&callback); + efree(shutdown_function_entry.arguments); - IF_SESSION_VARS() { - if (zend_hash_find(Z_ARRVAL_P(PS(http_session_vars)), p_name, p_name_len+1, (void **)&p_var) == SUCCESS) { - RETURN_TRUE; - } + /* Unable to register shutdown function, presumably because of lack + * of memory, so flush the session now. It would be done in rshutdown + * anyway but the handler will have had it's dtor called by then. + * If the user does have a later shutdown function which needs the + * session then tough luck. + */ + php_session_flush(TSRMLS_C); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to register session flush function"); } - RETURN_FALSE; } /* }}} */ @@ -2054,19 +1987,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_session_decode, 0, 0, 1) ZEND_ARG_INFO(0, data) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_session_register, 0, 0, 1) - ZEND_ARG_INFO(0, name) - ZEND_ARG_INFO(0, ...) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_session_unregister, 0, 0, 1) - ZEND_ARG_INFO(0, name) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_session_is_registered, 0, 0, 1) - ZEND_ARG_INFO(0, name) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO(arginfo_session_void, 0) ZEND_END_ARG_INFO() @@ -2094,6 +2014,31 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_session_set_cookie_params, 0, 0, 1) ZEND_ARG_INFO(0, secure) ZEND_ARG_INFO(0, httponly) ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_session_class_open, 0) + ZEND_ARG_INFO(0, save_path) + ZEND_ARG_INFO(0, session_name) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_session_class_close, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_session_class_read, 0) + ZEND_ARG_INFO(0, key) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_session_class_write, 0) + ZEND_ARG_INFO(0, key) + ZEND_ARG_INFO(0, val) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_session_class_destroy, 0) + ZEND_ARG_INFO(0, key) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO(arginfo_session_class_gc, 0) + ZEND_ARG_INFO(0, maxlifetime) +ZEND_END_ARG_INFO() /* }}} */ /* {{{ session_functions[] @@ -2105,9 +2050,6 @@ static const zend_function_entry session_functions[] = { PHP_FE(session_id, arginfo_session_id) PHP_FE(session_regenerate_id, arginfo_session_regenerate_id) PHP_FE(session_decode, arginfo_session_decode) - PHP_DEP_FE(session_register, arginfo_session_register) - PHP_DEP_FE(session_unregister, arginfo_session_unregister) - PHP_DEP_FE(session_is_registered, arginfo_session_is_registered) PHP_FE(session_encode, arginfo_session_void) PHP_FE(session_start, arginfo_session_void) PHP_FE(session_destroy, arginfo_session_void) @@ -2118,16 +2060,44 @@ static const zend_function_entry session_functions[] = { PHP_FE(session_set_cookie_params, arginfo_session_set_cookie_params) PHP_FE(session_get_cookie_params, arginfo_session_void) PHP_FE(session_write_close, arginfo_session_void) + PHP_FE(session_status, arginfo_session_void) + PHP_FE(session_register_shutdown, arginfo_session_void) PHP_FALIAS(session_commit, session_write_close, arginfo_session_void) PHP_FE_END }; /* }}} */ +/* {{{ SessionHandlerInterface functions[] +*/ +static const zend_function_entry php_session_iface_functions[] = { + PHP_ABSTRACT_ME(SessionHandlerInterface, open, arginfo_session_class_open) + PHP_ABSTRACT_ME(SessionHandlerInterface, close, arginfo_session_class_close) + PHP_ABSTRACT_ME(SessionHandlerInterface, read, arginfo_session_class_read) + PHP_ABSTRACT_ME(SessionHandlerInterface, write, arginfo_session_class_write) + PHP_ABSTRACT_ME(SessionHandlerInterface, destroy, arginfo_session_class_destroy) + PHP_ABSTRACT_ME(SessionHandlerInterface, gc, arginfo_session_class_gc) + { NULL, NULL, NULL } +}; +/* }}} */ + +/* {{{ SessionHandler functions[] + */ +static const zend_function_entry php_session_class_functions[] = { + PHP_ME(SessionHandler, open, arginfo_session_class_open, ZEND_ACC_PUBLIC) + PHP_ME(SessionHandler, close, arginfo_session_class_close, ZEND_ACC_PUBLIC) + PHP_ME(SessionHandler, read, arginfo_session_class_read, ZEND_ACC_PUBLIC) + PHP_ME(SessionHandler, write, arginfo_session_class_write, ZEND_ACC_PUBLIC) + PHP_ME(SessionHandler, destroy, arginfo_session_class_destroy, ZEND_ACC_PUBLIC) + PHP_ME(SessionHandler, gc, arginfo_session_class_gc, ZEND_ACC_PUBLIC) + { NULL, NULL, NULL } +}; +/* }}} */ + /* ******************************** * Module Setup and Destruction * ******************************** */ -static PHP_RINIT_FUNCTION(session) /* {{{ */ +static int php_rinit_session(zend_bool auto_start TSRMLS_DC) /* {{{ */ { php_rinit_session_globals(TSRMLS_C); @@ -2155,11 +2125,16 @@ static PHP_RINIT_FUNCTION(session) /* {{{ */ return SUCCESS; } - if (PS(auto_start)) { + if (auto_start) { php_session_start(TSRMLS_C); } return SUCCESS; +} /* }}} */ + +static PHP_RINIT_FUNCTION(session) /* {{{ */ +{ + return php_rinit_session(PS(auto_start) TSRMLS_CC); } /* }}} */ @@ -2193,6 +2168,9 @@ static PHP_GINIT_FUNCTION(ps) /* {{{ */ ps_globals->serializer = NULL; ps_globals->mod_data = NULL; ps_globals->session_status = php_session_none; + ps_globals->default_mod = NULL; + ps_globals->mod_user_implemented = 0; + ps_globals->mod_user_is_open = 0; for (i = 0; i < 6; i++) { ps_globals->mod_user_names.names[i] = NULL; } @@ -2202,7 +2180,9 @@ static PHP_GINIT_FUNCTION(ps) /* {{{ */ static PHP_MINIT_FUNCTION(session) /* {{{ */ { - zend_register_auto_global("_SESSION", sizeof("_SESSION")-1, NULL TSRMLS_CC); + zend_class_entry ce; + + zend_register_auto_global("_SESSION", sizeof("_SESSION")-1, 0, NULL TSRMLS_CC); PS(module_number) = module_number; /* if we really need this var we need to init it in zts mode as well! */ @@ -2212,6 +2192,23 @@ static PHP_MINIT_FUNCTION(session) /* {{{ */ #ifdef HAVE_LIBMM PHP_MINIT(ps_mm) (INIT_FUNC_ARGS_PASSTHRU); #endif + php_session_rfc1867_orig_callback = php_rfc1867_callback; + php_rfc1867_callback = php_session_rfc1867_callback; + + /* Register interface */ + INIT_CLASS_ENTRY(ce, PS_IFACE_NAME, php_session_iface_functions); + php_session_iface_entry = zend_register_internal_class(&ce TSRMLS_CC); + php_session_iface_entry->ce_flags |= ZEND_ACC_INTERFACE; + + /* Register base class */ + INIT_CLASS_ENTRY(ce, PS_CLASS_NAME, php_session_class_functions); + php_session_class_entry = zend_register_internal_class(&ce TSRMLS_CC); + zend_class_implements(php_session_class_entry TSRMLS_CC, 1, php_session_iface_entry); + + REGISTER_LONG_CONSTANT("PHP_SESSION_DISABLED", php_session_disabled, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("PHP_SESSION_NONE", php_session_none, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("PHP_SESSION_ACTIVE", php_session_active, CONST_CS | CONST_PERSISTENT); + return SUCCESS; } /* }}} */ @@ -2287,6 +2284,286 @@ static const zend_module_dep session_deps[] = { /* {{{ */ }; /* }}} */ +/* ************************ + * Upload hook handling * + ************************ */ + +static zend_bool early_find_sid_in(zval *dest, int where, php_session_rfc1867_progress *progress TSRMLS_DC) /* {{{ */ +{ + zval **ppid; + + if (!PG(http_globals)[where]) { + return 0; + } + + if (zend_hash_find(Z_ARRVAL_P(PG(http_globals)[where]), PS(session_name), progress->sname_len+1, (void **)&ppid) == SUCCESS + && Z_TYPE_PP(ppid) == IS_STRING) { + zval_dtor(dest); + ZVAL_ZVAL(dest, *ppid, 1, 0); + return 1; + } + + return 0; +} /* }}} */ + +static void php_session_rfc1867_early_find_sid(php_session_rfc1867_progress *progress TSRMLS_DC) /* {{{ */ +{ + + if (PS(use_cookies)) { + sapi_module.treat_data(PARSE_COOKIE, NULL, NULL TSRMLS_CC); + if (early_find_sid_in(&progress->sid, TRACK_VARS_COOKIE, progress TSRMLS_CC)) { + progress->apply_trans_sid = 0; + return; + } + } + if (PS(use_only_cookies)) { + return; + } + sapi_module.treat_data(PARSE_GET, NULL, NULL TSRMLS_CC); + early_find_sid_in(&progress->sid, TRACK_VARS_GET, progress TSRMLS_CC); +} /* }}} */ + +static zend_bool php_check_cancel_upload(php_session_rfc1867_progress *progress TSRMLS_DC) /* {{{ */ +{ + zval **progress_ary, **cancel_upload; + + if (zend_symtable_find(Z_ARRVAL_P(PS(http_session_vars)), progress->key.c, progress->key.len+1, (void**)&progress_ary) != SUCCESS) { + return 0; + } + if (Z_TYPE_PP(progress_ary) != IS_ARRAY) { + return 0; + } + if (zend_hash_find(Z_ARRVAL_PP(progress_ary), "cancel_upload", sizeof("cancel_upload"), (void**)&cancel_upload) != SUCCESS) { + return 0; + } + return Z_TYPE_PP(cancel_upload) == IS_BOOL && Z_LVAL_PP(cancel_upload); +} /* }}} */ + +static void php_session_rfc1867_update(php_session_rfc1867_progress *progress, int force_update TSRMLS_DC) /* {{{ */ +{ + if (!force_update) { + if (Z_LVAL_P(progress->post_bytes_processed) < progress->next_update) { + return; + } +#ifdef HAVE_GETTIMEOFDAY + if (PS(rfc1867_min_freq) > 0.0) { + struct timeval tv = {0}; + double dtv; + gettimeofday(&tv, NULL); + dtv = (double) tv.tv_sec + tv.tv_usec / 1000000.0; + if (dtv < progress->next_update_time) { + return; + } + progress->next_update_time = dtv + PS(rfc1867_min_freq); + } +#endif + progress->next_update = Z_LVAL_P(progress->post_bytes_processed) + progress->update_step; + } + + php_session_initialize(TSRMLS_C); + PS(session_status) = php_session_active; + IF_SESSION_VARS() { + progress->cancel_upload = php_check_cancel_upload(progress TSRMLS_CC); + ZEND_SET_SYMBOL_WITH_LENGTH(Z_ARRVAL_P(PS(http_session_vars)), progress->key.c, progress->key.len+1, progress->data, 2, 0); + } + php_session_flush(TSRMLS_C); +} /* }}} */ + +static void php_session_rfc1867_cleanup(php_session_rfc1867_progress *progress TSRMLS_DC) /* {{{ */ +{ + php_session_initialize(TSRMLS_C); + PS(session_status) = php_session_active; + IF_SESSION_VARS() { + zend_hash_del(Z_ARRVAL_P(PS(http_session_vars)), progress->key.c, progress->key.len+1); + } + php_session_flush(TSRMLS_C); +} /* }}} */ + +static int php_session_rfc1867_callback(unsigned int event, void *event_data, void **extra TSRMLS_DC) /* {{{ */ +{ + php_session_rfc1867_progress *progress; + int retval = SUCCESS; + + if (php_session_rfc1867_orig_callback) { + retval = php_session_rfc1867_orig_callback(event, event_data, extra TSRMLS_CC); + } + if (!PS(rfc1867_enabled)) { + return retval; + } + + progress = PS(rfc1867_progress); + + switch(event) { + case MULTIPART_EVENT_START: { + multipart_event_start *data = (multipart_event_start *) event_data; + progress = ecalloc(1, sizeof(php_session_rfc1867_progress)); + progress->content_length = data->content_length; + progress->sname_len = strlen(PS(session_name)); + PS(rfc1867_progress) = progress; + } + break; + case MULTIPART_EVENT_FORMDATA: { + multipart_event_formdata *data = (multipart_event_formdata *) event_data; + size_t value_len; + + if (Z_TYPE(progress->sid) && progress->key.c) { + break; + } + + /* orig callback may have modified *data->newlength */ + if (data->newlength) { + value_len = *data->newlength; + } else { + value_len = data->length; + } + + if (data->name && data->value && value_len) { + size_t name_len = strlen(data->name); + + if (name_len == progress->sname_len && memcmp(data->name, PS(session_name), name_len) == 0) { + zval_dtor(&progress->sid); + ZVAL_STRINGL(&progress->sid, (*data->value), value_len, 1); + + } else if (name_len == PS(rfc1867_name).len && memcmp(data->name, PS(rfc1867_name).c, name_len) == 0) { + smart_str_free(&progress->key); + smart_str_appendl(&progress->key, PS(rfc1867_prefix).c, PS(rfc1867_prefix).len); + smart_str_appendl(&progress->key, *data->value, value_len); + smart_str_0(&progress->key); + + progress->apply_trans_sid = PS(use_trans_sid); + php_session_rfc1867_early_find_sid(progress TSRMLS_CC); + } + } + } + break; + case MULTIPART_EVENT_FILE_START: { + multipart_event_file_start *data = (multipart_event_file_start *) event_data; + + /* Do nothing when $_POST["PHP_SESSION_UPLOAD_PROGRESS"] is not set + * or when we have no session id */ + if (!Z_TYPE(progress->sid) || !progress->key.c) { + break; + } + + /* First FILE_START event, initializing data */ + if (!progress->data) { + + if (PS(rfc1867_freq) >= 0) { + progress->update_step = PS(rfc1867_freq); + } else if (PS(rfc1867_freq) < 0) { /* % of total size */ + progress->update_step = progress->content_length * -PS(rfc1867_freq) / 100; + } + progress->next_update = 0; + progress->next_update_time = 0.0; + + ALLOC_INIT_ZVAL(progress->data); + array_init(progress->data); + + ALLOC_INIT_ZVAL(progress->post_bytes_processed); + ZVAL_LONG(progress->post_bytes_processed, data->post_bytes_processed); + + ALLOC_INIT_ZVAL(progress->files); + array_init(progress->files); + + add_assoc_long_ex(progress->data, "start_time", sizeof("start_time"), (long)sapi_get_request_time(TSRMLS_C)); + add_assoc_long_ex(progress->data, "content_length", sizeof("content_length"), progress->content_length); + add_assoc_zval_ex(progress->data, "bytes_processed", sizeof("bytes_processed"), progress->post_bytes_processed); + add_assoc_bool_ex(progress->data, "done", sizeof("done"), 0); + add_assoc_zval_ex(progress->data, "files", sizeof("files"), progress->files); + + php_rinit_session(0 TSRMLS_CC); + PS(id) = estrndup(Z_STRVAL(progress->sid), Z_STRLEN(progress->sid)); + PS(apply_trans_sid) = progress->apply_trans_sid; + PS(send_cookie) = 0; + } + + ALLOC_INIT_ZVAL(progress->current_file); + array_init(progress->current_file); + + ALLOC_INIT_ZVAL(progress->current_file_bytes_processed); + ZVAL_LONG(progress->current_file_bytes_processed, 0); + + /* Each uploaded file has its own array. Trying to make it close to $_FILES entries. */ + add_assoc_string_ex(progress->current_file, "field_name", sizeof("field_name"), data->name, 1); + add_assoc_string_ex(progress->current_file, "name", sizeof("name"), *data->filename, 1); + add_assoc_null_ex(progress->current_file, "tmp_name", sizeof("tmp_name")); + add_assoc_long_ex(progress->current_file, "error", sizeof("error"), 0); + + add_assoc_bool_ex(progress->current_file, "done", sizeof("done"), 0); + add_assoc_long_ex(progress->current_file, "start_time", sizeof("start_time"), (long)time(NULL)); + add_assoc_zval_ex(progress->current_file, "bytes_processed", sizeof("bytes_processed"), progress->current_file_bytes_processed); + + add_next_index_zval(progress->files, progress->current_file); + + Z_LVAL_P(progress->post_bytes_processed) = data->post_bytes_processed; + + php_session_rfc1867_update(progress, 0 TSRMLS_CC); + } + break; + case MULTIPART_EVENT_FILE_DATA: { + multipart_event_file_data *data = (multipart_event_file_data *) event_data; + + if (!Z_TYPE(progress->sid) || !progress->key.c) { + break; + } + + Z_LVAL_P(progress->current_file_bytes_processed) = data->offset + data->length; + Z_LVAL_P(progress->post_bytes_processed) = data->post_bytes_processed; + + php_session_rfc1867_update(progress, 0 TSRMLS_CC); + } + break; + case MULTIPART_EVENT_FILE_END: { + multipart_event_file_end *data = (multipart_event_file_end *) event_data; + + if (!Z_TYPE(progress->sid) || !progress->key.c) { + break; + } + + if (data->temp_filename) { + add_assoc_string_ex(progress->current_file, "tmp_name", sizeof("tmp_name"), data->temp_filename, 1); + } + add_assoc_long_ex(progress->current_file, "error", sizeof("error"), data->cancel_upload); + add_assoc_bool_ex(progress->current_file, "done", sizeof("done"), 1); + + Z_LVAL_P(progress->post_bytes_processed) = data->post_bytes_processed; + + php_session_rfc1867_update(progress, 0 TSRMLS_CC); + } + break; + case MULTIPART_EVENT_END: { + multipart_event_end *data = (multipart_event_end *) event_data; + + if (Z_TYPE(progress->sid) && progress->key.c) { + if (PS(rfc1867_cleanup)) { + php_session_rfc1867_cleanup(progress TSRMLS_CC); + } else { + add_assoc_bool_ex(progress->data, "done", sizeof("done"), 1); + Z_LVAL_P(progress->post_bytes_processed) = data->post_bytes_processed; + php_session_rfc1867_update(progress, 1 TSRMLS_CC); + } + php_rshutdown_session_globals(TSRMLS_C); + } + + if (progress->data) { + zval_ptr_dtor(&progress->data); + } + zval_dtor(&progress->sid); + smart_str_free(&progress->key); + efree(progress); + progress = NULL; + PS(rfc1867_progress) = NULL; + } + break; + } + + if (progress && progress->cancel_upload) { + return FAILURE; + } + return retval; + +} /* }}} */ + zend_module_entry session_module_entry = { STANDARD_MODULE_HEADER_EX, NULL, diff --git a/ext/session/tests/001.phpt b/ext/session/tests/001.phpt index 543eba713..eb04dc114 100644 --- a/ext/session/tests/001.phpt +++ b/ext/session/tests/001.phpt @@ -5,7 +5,6 @@ session object serialization --INI-- session.use_cookies=0 session.cache_limiter= -register_globals=1 session.serialize_handler=php session.save_handler=files --FILE-- @@ -24,17 +23,14 @@ $baz->method(); $arr[3] = new foo; $arr[3]->method(); -session_register("baz"); -session_register("arr"); +session_start(); + +$_SESSION["baz"] = $baz; +$_SESSION["arr"] = $arr; print session_encode()."\n"; session_destroy(); ---EXPECTF-- -Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0 - -Deprecated: Function session_register() is deprecated in %s on line %d - -Deprecated: Function session_register() is deprecated in %s on line %d +--EXPECT-- baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";s:4:"done";}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";s:4:"done";}} diff --git a/ext/session/tests/003.phpt b/ext/session/tests/003.phpt index 677a958e8..03c3b9576 100644 --- a/ext/session/tests/003.phpt +++ b/ext/session/tests/003.phpt @@ -5,7 +5,6 @@ session object deserialization --INI-- session.use_cookies=0 session.cache_limiter= -register_globals=1 session.serialize_handler=php session.save_handler=files --FILE-- @@ -21,14 +20,13 @@ session_id("abtest"); session_start(); session_decode('baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}}'); -$baz->method(); -$arr[3]->method(); +$_SESSION["baz"]->method(); +$_SESSION["arr"][3]->method(); -var_dump($baz); -var_dump($arr); +var_dump($_SESSION["baz"]); +var_dump($_SESSION["arr"]); session_destroy(); --EXPECT-- -Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0 object(foo)#1 (2) { ["bar"]=> string(2) "ok" diff --git a/ext/session/tests/004.phpt b/ext/session/tests/004.phpt index 3e6de2523..aeb2c8b36 100644 --- a/ext/session/tests/004.phpt +++ b/ext/session/tests/004.phpt @@ -5,7 +5,6 @@ session_set_save_handler test --INI-- session.use_cookies=0 session.cache_limiter= -register_globals=1 session.name=PHPSESSID session.serialize_handler=php --FILE-- @@ -56,24 +55,23 @@ session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, session_id("abtest"); session_start(); -$baz->method(); -$arr[3]->method(); +$_SESSION["baz"]->method(); +$_SESSION["arr"][3]->method(); -var_dump($baz); -var_dump($arr); +var_dump($_SESSION["baz"]); +var_dump($_SESSION["arr"]); session_write_close(); session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); session_start(); -var_dump($baz); -var_dump($arr); +var_dump($_SESSION["baz"]); +var_dump($_SESSION["arr"]); session_destroy(); ?> --EXPECT-- -Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0 OPEN: PHPSESSID READ: abtest object(foo)#2 (2) { @@ -94,7 +92,7 @@ array(1) { WRITE: abtest, baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}} OPEN: PHPSESSID READ: abtest -object(foo)#4 (2) { +object(foo)#3 (2) { ["bar"]=> string(2) "ok" ["yes"]=> diff --git a/ext/session/tests/005.phpt b/ext/session/tests/005.phpt index 4e6682c86..a970e6b71 100644 --- a/ext/session/tests/005.phpt +++ b/ext/session/tests/005.phpt @@ -5,7 +5,6 @@ custom save handler, multiple session_start()s, complex data structure test. --INI-- session.use_cookies=0 session.cache_limiter= -register_globals=1 session.name=PHPSESSID session.serialize_handler=php --FILE-- @@ -58,37 +57,41 @@ session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, session_id("abtest"); session_start(); -$baz->method(); -$arr[3]->method(); +session_decode($hnd->data); -var_dump($baz); -var_dump($arr); +$_SESSION["baz"]->method(); +$_SESSION["arr"][3]->method(); + +var_dump($_SESSION["baz"]); +var_dump($_SESSION["arr"]); session_write_close(); session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); session_start(); -$baz->method(); -$arr[3]->method(); +$_SESSION["baz"]->method(); +$_SESSION["arr"][3]->method(); -$c = 123; -session_register("c"); -var_dump($baz); var_dump($arr); var_dump($c); +$_SESSION["c"] = 123; +var_dump($_SESSION["baz"]); +var_dump($_SESSION["arr"]); +var_dump($_SESSION["c"]); session_write_close(); session_set_save_handler(array($hnd, "open"), array($hnd, "close"), array($hnd, "read"), array($hnd, "write"), array($hnd, "destroy"), array($hnd, "gc")); session_start(); -var_dump($baz); var_dump($arr); var_dump($c); +var_dump($_SESSION["baz"]); +var_dump($_SESSION["arr"]); +var_dump($_SESSION["c"]); session_destroy(); ?> --EXPECTF-- -Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0 OPEN: PHPSESSID READ: abtest -object(foo)#2 (2) { +object(foo)#4 (2) { ["bar"]=> string(2) "ok" ["yes"]=> @@ -96,7 +99,7 @@ object(foo)#2 (2) { } array(1) { [3]=> - object(foo)#3 (2) { + object(foo)#2 (2) { ["bar"]=> string(2) "ok" ["yes"]=> @@ -107,9 +110,7 @@ WRITE: abtest, baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:2;}arr|a:1:{i:3;O CLOSE OPEN: PHPSESSID READ: abtest - -Deprecated: Function session_register() is deprecated in %s on line %d -object(foo)#4 (2) { +object(foo)#2 (2) { ["bar"]=> string(2) "ok" ["yes"]=> @@ -117,7 +118,7 @@ object(foo)#4 (2) { } array(1) { [3]=> - object(foo)#2 (2) { + object(foo)#4 (2) { ["bar"]=> string(2) "ok" ["yes"]=> @@ -129,7 +130,7 @@ WRITE: abtest, baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:3;}arr|a:1:{i:3;O CLOSE OPEN: PHPSESSID READ: abtest -object(foo)#3 (2) { +object(foo)#4 (2) { ["bar"]=> string(2) "ok" ["yes"]=> @@ -137,7 +138,7 @@ object(foo)#3 (2) { } array(1) { [3]=> - object(foo)#4 (2) { + object(foo)#2 (2) { ["bar"]=> string(2) "ok" ["yes"]=> diff --git a/ext/session/tests/006.phpt b/ext/session/tests/006.phpt index 9ab28f65d..03fca1038 100644 --- a/ext/session/tests/006.phpt +++ b/ext/session/tests/006.phpt @@ -5,7 +5,6 @@ correct instantiation of references between variables in sessions --INI-- session.use_cookies=0 session.cache_limiter= -register_globals=1 session.serialize_handler=php session.save_handler=files --FILE-- @@ -32,12 +31,11 @@ $b = new b($a); echo "original values:\n"; var_dump($a,$b); -session_register("a"); -session_register("b"); +$_SESSION["a"] = $a; +$_SESSION["b"] = $b; session_write_close(); -session_unregister("a"); -session_unregister("b"); +unset($_SESSION["a"], $_SESSION["b"]); session_start(); @@ -45,7 +43,6 @@ echo "values after session:\n"; var_dump($a,$b); ?> --EXPECTF-- -Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0 original values: object(a)#%d (1) { ["test"]=> @@ -58,14 +55,6 @@ object(b)#%d (1) { string(5) "hallo" } } - -Deprecated: Function session_register() is deprecated in %s on line %d - -Deprecated: Function session_register() is deprecated in %s on line %d - -Deprecated: Function session_unregister() is deprecated in %s on line %d - -Deprecated: Function session_unregister() is deprecated in %s on line %d values after session: object(a)#%d (1) { ["test"]=> @@ -78,4 +67,3 @@ object(b)#%d (1) { string(5) "hallo" } } - diff --git a/ext/session/tests/007.phpt b/ext/session/tests/007.phpt deleted file mode 100644 index 54768e2bd..000000000 --- a/ext/session/tests/007.phpt +++ /dev/null @@ -1,67 +0,0 @@ ---TEST-- -bug compatibility: unset($c) with enabled register_globals ---SKIPIF-- -<?php include('skipif.inc'); ?> ---INI-- -register_long_arrays=1 -session.use_cookies=0 -session.cache_limiter= -register_globals=1 -session.bug_compat_42=1 -session.serialize_handler=php -session.save_handler=files -precision=14 ---FILE-- -<?php -error_reporting(E_ALL); - -session_id("abtest"); - -### Phase 1 cleanup -session_start(); -session_destroy(); - -### Phase 2 $HTTP_SESSION_VARS["c"] does not contain any value -session_id("abtest"); -session_register("c"); -unset($c); -$c = 3.14; -session_write_close(); -unset($HTTP_SESSION_VARS); -unset($c); - -### Phase 3 $HTTP_SESSION_VARS["c"] is set -session_start(); -var_dump($c); -var_dump($HTTP_SESSION_VARS); -unset($c); -$c = 2.78; - -session_write_close(); -unset($HTTP_SESSION_VARS); -unset($c); - -### Phase 4 final - -session_start(); -var_dump($c); -var_dump($HTTP_SESSION_VARS); - -session_destroy(); -?> ---EXPECTF-- -Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0 - -Deprecated: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0 - -Deprecated: Function session_register() is deprecated in %s on line %d -float(3.14) -array(1) { - ["c"]=> - &float(3.14) -} -float(3.14) -array(1) { - ["c"]=> - &float(3.14) -} diff --git a/ext/session/tests/008-php4.2.3.phpt b/ext/session/tests/008-php4.2.3.phpt deleted file mode 100644 index 9464ecded..000000000 --- a/ext/session/tests/008-php4.2.3.phpt +++ /dev/null @@ -1,78 +0,0 @@ ---TEST-- -bug compatibility: global is used albeit register_globals=0 ---SKIPIF-- -<?php include('skipif.inc'); - if (version_compare(PHP_VERSION,"4.2.3-dev", "<")) die("skip this is for PHP >= 4.2.3"); -?> ---INI-- -register_long_arrays=1 -session.use_cookies=0 -session.cache_limiter= -register_globals=0 -session.bug_compat_42=1 -session.bug_compat_warn=1 -track_errors=1 -log_errors=0 -html_errors=0 -display_errors=1 -session.serialize_handler=php -session.save_handler=files -precision=14 ---FILE-- -<?php -session_id("abtest"); - -### Phase 1 cleanup -session_start(); -session_destroy(); - -### Phase 2 $HTTP_SESSION_VARS["c"] does not contain any value -session_id("abtest"); -session_register("c"); -var_dump($c); -unset($c); -$c = 3.14; -@session_write_close(); // this generates an E_WARNING which will be printed -// by $php_errormsg so we can use "@" here. ANY further message IS an error. -echo $php_errormsg."\n"; -unset($HTTP_SESSION_VARS); -unset($c); - -### Phase 3 $HTTP_SESSION_VARS["c"] is set -session_start(); -var_dump($HTTP_SESSION_VARS); -unset($c); -$c = 2.78; - -session_write_close(); -unset($HTTP_SESSION_VARS); -unset($c); - -### Phase 4 final - -session_start(); -var_dump($c); -var_dump($HTTP_SESSION_VARS); - -session_destroy(); -?> ---EXPECTF-- -Deprecated: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0 - -Deprecated: Function session_register() is deprecated in %s on line %d - -Notice: Undefined variable: c in %s on line %d -NULL -session_write_close(): Your script possibly relies on a session side-effect which existed until PHP 4.2.3. Please be advised that the session extension does not consider global variables as a source of data, unless register_globals is enabled. You can disable this functionality and this warning by setting session.bug_compat_42 or session.bug_compat_warn to off, respectively -array(1) { - ["c"]=> - float(3.14) -} - -Notice: Undefined variable: c in %s on line %d -NULL -array(1) { - ["c"]=> - float(3.14) -} - diff --git a/ext/session/tests/009.phpt b/ext/session/tests/009.phpt index 1a7e87ce0..d73bc238c 100644 --- a/ext/session/tests/009.phpt +++ b/ext/session/tests/009.phpt @@ -1,14 +1,10 @@ --TEST-- -unset($_SESSION["name"]); should work with register_globals=off +unset($_SESSION["name"]); test --SKIPIF-- <?php include('skipif.inc'); ?> --INI-- -register_long_arrays=1 session.use_cookies=0 session.cache_limiter= -register_globals=0 -session.bug_compat_42=1 -session.bug_compat_warn=0 session.serialize_handler=php session.save_handler=files --FILE-- @@ -21,29 +17,28 @@ session_id("abtest"); session_start(); session_destroy(); -### Phase 2 $HTTP_SESSION_VARS["c"] does not contain any value +### Phase 2 $_SESSION["c"] does not contain any value session_id("abtest"); session_start(); -var_dump($HTTP_SESSION_VARS); -$HTTP_SESSION_VARS["name"] = "foo"; -var_dump($HTTP_SESSION_VARS); +var_dump($_SESSION); +$_SESSION["name"] = "foo"; +var_dump($_SESSION); session_write_close(); -### Phase 3 $HTTP_SESSION_VARS["c"] is set +### Phase 3 $_SESSION["c"] is set session_start(); -var_dump($HTTP_SESSION_VARS); -unset($HTTP_SESSION_VARS["name"]); -var_dump($HTTP_SESSION_VARS); +var_dump($_SESSION); +unset($_SESSION["name"]); +var_dump($_SESSION); session_write_close(); ### Phase 4 final session_start(); -var_dump($HTTP_SESSION_VARS); +var_dump($_SESSION); session_destroy(); ?> --EXPECT-- -Deprecated: Directive 'register_long_arrays' is deprecated in PHP 5.3 and greater in Unknown on line 0 array(0) { } array(1) { diff --git a/ext/session/tests/010.phpt b/ext/session/tests/010.phpt index e1af8ce87..79638d283 100644 --- a/ext/session/tests/010.phpt +++ b/ext/session/tests/010.phpt @@ -5,9 +5,6 @@ $session_array = explode(";", session_encode()); should not segfault --INI-- session.use_cookies=0 session.cache_limiter= -register_globals=0 -session.bug_compat_42=1 -session.bug_compat_warn=0 --FILE-- <?php error_reporting(E_ALL); diff --git a/ext/session/tests/011.phpt b/ext/session/tests/011.phpt index 6aaa6bd79..ff1adbaec 100644 --- a/ext/session/tests/011.phpt +++ b/ext/session/tests/011.phpt @@ -5,9 +5,6 @@ session_decode(); should not segfault --INI-- session.use_cookies=0 session.cache_limiter= -register_globals=0 -session.bug_compat_42=1 -session.bug_compat_warn=0 --FILE-- <?php error_reporting(E_ALL); diff --git a/ext/session/tests/012.phpt b/ext/session/tests/012.phpt index b52333a99..870801127 100644 --- a/ext/session/tests/012.phpt +++ b/ext/session/tests/012.phpt @@ -5,9 +5,6 @@ registering $_SESSION should not segfault --INI-- session.use_cookies=0 session.cache_limiter= -register_globals=1 -session.bug_compat_42=1 -session.bug_compat_warn=0 session.serialize_handler=php session.save_handler=files --FILE-- @@ -18,7 +15,7 @@ error_reporting(E_ALL); session_id("abtest"); session_start(); -session_register("_SESSION"); +$_SESSION["_SESSION"] = Array(); $_SESSION = "kk"; session_write_close(); @@ -31,8 +28,5 @@ session_destroy(); print "I live\n"; ?> ---EXPECTF-- -Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0 - -Deprecated: Function session_register() is deprecated in %s on line %d +--EXPECT-- I live diff --git a/ext/session/tests/013.phpt b/ext/session/tests/013.phpt index 04322f9f1..8d0f284b1 100644 --- a/ext/session/tests/013.phpt +++ b/ext/session/tests/013.phpt @@ -5,9 +5,6 @@ redefining SID should not cause warnings --INI-- session.use_cookies=0 session.cache_limiter= -register_globals=1 -session.bug_compat_42=1 -session.bug_compat_warn=0 session.serialize_handler=php session.save_handler=files --FILE-- @@ -24,5 +21,4 @@ session_destroy(); print "I live\n"; ?> --EXPECT-- -Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0 I live diff --git a/ext/session/tests/014.phpt b/ext/session/tests/014.phpt index 09ad0f5b1..73bc28ea6 100644 --- a/ext/session/tests/014.phpt +++ b/ext/session/tests/014.phpt @@ -6,9 +6,6 @@ a script should not be able to modify session.use_trans_sid session.use_trans_sid=0 session.use_cookies=0 session.cache_limiter= -register_globals=1 -session.bug_compat_42=1 -session.bug_compat_warn=0 session.name=PHPSESSID session.serialize_handler=php session.save_handler=files @@ -33,7 +30,6 @@ ini_set("session.use_trans_sid","0"); session_destroy(); ?> --EXPECTF-- -Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0 <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 diff --git a/ext/session/tests/019.phpt b/ext/session/tests/019.phpt index 9c4f8caf9..3ee8ccd42 100644 --- a/ext/session/tests/019.phpt +++ b/ext/session/tests/019.phpt @@ -5,7 +5,6 @@ serializing references test case using globals --INI-- session.use_cookies=0 session.cache_limiter= -register_globals=1 session.serialize_handler=php session.save_handler=files --FILE-- @@ -25,31 +24,28 @@ class TFoo { session_id("abtest"); session_start(); -session_register('o1', 'o2' ); -$o1 = new TFoo(42); -$o2 =& $o1; +$_SESSION["o1"] = new TFoo(42); +$_SESSION["o2"] =& $_SESSION["o1"]; session_write_close(); -unset($o1); -unset($o2); +unset($_SESSION["o1"]); +unset($_SESSION["o2"]); session_start(); var_dump($_SESSION); -$o1->inc(); -$o2->inc(); +$_SESSION["o1"]->inc(); +$_SESSION["o2"]->inc(); var_dump($_SESSION); session_destroy(); ?> --EXPECTF-- -Deprecated: Directive 'register_globals' is deprecated in PHP 5.3 and greater in Unknown on line 0 -Deprecated: Function session_register() is deprecated in %s on line %d array(2) { ["o1"]=> &object(TFoo)#%d (1) { diff --git a/ext/session/tests/bug24592.phpt b/ext/session/tests/bug24592.phpt index 059125ba2..9f6c39531 100644 --- a/ext/session/tests/bug24592.phpt +++ b/ext/session/tests/bug24592.phpt @@ -3,7 +3,6 @@ Bug #24592 (crash when multiple NULL values are being stored) --SKIPIF-- <?php include('skipif.inc'); ?> --INI-- -register_globals=0 html_errors=0 session.save_handler=files --FILE-- diff --git a/ext/session/tests/bug26862.phpt b/ext/session/tests/bug26862.phpt index 44e7418cd..7990f7435 100644 --- a/ext/session/tests/bug26862.phpt +++ b/ext/session/tests/bug26862.phpt @@ -3,7 +3,6 @@ Bug #26862 (ob_flush() before output_reset_rewrite_vars() results in data loss) --SKIPIF-- <?php include('skipif.inc'); ?> --INI-- -register_globals=0 html_errors=0 session.use_trans_sid=0 session.save_handler=files diff --git a/ext/session/tests/bug55688.phpt b/ext/session/tests/bug55688.phpt new file mode 100644 index 000000000..8db48384a --- /dev/null +++ b/ext/session/tests/bug55688.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #55688 (Crash when calling SessionHandler::gc()) +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +html_errors=0 +session.save_handler=files +--FILE-- +<?php +ini_set('session.save_handler', 'files'); +$x = new SessionHandler; +$x->gc(1); +?> +--EXPECTF-- +Warning: SessionHandler::gc(): Parent session handler is not open in %s on line %d diff --git a/ext/session/tests/rfc1867.phpt b/ext/session/tests/rfc1867.phpt new file mode 100644 index 000000000..dc44e8b44 --- /dev/null +++ b/ext/session/tests/rfc1867.phpt @@ -0,0 +1,129 @@ +--TEST-- +session rfc1867 +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=1% +session.upload_progress.min_freq=0.000000001 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} diff --git a/ext/session/tests/rfc1867_cleanup.phpt b/ext/session/tests/rfc1867_cleanup.phpt new file mode 100644 index 000000000..f70b395d2 --- /dev/null +++ b/ext/session/tests/rfc1867_cleanup.phpt @@ -0,0 +1,83 @@ +--TEST-- +session rfc1867 +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=1 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=1% +session.upload_progress.min_freq=0.000000001 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_cleanup.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +NULL diff --git a/ext/session/tests/rfc1867_disabled.phpt b/ext/session/tests/rfc1867_disabled.phpt new file mode 100644 index 000000000..449005579 --- /dev/null +++ b/ext/session/tests/rfc1867_disabled.phpt @@ -0,0 +1,76 @@ +--TEST-- +session rfc1867 disabled +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=0 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=1% +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +NULL diff --git a/ext/session/tests/rfc1867_disabled_2.phpt b/ext/session/tests/rfc1867_disabled_2.phpt new file mode 100644 index 000000000..e878f4619 --- /dev/null +++ b/ext/session/tests/rfc1867_disabled_2.phpt @@ -0,0 +1,76 @@ +--TEST-- +session rfc1867 disabled 2 +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=1% +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +NULL diff --git a/ext/session/tests/rfc1867_inter.phpt b/ext/session/tests/rfc1867_inter.phpt new file mode 100644 index 000000000..768637105 --- /dev/null +++ b/ext/session/tests/rfc1867_inter.phpt @@ -0,0 +1,133 @@ +--TEST-- +session rfc1867 +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=1% +session.upload_progress.min_freq=0.000000001 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_inter.php_1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_inter.php_2 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__) . "_1"]); +var_dump($_SESSION["upload_progress_" . basename(__FILE__) . "_2"]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} +NULL diff --git a/ext/session/tests/rfc1867_invalid_settings.phpt b/ext/session/tests/rfc1867_invalid_settings.phpt new file mode 100644 index 000000000..d954563b0 --- /dev/null +++ b/ext/session/tests/rfc1867_invalid_settings.phpt @@ -0,0 +1,16 @@ +--TEST-- +session rfc1867 invalid settings +--INI-- +session.upload_progress.freq=-1 +error_log= +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php +var_dump(ini_get("session.upload_progress.freq")); +?> +--EXPECTF-- +PHP 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 zero in %s +string(%d) "1%" diff --git a/ext/session/tests/rfc1867_invalid_settings_2.phpt b/ext/session/tests/rfc1867_invalid_settings_2.phpt new file mode 100644 index 000000000..544510eef --- /dev/null +++ b/ext/session/tests/rfc1867_invalid_settings_2.phpt @@ -0,0 +1,16 @@ +--TEST-- +session rfc1867 invalid settings 2 +--INI-- +session.upload_progress.freq=200% +error_log= +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php +var_dump(ini_get("session.upload_progress.freq")); +?> +--EXPECTF-- +PHP Warning: PHP Startup: session.upload_progress.freq cannot be over 100% in %s + +Warning: PHP Startup: session.upload_progress.freq cannot be over 100% in %s +string(%d) "1%" diff --git a/ext/session/tests/rfc1867_no_name.phpt b/ext/session/tests/rfc1867_no_name.phpt new file mode 100644 index 000000000..c1dda8156 --- /dev/null +++ b/ext/session/tests/rfc1867_no_name.phpt @@ -0,0 +1,76 @@ +--TEST-- +session rfc1867 no name +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=1% +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +NULL diff --git a/ext/session/tests/rfc1867_sid_cookie.phpt b/ext/session/tests/rfc1867_sid_cookie.phpt new file mode 100644 index 000000000..735a5ac20 --- /dev/null +++ b/ext/session/tests/rfc1867_sid_cookie.phpt @@ -0,0 +1,128 @@ +--TEST-- +session rfc1867 sid cookie +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_cookie.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} diff --git a/ext/session/tests/rfc1867_sid_get.phpt b/ext/session/tests/rfc1867_sid_get.phpt new file mode 100644 index 000000000..cc5a793e7 --- /dev/null +++ b/ext/session/tests/rfc1867_sid_get.phpt @@ -0,0 +1,126 @@ +--TEST-- +session rfc1867 sid get +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--GET-- +PHPSESSID=rfc1867-tests +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_get.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} diff --git a/ext/session/tests/rfc1867_sid_get_2.phpt b/ext/session/tests/rfc1867_sid_get_2.phpt new file mode 100644 index 000000000..1d22e5930 --- /dev/null +++ b/ext/session/tests/rfc1867_sid_get_2.phpt @@ -0,0 +1,128 @@ +--TEST-- +session rfc1867 sid get 2 +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=0 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests-cookie +--GET-- +PHPSESSID=rfc1867-tests +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_get_2.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} diff --git a/ext/session/tests/rfc1867_sid_invalid.phpt b/ext/session/tests/rfc1867_sid_invalid.phpt new file mode 100644 index 000000000..b28a2e341 --- /dev/null +++ b/ext/session/tests/rfc1867_sid_invalid.phpt @@ -0,0 +1,79 @@ +--TEST-- +session rfc1867 sid cookie +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.auto_start=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=_ +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_invalid.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +error_reporting(0); +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--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 +string(%d) "%s" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +NULL diff --git a/ext/session/tests/rfc1867_sid_only_cookie.phpt b/ext/session/tests/rfc1867_sid_only_cookie.phpt new file mode 100644 index 000000000..9a0105668 --- /dev/null +++ b/ext/session/tests/rfc1867_sid_only_cookie.phpt @@ -0,0 +1,128 @@ +--TEST-- +session rfc1867 sid only cookie +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=1 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--COOKIE-- +PHPSESSID=rfc1867-tests +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_only_cookie.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} diff --git a/ext/session/tests/rfc1867_sid_only_cookie_2.phpt b/ext/session/tests/rfc1867_sid_only_cookie_2.phpt new file mode 100644 index 000000000..e705314d6 --- /dev/null +++ b/ext/session/tests/rfc1867_sid_only_cookie_2.phpt @@ -0,0 +1,80 @@ +--TEST-- +session rfc1867 sid only cookie 2 +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=1 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--GET-- +PHPSESSID=rfc1867-tests-get +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests-post +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_only_cookie_2.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "%s" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +NULL diff --git a/ext/session/tests/rfc1867_sid_post.phpt b/ext/session/tests/rfc1867_sid_post.phpt new file mode 100644 index 000000000..7c1eb2de5 --- /dev/null +++ b/ext/session/tests/rfc1867_sid_post.phpt @@ -0,0 +1,124 @@ +--TEST-- +session rfc1867 sid post +--INI-- +file_uploads=1 +error_reporting=E_ALL&~E_NOTICE +comment=debug builds show some additional E_NOTICE errors +upload_max_filesize=1024 +session.save_path= +session.name=PHPSESSID +session.use_cookies=1 +session.use_only_cookies=0 +session.upload_progress.enabled=1 +session.upload_progress.cleanup=0 +session.upload_progress.prefix=upload_progress_ +session.upload_progress.name=PHP_SESSION_UPLOAD_PROGRESS +session.upload_progress.freq=0 +--SKIPIF-- +<?php include('skipif.inc'); ?> +--POST_RAW-- +Content-Type: multipart/form-data; boundary=---------------------------20896060251896012921717172737 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHPSESSID" + +rfc1867-tests +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="PHP_SESSION_UPLOAD_PROGRESS" + +rfc1867_sid_post.php +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file1"; filename="file1.txt" + +1 +-----------------------------20896060251896012921717172737 +Content-Disposition: form-data; name="file2"; filename="file2.txt" + +2 +-----------------------------20896060251896012921717172737-- +--FILE-- +<?php +session_start(); +var_dump(session_id()); +var_dump(basename(__FILE__) == $_POST[ini_get("session.upload_progress.name")]); +var_dump($_FILES); +var_dump($_SESSION["upload_progress_" . basename(__FILE__)]); +session_destroy(); +?> +--EXPECTF-- +string(%d) "rfc1867-tests" +bool(true) +array(2) { + [%u|b%"file1"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file1.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } + [%u|b%"file2"]=> + array(5) { + [%u|b%"name"]=> + %string|unicode%(9) "file2.txt" + [%u|b%"type"]=> + %string|unicode%(0) "" + [%u|b%"tmp_name"]=> + %string|unicode%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"size"]=> + int(1) + } +} +array(5) { + [%u|b%"start_time"]=> + int(%d) + [%u|b%"content_length"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(%d) + [%u|b%"done"]=> + bool(true) + [%u|b%"files"]=> + array(2) { + [0]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file1" + [%u|b%"name"]=> + %unicode|string%(9) "file1.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + [1]=> + array(7) { + [%u|b%"field_name"]=> + %unicode|string%(5) "file2" + [%u|b%"name"]=> + %unicode|string%(9) "file2.txt" + [%u|b%"tmp_name"]=> + %unicode|string%(%d) "%s" + [%u|b%"error"]=> + int(0) + [%u|b%"done"]=> + bool(true) + [%u|b%"start_time"]=> + int(%d) + [%u|b%"bytes_processed"]=> + int(1) + } + } +} diff --git a/ext/session/tests/session_encode_basic.phpt b/ext/session/tests/session_encode_basic.phpt index b087f7441..dfe40d204 100644 --- a/ext/session/tests/session_encode_basic.phpt +++ b/ext/session/tests/session_encode_basic.phpt @@ -1,5 +1,7 @@ --TEST-- Test session_encode() function : basic functionality +--INI-- +serialize_precision=100 --SKIPIF-- <?php include('skipif.inc'); ?> --FILE-- @@ -120,7 +122,7 @@ string(13) "data|d:-10.5;" string(20) "data|d:123456789000;" -- Iteration 8 -- -string(29) "data|d:1.2345678899999999E-9;" +string(%d) "data|d:1.2345678899999999145113427164344339914681114578343112953007221221923828125E-9;" -- Iteration 9 -- string(11) "data|d:0.5;" diff --git a/ext/session/tests/session_id_variation2.phpt b/ext/session/tests/session_id_variation2.phpt index 70db283ae..f69aa44c0 100644 --- a/ext/session/tests/session_id_variation2.phpt +++ b/ext/session/tests/session_id_variation2.phpt @@ -4,6 +4,8 @@ Test session_id() function : variation <?php include('skipif.inc'); ?> --INI-- session.hash_function=0 +session.entropy_file= +session.entropy_length=0 --FILE-- <?php diff --git a/ext/session/tests/session_is_registered_basic.phpt b/ext/session/tests/session_is_registered_basic.phpt deleted file mode 100644 index 5eb127ea4..000000000 --- a/ext/session/tests/session_is_registered_basic.phpt +++ /dev/null @@ -1,318 +0,0 @@ ---TEST-- -Test session_unregister() function : basic functionality ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_is_registered(string $name) - * Description : Find out whether a global variable is registered in a session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_is_registered() : basic functionality ***\n"; - -// Get an unset variable -$unset_var = 10; -unset($unset_var); - -class classA -{ - public function __toString() { - return "Hello World!"; - } -} - -$heredoc = <<<EOT -Hello World! -EOT; - -$fp = fopen(__FILE__, "r"); - -// Unexpected values to be passed as arguments -$inputs = array( - - // Integer data -/*1*/ 0, - 1, - 12345, - -2345, - - // Float data -/*5*/ 10.5, - -10.5, - 12.3456789000e10, - 12.3456789000E-10, - .5, - - // Null data -/*10*/ NULL, - null, - - // Boolean data -/*12*/ true, - false, - TRUE, - FALSE, - - // Empty strings -/*16*/ "", - '', - - // Invalid string data -/*18*/ "Nothing", - 'Nothing', - $heredoc, - - // Object data -/*21*/ new classA(), - - // Undefined data -/*22*/ @$undefined_var, - - // Unset data -/*23*/ @$unset_var, - - // Resource variable -/*24*/ $fp -); - - -$iterator = 1; -foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump(session_start()); - var_dump(session_is_registered($input)); - var_dump($_SESSION); - var_dump(session_destroy()); - $iterator++; -}; - -fclose($fp); -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_is_registered() : basic functionality *** - --- Iteration 1 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 2 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 3 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 4 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 5 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 6 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 7 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 8 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 9 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 10 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 11 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 12 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 13 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 14 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 15 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 16 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 17 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 18 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 19 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 20 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 21 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 22 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 23 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - --- Iteration 24 -- -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d - -Warning: session_is_registered() expects parameter 1 to be string, resource given in %s on line %d -NULL -array(0) { -} -bool(true) -Done diff --git a/ext/session/tests/session_is_registered_variation1.phpt b/ext/session/tests/session_is_registered_variation1.phpt deleted file mode 100644 index 35c357d14..000000000 --- a/ext/session/tests/session_is_registered_variation1.phpt +++ /dev/null @@ -1,109 +0,0 @@ ---TEST-- -Test session_unregister() function : variation ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_is_registered(string $name) - * Description : Find out whether a global variable is registered in a session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_is_registered() : variation ***\n"; - -// Get an unset variable -$unset_var = 10; -unset($unset_var); - -class classA -{ - public function __toString() { - return "Hello World!"; - } -} - -$heredoc = <<<EOT -Hello World! -EOT; - -$fp = fopen(__FILE__, "r"); - -// Unexpected values to be passed as arguments -$inputs = array( - - // Integer data -/*1*/ 0, - 1, - 12345, - -2345, - - // Float data -/*5*/ 10.5, - -10.5, - 12.3456789000e10, - 12.3456789000E-10, - .5, - - // Null data -/*10*/ NULL, - null, - - // Boolean data -/*12*/ true, - false, - TRUE, - FALSE, - - // Empty strings -/*16*/ "", - '', - - // Invalid string data -/*18*/ "Nothing", - 'Nothing', - $heredoc, - - // Object data -/*21*/ new classA(), - - // Undefined data -/*22*/ @$undefined_var, - - // Unset data -/*23*/ @$unset_var, - - // Resource variable -/*24*/ $fp -); - -var_dump(session_start()); -var_dump($_SESSION); -var_dump(session_is_registered($inputs)); -var_dump($_SESSION); -var_dump(session_destroy()); -var_dump($_SESSION); - -fclose($fp); -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_is_registered() : variation *** -bool(true) -array(0) { -} - -Deprecated: Function session_is_registered() is deprecated in %s on line %d - -Warning: session_is_registered() expects parameter 1 to be string, array given in %s on line %d -NULL -array(0) { -} -bool(true) -array(0) { -} -Done diff --git a/ext/session/tests/session_is_registered_variation2.phpt b/ext/session/tests/session_is_registered_variation2.phpt deleted file mode 100644 index 3727518b1..000000000 --- a/ext/session/tests/session_is_registered_variation2.phpt +++ /dev/null @@ -1,75 +0,0 @@ ---TEST-- -Test session_unregister() function : variation ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_is_registered(string $name) - * Description : Find out whether a global variable is registered in a session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_is_registered() : variation ***\n"; - -var_dump(session_is_registered("foo")); -var_dump(session_start()); -var_dump(session_is_registered("foo")); -var_dump($_SESSION); -$_SESSION["foo"] = "Hello World!"; -var_dump(session_is_registered("foo")); -var_dump($_SESSION); -var_dump(session_is_registered("foo")); -var_dump(session_unregister("foo")); -var_dump(session_is_registered("foo")); -var_dump($_SESSION); -var_dump(session_destroy()); -var_dump(session_is_registered("foo")); -var_dump($_SESSION); -var_dump(session_is_registered("foo")); - -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_is_registered() : variation *** - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(true) -array(1) { - ["foo"]=> - string(12) "Hello World!" -} - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(true) - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -Done diff --git a/ext/session/tests/session_is_registered_variation3.phpt b/ext/session/tests/session_is_registered_variation3.phpt deleted file mode 100644 index b435d043d..000000000 --- a/ext/session/tests/session_is_registered_variation3.phpt +++ /dev/null @@ -1,72 +0,0 @@ ---TEST-- -Test session_unregister() function : variation ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_is_registered(string $name) - * Description : Find out whether a global variable is registered in a session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_is_registered() : variation ***\n"; - -var_dump(session_is_registered("foo")); -var_dump(session_start()); -var_dump(session_is_registered("foo")); -var_dump($_SESSION); -$blah = "Hello World!"; -var_dump(session_is_registered("foo")); -$_SESSION["foo"] = &$blah; -var_dump($_SESSION); -var_dump(session_is_registered("foo")); -var_dump(session_unregister("foo")); -var_dump(session_is_registered("foo")); -var_dump($_SESSION); -var_dump(session_destroy()); -var_dump(session_is_registered("foo")); -var_dump($_SESSION); - -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_is_registered() : variation *** - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(1) { - ["foo"]=> - &string(12) "Hello World!" -} - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(true) - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -bool(true) - -Deprecated: Function session_is_registered() is deprecated in %s on line %d -bool(false) -array(0) { -} -Done diff --git a/ext/session/tests/session_register_basic.phpt b/ext/session/tests/session_register_basic.phpt deleted file mode 100644 index a394f748e..000000000 --- a/ext/session/tests/session_register_basic.phpt +++ /dev/null @@ -1,364 +0,0 @@ ---TEST-- -Test session_register() function : basic functionality ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_register(mixed $name [,mixed $...]) - * Description : Register one or more global variables with the current session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_register() : basic functionality ***\n"; - -// Get an unset variable -$unset_var = 10; -unset($unset_var); - -class classA -{ - public function __toString() { - return "Hello World!"; - } -} - -$heredoc = <<<EOT -Hello World! -EOT; - -$fp = fopen(__FILE__, "r"); - -// Unexpected values to be passed as arguments -$inputs = array( - - // Integer data -/*1*/ 0, - 1, - 12345, - -2345, - - // Float data -/*5*/ 10.5, - -10.5, - 12.3456789000e10, - 12.3456789000E-10, - .5, - - // Null data -/*10*/ NULL, - null, - - // Boolean data -/*12*/ true, - false, - TRUE, - FALSE, - - // Empty strings -/*16*/ "", - '', - - // Invalid string data -/*18*/ "Nothing", - 'Nothing', - $heredoc, - - // Object data -/*21*/ new classA(), - - // Undefined data -/*22*/ @$undefined_var, - - // Unset data -/*23*/ @$unset_var, - - // Resource variable -/*24*/ $fp -); - - -$iterator = 1; -foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump(session_start()); - var_dump(session_register($input)); - var_dump($_SESSION); - var_dump(session_destroy()); - $iterator++; -}; - -fclose($fp); -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_register() : basic functionality *** - --- Iteration 1 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["0"]=> - NULL -} -bool(true) - --- Iteration 2 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["1"]=> - NULL -} -bool(true) - --- Iteration 3 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["12345"]=> - NULL -} -bool(true) - --- Iteration 4 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["-2345"]=> - NULL -} -bool(true) - --- Iteration 5 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["10.5"]=> - NULL -} -bool(true) - --- Iteration 6 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["-10.5"]=> - NULL -} -bool(true) - --- Iteration 7 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["123456789000"]=> - NULL -} -bool(true) - --- Iteration 8 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["1.23456789E-9"]=> - NULL -} -bool(true) - --- Iteration 9 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["0.5"]=> - NULL -} -bool(true) - --- Iteration 10 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - [""]=> - NULL -} -bool(true) - --- Iteration 11 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - [""]=> - NULL -} -bool(true) - --- Iteration 12 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["1"]=> - NULL -} -bool(true) - --- Iteration 13 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - [""]=> - NULL -} -bool(true) - --- Iteration 14 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["1"]=> - NULL -} -bool(true) - --- Iteration 15 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - [""]=> - NULL -} -bool(true) - --- Iteration 16 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - [""]=> - NULL -} -bool(true) - --- Iteration 17 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - [""]=> - NULL -} -bool(true) - --- Iteration 18 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["Nothing"]=> - NULL -} -bool(true) - --- Iteration 19 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["Nothing"]=> - NULL -} -bool(true) - --- Iteration 20 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["Hello World!"]=> - NULL -} -bool(true) - --- Iteration 21 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["Hello World!"]=> - NULL -} -bool(true) - --- Iteration 22 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - [""]=> - NULL -} -bool(true) - --- Iteration 23 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - [""]=> - NULL -} -bool(true) - --- Iteration 24 -- -bool(true) - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["Resource id #%d"]=> - NULL -} -bool(true) -Done diff --git a/ext/session/tests/session_register_variation1.phpt b/ext/session/tests/session_register_variation1.phpt deleted file mode 100644 index 82950d9a9..000000000 --- a/ext/session/tests/session_register_variation1.phpt +++ /dev/null @@ -1,159 +0,0 @@ ---TEST-- -Test session_register() function : variation ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_register(mixed $name [,mixed $...]) - * Description : Register one or more global variables with the current session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_register() : variation ***\n"; - -// Get an unset variable -$unset_var = 10; -unset($unset_var); - -class classA -{ - public function __toString() { - return "Hello World!"; - } -} - -$heredoc = <<<EOT -Hello World! -EOT; - -$fp = fopen(__FILE__, "r"); - -// Unexpected values to be passed as arguments -$inputs = array( - - // Integer data -/*1*/ 0, - 1, - 12345, - -2345, - - // Float data -/*5*/ 10.5, - -10.5, - 12.3456789000e10, - 12.3456789000E-10, - .5, - - // Null data -/*10*/ NULL, - null, - - // Boolean data -/*12*/ true, - false, - TRUE, - FALSE, - - // Empty strings -/*16*/ "", - '', - - // Invalid string data -/*18*/ "Nothing", - 'Nothing', - $heredoc, - - // Object data -/*21*/ new classA(), - - // Undefined data -/*22*/ @$undefined_var, - - // Unset data -/*23*/ @$unset_var, - - // Resource variable -/*24*/ $fp -); - -var_dump(session_start()); -var_dump($_SESSION); -var_dump(session_register($inputs)); -var_dump($_SESSION); -var_dump(session_destroy()); -var_dump($_SESSION); - -fclose($fp); -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_register() : variation *** -bool(true) -array(0) { -} - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(13) { - ["0"]=> - NULL - ["1"]=> - NULL - ["12345"]=> - NULL - ["-2345"]=> - NULL - ["10.5"]=> - NULL - ["-10.5"]=> - NULL - ["123456789000"]=> - NULL - ["1.23456789E-9"]=> - NULL - ["0.5"]=> - NULL - [""]=> - NULL - ["Nothing"]=> - NULL - ["Hello World!"]=> - NULL - ["Resource id #%d"]=> - NULL -} -bool(true) -array(13) { - ["0"]=> - NULL - ["1"]=> - NULL - ["12345"]=> - NULL - ["-2345"]=> - NULL - ["10.5"]=> - NULL - ["-10.5"]=> - NULL - ["123456789000"]=> - NULL - ["1.23456789E-9"]=> - NULL - ["0.5"]=> - NULL - [""]=> - NULL - ["Nothing"]=> - NULL - ["Hello World!"]=> - NULL - ["Resource id #%d"]=> - NULL -} -Done diff --git a/ext/session/tests/session_register_variation2.phpt b/ext/session/tests/session_register_variation2.phpt deleted file mode 100644 index d9060c7e9..000000000 --- a/ext/session/tests/session_register_variation2.phpt +++ /dev/null @@ -1,43 +0,0 @@ ---TEST-- -Test session_register() function : variation ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_register(mixed $name [,mixed $...]) - * Description : Register one or more global variables with the current session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_register() : variation ***\n"; - -var_dump(session_start()); -var_dump($_SESSION); -var_dump(session_register()); -var_dump($_SESSION); -var_dump(session_destroy()); -var_dump($_SESSION); - -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_register() : variation *** -bool(true) -array(0) { -} - -Deprecated: Function session_register() is deprecated in %s on line %d - -Warning: session_register() expects at least 1 parameter, 0 given in %s on line %d -NULL -array(0) { -} -bool(true) -array(0) { -} -Done diff --git a/ext/session/tests/session_register_variation3.phpt b/ext/session/tests/session_register_variation3.phpt deleted file mode 100644 index 43172ac49..000000000 --- a/ext/session/tests/session_register_variation3.phpt +++ /dev/null @@ -1,46 +0,0 @@ ---TEST-- -Test session_register() function : variation ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_register(mixed $name [,mixed $...]) - * Description : Register one or more global variables with the current session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_register() : variation ***\n"; - -$blah = "Hello World!"; -var_dump(session_start()); -var_dump($_SESSION); -var_dump(session_register("blah")); -var_dump($_SESSION); -var_dump(session_destroy()); -var_dump($_SESSION); - -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_register() : variation *** -bool(true) -array(0) { -} - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["blah"]=> - NULL -} -bool(true) -array(1) { - ["blah"]=> - NULL -} -Done diff --git a/ext/session/tests/session_register_variation4.phpt b/ext/session/tests/session_register_variation4.phpt deleted file mode 100644 index 4f0781502..000000000 --- a/ext/session/tests/session_register_variation4.phpt +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -Test session_register() function : variation ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_register(mixed $name [,mixed $...]) - * Description : Register one or more global variables with the current session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_register() : variation ***\n"; - -$blah = "Hello World!"; -$foo = &$blah; -var_dump(session_start()); -var_dump($_SESSION); -var_dump(session_register("foo")); -var_dump($_SESSION); -var_dump(session_destroy()); -var_dump($_SESSION); - -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_register() : variation *** -bool(true) -array(0) { -} - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(1) { - ["foo"]=> - NULL -} -bool(true) -array(1) { - ["foo"]=> - NULL -} -Done diff --git a/ext/session/tests/session_save_path_variation5.phpt b/ext/session/tests/session_save_path_variation5.phpt index ca6cb51c5..5407b5e15 100644 --- a/ext/session/tests/session_save_path_variation5.phpt +++ b/ext/session/tests/session_save_path_variation5.phpt @@ -6,15 +6,14 @@ if(substr(PHP_OS, 0, 3) == "WIN") die("skip Not for Windows"); ?> --INI-- -open_basedir=. session.save_handler=files session.save_path= session.name=PHPSESSID +open_basedir=. --FILE-- <?php ob_start(); - /* * Prototype : string session_save_path([string $path]) * Description : Get and/or set the current session save path diff --git a/ext/session/tests/session_set_save_handler_class_001.phpt b/ext/session/tests/session_set_save_handler_class_001.phpt new file mode 100644 index 000000000..83e899a2b --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_001.phpt @@ -0,0 +1,68 @@ +--TEST-- +Test session_set_save_handler() : basic class wrapping existing handler +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : basic class wrapping existing handler ***\n"; + +class MySession extends SessionHandler { + public $i = 0; + public function open($path, $name) { + ++$this->i; + echo 'Open ', session_id(), "\n"; + return parent::open($path, $name); + } + public function read($key) { + ++$this->i; + echo 'Read ', session_id(), "\n"; + return parent::read($key); + } +} + +$oldHandler = ini_get('session.save_handler'); +$handler = new MySession; +session_set_save_handler($handler); +session_start(); + +var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i, $_SESSION); + +$_SESSION['foo'] = "hello"; + +session_write_close(); +session_unset(); + +session_start(); +var_dump($_SESSION); + +session_write_close(); +session_unset(); + +--EXPECTF-- +*** Testing session_set_save_handler() : basic class wrapping existing handler *** +Open +Read %s +string(%d) "%s" +string(5) "files" +string(4) "user" +int(2) +array(0) { +} +Open %s +Read %s +array(1) { + ["foo"]=> + string(5) "hello" +} diff --git a/ext/session/tests/session_set_save_handler_class_002.phpt b/ext/session/tests/session_set_save_handler_class_002.phpt new file mode 100644 index 000000000..9d5f732b5 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_002.phpt @@ -0,0 +1,113 @@ +--TEST-- +Test session_set_save_handler() : full handler implementation +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : full handler implementation ***\n"; + +class MySession2 extends SessionHandler { + public $path; + + public function open($path, $name) { + if (!$path) { + $path = '/tmp'; + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return @file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } +} + +$handler = new MySession2; +session_set_save_handler(array($handler, 'open'), array($handler, 'close'), + array($handler, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc')); +session_start(); + +$_SESSION['foo'] = "hello"; + +var_dump(session_id(), ini_get('session.save_handler'), $_SESSION); + +session_write_close(); +session_unset(); + +session_start(); +var_dump($_SESSION); + +session_write_close(); +session_unset(); + +session_set_save_handler($handler); +session_start(); + +$_SESSION['foo'] = "hello"; + +var_dump(session_id(), ini_get('session.save_handler'), $_SESSION); + +session_write_close(); +session_unset(); + +session_start(); +var_dump($_SESSION); + +session_write_close(); +session_unset(); + +--EXPECTF-- +*** Testing session_set_save_handler() : full handler implementation *** +string(%d) "%s" +string(4) "user" +array(1) { + ["foo"]=> + string(5) "hello" +} +array(1) { + ["foo"]=> + string(5) "hello" +} +string(%d) "%s" +string(4) "user" +array(1) { + ["foo"]=> + string(5) "hello" +} +array(1) { + ["foo"]=> + string(5) "hello" +} diff --git a/ext/session/tests/session_set_save_handler_class_003.phpt b/ext/session/tests/session_set_save_handler_class_003.phpt new file mode 100644 index 000000000..e9a3cc2fe --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_003.phpt @@ -0,0 +1,78 @@ +--TEST-- +Test session_set_save_handler() : inheritance +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : inheritance ***\n"; + +class MySession3 extends SessionHandler { + public $i = 0; + public function open($path, $name) { + ++$this->i; + return parent::open($path, $name); + } + public function read($key) { + ++$this->i; + return parent::read($key); + } +} + +class MySession4 extends MySession3 { + public function write($id, $data) { + $this->i = "hai"; + return parent::write($id, $data); + } +} + +$handler = new MySession3; +session_set_save_handler($handler); +session_start(); + +$_SESSION['foo'] = "hello"; + +session_write_close(); +session_unset(); + +session_start(); + +var_dump($_SESSION, $handler->i); + +session_write_close(); +session_unset(); + +$handler = new MySession4; +session_set_save_handler($handler); + +session_start(); + +session_write_close(); +session_unset(); + +var_dump(session_id(), $_SESSION, $handler->i); + +--EXPECTF-- +*** Testing session_set_save_handler() : inheritance *** +array(1) { + ["foo"]=> + string(5) "hello" +} +int(4) +string(%d) "%s" +array(1) { + ["foo"]=> + string(5) "hello" +} +string(3) "hai" diff --git a/ext/session/tests/session_set_save_handler_class_004.phpt b/ext/session/tests/session_set_save_handler_class_004.phpt new file mode 100644 index 000000000..103b13baa --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_004.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test session_set_save_handler() : default object +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : default object ***\n"; + +session_set_save_handler(new SessionHandler); +session_start(); + +$_SESSION['foo'] = "hello"; + +var_dump(session_id(), ini_get('session.save_handler'), $_SESSION); + +session_write_close(); +session_unset(); +session_start(); + +var_dump($_SESSION); + +session_write_close(); +session_unset(); + +--EXPECTF-- +*** Testing session_set_save_handler() : default object *** +string(%d) "%s" +string(4) "user" +array(1) { + ["foo"]=> + string(5) "hello" +} +array(1) { + ["foo"]=> + string(5) "hello" +} diff --git a/ext/session/tests/session_set_save_handler_class_005.phpt b/ext/session/tests/session_set_save_handler_class_005.phpt new file mode 100644 index 000000000..a996eb8d2 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_005.phpt @@ -0,0 +1,54 @@ +--TEST-- +Test session_set_save_handler() : incomplete implementation +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : incomplete implementation ***\n"; + +class MySession6 extends SessionHandler { + public function open($path, $name) { + // don't call parent + return true; + } + + public function read($id) { + // should error because parent::open hasn't been called + return parent::read($id); + } +} + +$handler = new MySession6; +session_set_save_handler($handler); +session_start(); + +var_dump(session_id(), ini_get('session.save_handler'), $_SESSION); + +session_write_close(); +session_unset(); + + +--EXPECTF-- +*** Testing session_set_save_handler() : incomplete implementation *** + +Warning: SessionHandler::read(): Parent session handler is not open in %ssession_set_save_handler_class_005.php on line %d +string(%d) "%s" +string(4) "user" +array(0) { +} + +Warning: SessionHandler::write(): Parent session handler is not open in %ssession_set_save_handler_class_005.php on line %d + +Warning: SessionHandler::close(): Parent session handler is not open in %ssession_set_save_handler_class_005.php on line %d diff --git a/ext/session/tests/session_set_save_handler_class_006.phpt b/ext/session/tests/session_set_save_handler_class_006.phpt new file mode 100644 index 000000000..5830b6d4f --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_006.phpt @@ -0,0 +1,54 @@ +--TEST-- +Test session_set_save_handler() : using objects in close +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : using objects in close ***\n"; + +class MySession7_Foo { + public $state = 'ok'; + function __destruct() { + $this->state = 'destroyed'; + } +} + +class MySession7 extends SessionHandler { + public $foo; + public function close() { + var_dump($this->foo); + @var_dump($GLOBALS['bar']); + return parent::close(); + } +} + +$bar = new MySession7_Foo; +$handler = new MySession7; +$handler->foo = new MySession7_Foo; +session_set_save_handler($handler); +session_start(); + +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : using objects in close *** +object(MySession7_Foo)#%d (%d) { + ["state"]=> + string(2) "ok" +} +object(MySession7_Foo)#%d (%d) { + ["state"]=> + string(2) "ok" +} diff --git a/ext/session/tests/session_set_save_handler_class_007.phpt b/ext/session/tests/session_set_save_handler_class_007.phpt new file mode 100644 index 000000000..7344ae1ef --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_007.phpt @@ -0,0 +1,74 @@ +--TEST-- +Test session_set_save_handler() : manual shutdown, reopen +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : manual shutdown, reopen ***\n"; + +class MySession extends SessionHandler { + public $num; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + } + public function finish() { + $id = session_id(); + echo "(#$this->num) finish called $id\n"; + session_write_close(); + } + public function write($id, $data) { + echo "(#$this->num) writing $id = $data\n"; + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + echo "(#$this->num) closing $id\n"; + return parent::close(); + } +} + +$handler = new MySession(1); +session_set_save_handler($handler); +session_start(); + +$_SESSION['foo'] = 'bar'; + +// explicit close +$handler->finish(); + +$handler = new MySession(2); +session_set_save_handler($handler); +session_start(); + +// implicit close (called by shutdown function) +echo "done\n"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : manual shutdown, reopen *** +(#1) constructor called +(#1) finish called %s +(#1) writing %s = foo|s:3:"bar"; +(#1) closing %s +(#2) constructor called +(#1) destructor called +done +(#2) writing %s = foo|s:3:"bar"; +(#2) closing %s +(#2) destructor called diff --git a/ext/session/tests/session_set_save_handler_class_008.phpt b/ext/session/tests/session_set_save_handler_class_008.phpt new file mode 100644 index 000000000..28cb692f0 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_008.phpt @@ -0,0 +1,65 @@ +--TEST-- +Test session_set_save_handler() : manual shutdown +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : manual shutdown ***\n"; + +class MySession extends SessionHandler { + public $num; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + } + public function finish() { + $id = session_id(); + echo "(#$this->num) finish called $id\n"; + session_write_close(); + } + public function write($id, $data) { + echo "(#$this->num) writing $id = $data\n"; + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + echo "(#$this->num) closing $id\n"; + return parent::close(); + } +} + +$handler = new MySession(1); +session_set_save_handler($handler); +session_start(); + +$_SESSION['foo'] = 'bar'; + +// explicit close +$handler->finish(); + +echo "done\n"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : manual shutdown *** +(#1) constructor called +(#1) finish called %s +(#1) writing %s = foo|s:3:"bar"; +(#1) closing %s +done +(#1) destructor called diff --git a/ext/session/tests/session_set_save_handler_class_009.phpt b/ext/session/tests/session_set_save_handler_class_009.phpt new file mode 100644 index 000000000..a8b57dc54 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_009.phpt @@ -0,0 +1,62 @@ +--TEST-- +Test session_set_save_handler() : implicit shutdown +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : implicit shutdown ***\n"; + +class MySession extends SessionHandler { + public $num; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + } + public function finish() { + $id = session_id(); + echo "(#$this->num) finish called $id\n"; + $this->shutdown(); + } + public function write($id, $data) { + echo "(#$this->num) writing $id = $data\n"; + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + echo "(#$this->num) closing $id\n"; + return parent::close(); + } +} + +$handler = new MySession(1); +session_set_save_handler($handler); +session_start(); + +$_SESSION['foo'] = 'bar'; + +// implicit close +echo "done\n"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : implicit shutdown *** +(#1) constructor called +done +(#1) writing %s = foo|s:3:"bar"; +(#1) closing %s +(#1) destructor called diff --git a/ext/session/tests/session_set_save_handler_class_010.phpt b/ext/session/tests/session_set_save_handler_class_010.phpt new file mode 100644 index 000000000..02304f497 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_010.phpt @@ -0,0 +1,63 @@ +--TEST-- +Test session_set_save_handler() : manual shutdown function +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : manual shutdown function ***\n"; + +class MySession extends SessionHandler { + public $num; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + } + public function finish() { + $id = session_id(); + echo "(#$this->num) finish called $id\n"; + session_write_close(); + } + public function write($id, $data) { + echo "(#$this->num) writing $id = $data\n"; + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + echo "(#$this->num) closing $id\n"; + return parent::close(); + } +} + +$handler = new MySession(1); +session_set_save_handler($handler, false); +register_shutdown_function(array($handler, 'finish')); +session_start(); + +$_SESSION['foo'] = 'bar'; + +echo "done\n"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : manual shutdown function *** +(#1) constructor called +done +(#1) finish called %s +(#1) writing %s = foo|s:3:"bar"; +(#1) closing %s +(#1) destructor called diff --git a/ext/session/tests/session_set_save_handler_class_011.phpt b/ext/session/tests/session_set_save_handler_class_011.phpt new file mode 100644 index 000000000..7fa365769 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_011.phpt @@ -0,0 +1,66 @@ +--TEST-- +Test session_set_save_handler() : shutdown failure +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : shutdown failure ***\n"; + +class MySession extends SessionHandler { + public $num; + public $destroyed = false; + public function __construct($num) { + $this->num = $num; + echo "(#$this->num) constructor called\n"; + } + public function __destruct() { + echo "(#$this->num) destructor called\n"; + $this->destroyed = true; + } + public function write($id, $data) { + if ($this->destroyed) { + echo "(#$this->num) destroyed, cannot write\n"; + } else { + echo "(#$this->num) writing $id = $data\n"; + } + return parent::write($id, $data); + } + public function close() { + $id = session_id(); + if ($this->destroyed) { + echo "(#$this->num) destroyed, cannot write\n"; + } else { + echo "(#$this->num) closing $id\n"; + } + return parent::close(); + } +} + +$handler = new MySession(1); +session_set_save_handler($handler, false); +session_start(); + +$_SESSION['foo'] = 'bar'; + +echo "done\n"; +ob_end_flush(); +?> +--EXPECTF-- +*** Testing session_set_save_handler() : shutdown failure *** +(#1) constructor called +done +(#1) destructor called +(#1) destroyed, cannot write +(#1) destroyed, cannot write diff --git a/ext/session/tests/session_set_save_handler_class_012.phpt b/ext/session/tests/session_set_save_handler_class_012.phpt new file mode 100644 index 000000000..706ef793e --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_012.phpt @@ -0,0 +1,59 @@ +--TEST-- +Test session_set_save_handler() : incorrect arguments for existing handler open +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : incorrect arguments for existing handler open ***\n"; + +class MySession extends SessionHandler { + public $i = 0; + public function open($path, $name) { + ++$this->i; + echo 'Open ', session_id(), "\n"; + return parent::open(); + } + public function read($key) { + ++$this->i; + echo 'Read ', session_id(), "\n"; + return parent::read($key); + } +} + +$oldHandler = ini_get('session.save_handler'); +$handler = new MySession; +session_set_save_handler($handler); +session_start(); + +var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i, $_SESSION); + +--EXPECTF-- +*** Testing session_set_save_handler() : incorrect arguments for existing handler open *** +Open + +Warning: SessionHandler::open() expects exactly 2 parameters, 0 given in %s on line %d +Read %s + +Warning: SessionHandler::read(): Parent session handler is not open in %s on line %d +string(%d) "%s" +string(5) "files" +string(4) "user" +int(2) +array(0) { +} + +Warning: Unknown: Parent session handler is not open in Unknown on line 0 + +Warning: Unknown: Parent session handler is not open in Unknown on line 0 diff --git a/ext/session/tests/session_set_save_handler_class_013.phpt b/ext/session/tests/session_set_save_handler_class_013.phpt new file mode 100644 index 000000000..f536aa72a --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_013.phpt @@ -0,0 +1,56 @@ +--TEST-- +Test session_set_save_handler() : incorrect arguments for existing handler close +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : incorrect arguments for existing handler close ***\n"; + +class MySession extends SessionHandler { + public $i = 0; + public function open($path, $name) { + ++$this->i; + echo 'Open ', session_id(), "\n"; + return parent::open($path, $name); + } + public function read($key) { + ++$this->i; + echo 'Read ', session_id(), "\n"; + return parent::read($key); + } + public function close() { + return parent::close(false); + } +} + +$oldHandler = ini_get('session.save_handler'); +$handler = new MySession; +session_set_save_handler($handler); +session_start(); + +var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i, $_SESSION); + +--EXPECTF-- +*** Testing session_set_save_handler() : incorrect arguments for existing handler close *** +Open +Read %s +string(%d) "%s" +string(5) "files" +string(4) "user" +int(2) +array(0) { +} + +Warning: SessionHandler::close() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/session/tests/session_set_save_handler_class_014.phpt b/ext/session/tests/session_set_save_handler_class_014.phpt new file mode 100644 index 000000000..ea62beb0f --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_014.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test session_set_save_handler() : calling default handler when save_handler=user +--INI-- +session.save_handler=user +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : calling default handler when save_handler=user ***\n"; + +$oldHandler = ini_get('session.save_handler'); +$handler = new SessionHandler; +session_set_save_handler($handler); + +session_start(); + +--EXPECTF-- +*** Testing session_set_save_handler() : calling default handler when save_handler=user *** + +Fatal error: SessionHandler::open(): Cannot call default session handler in %s on line %d diff --git a/ext/session/tests/session_set_save_handler_class_015.phpt b/ext/session/tests/session_set_save_handler_class_015.phpt new file mode 100644 index 000000000..3bef51be4 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_class_015.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test session_set_save_handler() : register session handler but don't start +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandler $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() : register session handler but don't start ***\n"; + +session_set_save_handler(new SessionHandler); + +--EXPECTF-- +*** Testing session_set_save_handler() : register session handler but don't start *** diff --git a/ext/session/tests/session_set_save_handler_iface_001.phpt b/ext/session/tests/session_set_save_handler_iface_001.phpt new file mode 100644 index 000000000..c8199ffe3 --- /dev/null +++ b/ext/session/tests/session_set_save_handler_iface_001.phpt @@ -0,0 +1,113 @@ +--TEST-- +Test session_set_save_handler() function: interface +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandlerInterface $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() function: interface ***\n"; + +class MySession2 implements SessionHandlerInterface { + public $path; + + public function open($path, $name) { + if (!$path) { + $path = '/tmp'; + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return @file_get_contents($this->path . $id); + } + + public function write($id, $data) { + return file_put_contents($this->path . $id, $data); + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } +} + +$handler = new MySession2; +session_set_save_handler(array($handler, 'open'), array($handler, 'close'), + array($handler, 'read'), array($handler, 'write'), array($handler, 'destroy'), array($handler, 'gc')); +session_start(); + +$_SESSION['foo'] = "hello"; + +var_dump(session_id(), ini_get('session.save_handler'), $_SESSION); + +session_write_close(); +session_unset(); + +session_start(); +var_dump($_SESSION); + +session_write_close(); +session_unset(); + +session_set_save_handler($handler); +session_start(); + +$_SESSION['foo'] = "hello"; + +var_dump(session_id(), ini_get('session.save_handler'), $_SESSION); + +session_write_close(); +session_unset(); + +session_start(); +var_dump($_SESSION); + +session_write_close(); +session_unset(); + +--EXPECTF-- +*** Testing session_set_save_handler() function: interface *** +string(%d) "%s" +string(4) "user" +array(1) { + ["foo"]=> + string(5) "hello" +} +array(1) { + ["foo"]=> + string(5) "hello" +} +string(%d) "%s" +string(4) "user" +array(1) { + ["foo"]=> + string(5) "hello" +} +array(1) { + ["foo"]=> + string(5) "hello" +} diff --git a/ext/session/tests/session_set_save_handler_iface_002.phpt b/ext/session/tests/session_set_save_handler_iface_002.phpt new file mode 100644 index 000000000..42e8fbe3f --- /dev/null +++ b/ext/session/tests/session_set_save_handler_iface_002.phpt @@ -0,0 +1,90 @@ +--TEST-- +Test session_set_save_handler() function: interface wrong +--INI-- +session.save_handler=files +session.name=PHPSESSID +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +/* + * Prototype : bool session_set_save_handler(SessionHandlerInterface $handler [, bool $register_shutdown_function = true]) + * Description : Sets user-level session storage functions + * Source code : ext/session/session.c + */ + +echo "*** Testing session_set_save_handler() function: interface wrong ***\n"; + +interface MySessionHandlerInterface { + public function open($path, $name); + public function close(); + public function read($id); + public function write($id, $data); + public function destroy($id); + public function gc($maxlifetime); +} + +class MySession2 implements MySessionHandlerInterface { + public $path; + + public function open($path, $name) { + if (!$path) { + $path = '/tmp'; + } + $this->path = $path . '/u_sess_' . $name; + return true; + } + + public function close() { + return true; + } + + public function read($id) { + return @file_get_contents($this->path . $id); + } + + public function write($id, $data) { + echo "Unsupported session handler in use\n"; + } + + public function destroy($id) { + @unlink($this->path . $id); + } + + public function gc($maxlifetime) { + foreach (glob($this->path . '*') as $filename) { + if (filemtime($filename) + $maxlifetime < time()) { + @unlink($filename); + } + } + return true; + } +} + +function good_write($id, $data) { + global $handler; + echo "good handler writing\n"; + return file_put_contents($handler->path . $id, $data); +} + +$handler = new MySession2; + +$ret = session_set_save_handler(array($handler, 'open'), array($handler, 'close'), + array($handler, 'read'), 'good_write', array($handler, 'destroy'), array($handler, 'gc')); + +var_dump($ret); +$ret = session_set_save_handler($handler); +var_dump($ret); + +session_start(); + +--EXPECTF-- +*** Testing session_set_save_handler() function: interface wrong *** +bool(true) + +Warning: session_set_save_handler() expects parameter 1 to be SessionHandlerInterface, object given in %s +bool(false) +good handler writing diff --git a/ext/session/tests/session_status.phpt b/ext/session/tests/session_status.phpt new file mode 100644 index 000000000..d1f7e2f38 --- /dev/null +++ b/ext/session/tests/session_status.phpt @@ -0,0 +1,24 @@ +--TEST-- +Test session_status() function : active, none +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ob_start(); + +echo "*** Testing session_status() : active, none\n"; + +var_dump(PHP_SESSION_NONE != PHP_SESSION_ACTIVE); +var_dump(session_status() == PHP_SESSION_NONE); + +session_start(); + +var_dump(session_status() == PHP_SESSION_ACTIVE); + +?> +--EXPECTF-- +*** Testing session_status() : active, none +bool(true) +bool(true) +bool(true) diff --git a/ext/session/tests/session_status_disabled.phpt b/ext/session/tests/session_status_disabled.phpt new file mode 100644 index 000000000..24e0ecd7b --- /dev/null +++ b/ext/session/tests/session_status_disabled.phpt @@ -0,0 +1,17 @@ +--TEST-- +Test session_status() function : disabled +--SKIPIF-- +<?php include('skipif.inc'); ?> +--INI-- +session.save_handler=non-existant +--FILE-- +<?php + +echo "*** Testing session_status() : disabled\n"; + +var_dump(session_status() == PHP_SESSION_DISABLED); + +?> +--EXPECTF-- +*** Testing session_status() : disabled +bool(true) diff --git a/ext/session/tests/session_unregister_basic.phpt b/ext/session/tests/session_unregister_basic.phpt deleted file mode 100644 index 15ebb7dd2..000000000 --- a/ext/session/tests/session_unregister_basic.phpt +++ /dev/null @@ -1,225 +0,0 @@ ---TEST-- -Test session_unregister() function : basic functionality ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_unregister(string $name) - * Description : Unregister a global variable from the current session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_unregister() : basic functionality ***\n"; - -// Get an unset variable -$unset_var = 10; -unset($unset_var); - -class classA -{ - public function __toString() { - return "Hello World!"; - } -} - -$heredoc = <<<EOT -Hello World! -EOT; - -$fp = fopen(__FILE__, "r"); - -// Unexpected values to be passed as arguments -$inputs = array( - - // Integer data -/*1*/ 0, - 1, - 12345, - -2345, - - // Float data -/*5*/ 10.5, - -10.5, - 12.3456789000e10, - 12.3456789000E-10, - .5, - - // Null data -/*10*/ NULL, - null, - - // Boolean data -/*12*/ true, - false, - TRUE, - FALSE, - - // Empty strings -/*16*/ "", - '', - - // Invalid string data -/*18*/ "Nothing", - 'Nothing', - $heredoc, - - // Object data -/*21*/ new classA(), - - // Undefined data -/*22*/ @$undefined_var, - - // Unset data -/*23*/ @$unset_var, - - // Resource variable -/*24*/ $fp -); - - -var_dump(session_start()); - -$iterator = 1; -foreach($inputs as $input) { - echo "\n-- Iteration $iterator --\n"; - var_dump(session_unregister($input)); - $iterator++; -}; - -var_dump(session_destroy()); - -fclose($fp); -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_unregister() : basic functionality *** -bool(true) - --- Iteration 1 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 2 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 3 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 4 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 5 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 6 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 7 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 8 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 9 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 10 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 11 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 12 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 13 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 14 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 15 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 16 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 17 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 18 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 19 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 20 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 21 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 22 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 23 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) - --- Iteration 24 -- - -Deprecated: Function session_unregister() is deprecated in %s on line %d - -Warning: session_unregister() expects parameter 1 to be string, resource given in %s on line %d -NULL -bool(true) -Done diff --git a/ext/session/tests/session_unregister_variation1.phpt b/ext/session/tests/session_unregister_variation1.phpt deleted file mode 100644 index 609a05163..000000000 --- a/ext/session/tests/session_unregister_variation1.phpt +++ /dev/null @@ -1,159 +0,0 @@ ---TEST-- -Test session_unregister() function : variation ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_unregister(string $name) - * Description : Unregister a global variable from the current session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_unregister() : variation ***\n"; - -// Get an unset variable -$unset_var = 10; -unset($unset_var); - -class classA -{ - public function __toString() { - return "Hello World!"; - } -} - -$heredoc = <<<EOT -Hello World! -EOT; - -$fp = fopen(__FILE__, "r"); - -// Unexpected values to be passed as arguments -$inputs = array( - - // Integer data -/*1*/ 0, - 1, - 12345, - -2345, - - // Float data -/*5*/ 10.5, - -10.5, - 12.3456789000e10, - 12.3456789000E-10, - .5, - - // Null data -/*10*/ NULL, - null, - - // Boolean data -/*12*/ true, - false, - TRUE, - FALSE, - - // Empty strings -/*16*/ "", - '', - - // Invalid string data -/*18*/ "Nothing", - 'Nothing', - $heredoc, - - // Object data -/*21*/ new classA(), - - // Undefined data -/*22*/ @$undefined_var, - - // Unset data -/*23*/ @$unset_var, - - // Resource variable -/*24*/ $fp -); - -var_dump(session_start()); -var_dump($_SESSION); -var_dump(session_register($inputs)); -var_dump($_SESSION); -var_dump(session_destroy()); -var_dump($_SESSION); - -fclose($fp); -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_unregister() : variation *** -bool(true) -array(0) { -} - -Deprecated: Function session_register() is deprecated in %s on line %d -bool(true) -array(13) { - ["0"]=> - NULL - ["1"]=> - NULL - ["12345"]=> - NULL - ["-2345"]=> - NULL - ["10.5"]=> - NULL - ["-10.5"]=> - NULL - ["123456789000"]=> - NULL - ["1.23456789E-9"]=> - NULL - ["0.5"]=> - NULL - [""]=> - NULL - ["Nothing"]=> - NULL - ["Hello World!"]=> - NULL - ["Resource id #%d"]=> - NULL -} -bool(true) -array(13) { - ["0"]=> - NULL - ["1"]=> - NULL - ["12345"]=> - NULL - ["-2345"]=> - NULL - ["10.5"]=> - NULL - ["-10.5"]=> - NULL - ["123456789000"]=> - NULL - ["1.23456789E-9"]=> - NULL - ["0.5"]=> - NULL - [""]=> - NULL - ["Nothing"]=> - NULL - ["Hello World!"]=> - NULL - ["Resource id #%d"]=> - NULL -} -Done diff --git a/ext/session/tests/session_unregister_variation2.phpt b/ext/session/tests/session_unregister_variation2.phpt deleted file mode 100644 index 19cf4d5e6..000000000 --- a/ext/session/tests/session_unregister_variation2.phpt +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -Test session_unregister() function : variation ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_unregister(string $name) - * Description : Unregister a global variable from the current session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_unregister() : variation ***\n"; - -var_dump(session_start()); -var_dump($_SESSION); -$_SESSION["foo"] = "Hello World!"; -var_dump($_SESSION); -var_dump(session_unregister("foo")); -var_dump($_SESSION); -var_dump(session_destroy()); -var_dump($_SESSION); - -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_unregister() : variation *** -bool(true) -array(0) { -} -array(1) { - ["foo"]=> - string(12) "Hello World!" -} - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) -array(0) { -} -bool(true) -array(0) { -} -Done diff --git a/ext/session/tests/session_unregister_variation3.phpt b/ext/session/tests/session_unregister_variation3.phpt deleted file mode 100644 index 7933b0878..000000000 --- a/ext/session/tests/session_unregister_variation3.phpt +++ /dev/null @@ -1,48 +0,0 @@ ---TEST-- -Test session_unregister() function : variation ---SKIPIF-- -<?php include('skipif.inc'); ?> ---FILE-- -<?php - -ob_start(); - -/* - * Prototype : bool session_unregister(string $name) - * Description : Unregister a global variable from the current session - * Source code : ext/session/session.c - */ - -echo "*** Testing session_unregister() : variation ***\n"; - -var_dump(session_start()); -var_dump($_SESSION); -$blah = "Hello World!"; -$_SESSION["foo"] = &$blah; -var_dump($_SESSION); -var_dump(session_unregister("foo")); -var_dump($_SESSION); -var_dump(session_destroy()); -var_dump($_SESSION); - -echo "Done"; -ob_end_flush(); -?> ---EXPECTF-- -*** Testing session_unregister() : variation *** -bool(true) -array(0) { -} -array(1) { - ["foo"]=> - &string(12) "Hello World!" -} - -Deprecated: Function session_unregister() is deprecated in %s on line %d -bool(true) -array(0) { -} -bool(true) -array(0) { -} -Done diff --git a/ext/session/tests/sessionhandler_open_001.phpt b/ext/session/tests/sessionhandler_open_001.phpt new file mode 100644 index 000000000..6ade9e00a --- /dev/null +++ b/ext/session/tests/sessionhandler_open_001.phpt @@ -0,0 +1,19 @@ +--TEST-- +Testing repated SessionHandler::open() calls +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php + +ini_set('session.save_handler', 'files'); +$x = new SessionHandler; +$x->open('',''); +$x->open('',''); +$x->open('',''); +$x->open('',''); + +print "Done!\n"; + +?> +--EXPECTF-- +Done! |