From bd58146ad664431464e42f654b58fc92270f3484 Mon Sep 17 00:00:00 2001 From: Kalle Sommer Nielsen Date: Wed, 18 Dec 2013 07:59:47 +0100 Subject: Kill another TSRMLS_FETCH() in the zend extension loading code --- main/php_ini.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'main/php_ini.c') diff --git a/main/php_ini.c b/main/php_ini.c index e9529a2d29..2bdd3ae660 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -361,7 +361,7 @@ static void php_load_zend_extension_cb(void *arg TSRMLS_DC) int length = strlen(filename); if (IS_ABSOLUTE_PATH(filename, length)) { - zend_load_extension(filename); + zend_load_extension(filename TSRMLS_CC); } else { char *libpath; char *extension_dir = INI_STR("extension_dir"); @@ -372,7 +372,7 @@ static void php_load_zend_extension_cb(void *arg TSRMLS_DC) } else { spprintf(&libpath, 0, "%s%c%s", extension_dir, DEFAULT_SLASH, filename); } - zend_load_extension(libpath); + zend_load_extension(libpath TSRMLS_CC); efree(libpath); } } -- cgit v1.2.1 From 47c902777297ce895aa915c13efdb00881af3669 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Fri, 3 Jan 2014 11:06:16 +0800 Subject: Bump year --- main/php_ini.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main/php_ini.c') diff --git a/main/php_ini.c b/main/php_ini.c index e9529a2d29..1faec6877d 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 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 | -- cgit v1.2.1 From c081ce628f0d76d44784d7bb8e06428b06142ac0 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Fri, 3 Jan 2014 11:08:10 +0800 Subject: Bump year --- main/php_ini.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main/php_ini.c') diff --git a/main/php_ini.c b/main/php_ini.c index e9529a2d29..1faec6877d 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2013 The PHP Group | + | Copyright (c) 1997-2014 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 | -- cgit v1.2.1 From da84f3af751aa9bbf76bc22924a488f981d47088 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 29 Jan 2014 09:53:22 +0100 Subject: Fixed Request #66574 Allow multiple paths in php_ini_scanned_path php_ini_scanned_path, from --with-config-file-scan-dir option or from PHP_INI_SCAN_DIR environment variable allow a single path. In some case it could be useful to allow multiple. In the proposed patch, multiple paths are allow, using syntax inspired from Unix MANPATH (: separated list, empty string for builtin value). For example, this allow to use: PHP_INI_SCAN_DIR=/foo/php.d:/bar/php.d php PHP_INI_SCAN_DIR=:/myproject/php.d php PHP_INI_SCAN_DIR=/myproject/php.d: php Real use case: in SCL for dependent collections where each collection provides a separate tree for extensions, libraries and ini files. --- main/php_ini.c | 106 +++++++++++++++++++++++++++++++++------------------------ 1 file changed, 62 insertions(+), 44 deletions(-) (limited to 'main/php_ini.c') diff --git a/main/php_ini.c b/main/php_ini.c index 1faec6877d..e20ba4ba73 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -630,63 +630,81 @@ int php_init_config(TSRMLS_D) zend_llist scanned_ini_list; zend_llist_element *element; int l, total_l = 0; + char *bufpath, *debpath, *endpath; + int lenpath; - if ((ndir = php_scandir(php_ini_scanned_path, &namelist, 0, php_alphasort)) > 0) { - zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1); - memset(&fh2, 0, sizeof(fh2)); + zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1); + memset(&fh2, 0, sizeof(fh2)); - for (i = 0; i < ndir; i++) { + bufpath = estrdup(php_ini_scanned_path); + for (debpath = bufpath ; debpath ; debpath=endpath) { + endpath = strchr(debpath, DEFAULT_DIR_SEPARATOR); + if (endpath) { + *(endpath++) = 0; + } + if (!debpath[0]) { + /* empty string means default builtin value + to allow "/foo/phd.d:" or ":/foo/php.d" */ + debpath = PHP_CONFIG_FILE_SCAN_DIR; + } + lenpath = strlen(debpath); - /* check for any file with .ini extension */ - if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) { - free(namelist[i]); - continue; - } - /* Reset active ini section */ - RESET_ACTIVE_INI_HASH(); + if (lenpath > 0 && (ndir = php_scandir(debpath, &namelist, 0, php_alphasort)) > 0) { - if (IS_SLASH(php_ini_scanned_path[php_ini_scanned_path_len - 1])) { - snprintf(ini_file, MAXPATHLEN, "%s%s", php_ini_scanned_path, namelist[i]->d_name); - } else { - snprintf(ini_file, MAXPATHLEN, "%s%c%s", php_ini_scanned_path, DEFAULT_SLASH, namelist[i]->d_name); - } - if (VCWD_STAT(ini_file, &sb) == 0) { - if (S_ISREG(sb.st_mode)) { - if ((fh2.handle.fp = VCWD_FOPEN(ini_file, "r"))) { - fh2.filename = ini_file; - fh2.type = ZEND_HANDLE_FP; - - if (zend_parse_ini_file(&fh2, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash TSRMLS_CC) == SUCCESS) { - /* Here, add it to the list of ini files read */ - l = strlen(ini_file); - total_l += l + 2; - p = estrndup(ini_file, l); - zend_llist_add_element(&scanned_ini_list, &p); + for (i = 0; i < ndir; i++) { + + /* check for any file with .ini extension */ + if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) { + free(namelist[i]); + continue; + } + /* Reset active ini section */ + RESET_ACTIVE_INI_HASH(); + + if (IS_SLASH(debpath[lenpath - 1])) { + snprintf(ini_file, MAXPATHLEN, "%s%s", debpath, namelist[i]->d_name); + } else { + snprintf(ini_file, MAXPATHLEN, "%s%c%s", debpath, DEFAULT_SLASH, namelist[i]->d_name); + } + if (VCWD_STAT(ini_file, &sb) == 0) { + if (S_ISREG(sb.st_mode)) { + if ((fh2.handle.fp = VCWD_FOPEN(ini_file, "r"))) { + fh2.filename = ini_file; + fh2.type = ZEND_HANDLE_FP; + + if (zend_parse_ini_file(&fh2, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash TSRMLS_CC) == SUCCESS) { + /* Here, add it to the list of ini files read */ + l = strlen(ini_file); + total_l += l + 2; + p = estrndup(ini_file, l); + zend_llist_add_element(&scanned_ini_list, &p); + } } } } + free(namelist[i]); } - free(namelist[i]); + free(namelist); } - free(namelist); + } + efree(bufpath); - if (total_l) { - int php_ini_scanned_files_len = (php_ini_scanned_files) ? strlen(php_ini_scanned_files) + 1 : 0; - php_ini_scanned_files = (char *) realloc(php_ini_scanned_files, php_ini_scanned_files_len + total_l + 1); - if (!php_ini_scanned_files_len) { - *php_ini_scanned_files = '\0'; - } - total_l += php_ini_scanned_files_len; - for (element = scanned_ini_list.head; element; element = element->next) { - if (php_ini_scanned_files_len) { - strlcat(php_ini_scanned_files, ",\n", total_l); - } - strlcat(php_ini_scanned_files, *(char **)element->data, total_l); - strlcat(php_ini_scanned_files, element->next ? ",\n" : "\n", total_l); + if (total_l) { + int php_ini_scanned_files_len = (php_ini_scanned_files) ? strlen(php_ini_scanned_files) + 1 : 0; + php_ini_scanned_files = (char *) realloc(php_ini_scanned_files, php_ini_scanned_files_len + total_l + 1); + if (!php_ini_scanned_files_len) { + *php_ini_scanned_files = '\0'; + } + total_l += php_ini_scanned_files_len; + for (element = scanned_ini_list.head; element; element = element->next) { + if (php_ini_scanned_files_len) { + strlcat(php_ini_scanned_files, ",\n", total_l); } + strlcat(php_ini_scanned_files, *(char **)element->data, total_l); + strlcat(php_ini_scanned_files, element->next ? ",\n" : "\n", total_l); } - zend_llist_destroy(&scanned_ini_list); } + zend_llist_destroy(&scanned_ini_list); } else { /* Make sure an empty php_ini_scanned_path ends up as NULL */ php_ini_scanned_path = NULL; -- cgit v1.2.1 From f4cfaf36e23ca47da3e352e1c60909104c059647 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 10 Feb 2014 10:04:30 +0400 Subject: Use better data structures (incomplete) --- main/php_ini.c | 81 +++++++++++++++++++++++----------------------------------- 1 file changed, 32 insertions(+), 49 deletions(-) (limited to 'main/php_ini.c') diff --git a/main/php_ini.c b/main/php_ini.c index 3bcb249f84..118743fba3 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -237,14 +237,14 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t /* All other entries are added into either configuration_hash or active ini section array */ } else { /* Store in active hash */ - zend_hash_update(active_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1) + 1, arg2, sizeof(zval), (void **) &entry); - Z_STRVAL_P(entry) = zend_strndup(Z_STRVAL_P(entry), Z_STRLEN_P(entry)); + entry = zend_hash_update(active_hash, Z_STR_P(arg1), arg2); + Z_STR_P(entry) = STR_DUP(Z_STR_P(entry), 1); } } break; case ZEND_INI_PARSER_POP_ENTRY: { - zval *option_arr; + zval option_arr; zval *find_arr; if (!arg2) { @@ -255,23 +255,19 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t /* fprintf(stdout, "ZEND_INI_PARSER_POP_ENTRY: %s[%s] = %s\n",Z_STRVAL_P(arg1), Z_STRVAL_P(arg3), Z_STRVAL_P(arg2)); */ /* If option not found in hash or is not an array -> create array, otherwise add to existing array */ - if (zend_hash_find(active_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1) + 1, (void **) &find_arr) == FAILURE || Z_TYPE_P(find_arr) != IS_ARRAY) { - option_arr = (zval *) pemalloc(sizeof(zval), 1); - INIT_PZVAL(option_arr); - Z_TYPE_P(option_arr) = IS_ARRAY; - Z_ARRVAL_P(option_arr) = (HashTable *) pemalloc(sizeof(HashTable), 1); - zend_hash_init(Z_ARRVAL_P(option_arr), 0, NULL, (dtor_func_t) config_zval_dtor, 1); - zend_hash_update(active_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1) + 1, option_arr, sizeof(zval), (void **) &find_arr); - free(option_arr); + if ((find_arr = zend_hash_find(active_hash, Z_STR_P(arg1))) == NULL || Z_TYPE_P(find_arr) != IS_ARRAY) { + ZVAL_NEW_PERSISTENT_ARR(&option_arr); + zend_hash_init(Z_ARRVAL(option_arr), 0, NULL, (dtor_func_t) config_zval_dtor, 1); + find_arr = zend_hash_update(active_hash, Z_STR_P(arg1), &option_arr); } /* arg3 is possible option offset name */ if (arg3 && Z_STRLEN_P(arg3) > 0) { - zend_symtable_update(Z_ARRVAL_P(find_arr), Z_STRVAL_P(arg3), Z_STRLEN_P(arg3) + 1, arg2, sizeof(zval), (void **) &entry); + entry = zend_symtable_update(Z_ARRVAL_P(find_arr), Z_STR_P(arg3), arg2); } else { - zend_hash_next_index_insert(Z_ARRVAL_P(find_arr), arg2, sizeof(zval), (void **) &entry); + entry = zend_hash_next_index_insert(Z_ARRVAL_P(find_arr), arg2); } - Z_STRVAL_P(entry) = zend_strndup(Z_STRVAL_P(entry), Z_STRLEN_P(entry)); + Z_STR_P(entry) = STR_DUP(Z_STR_P(entry), 1); } break; @@ -324,16 +320,12 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t } /* Search for existing entry and if it does not exist create one */ - if (zend_hash_find(target_hash, key, key_len + 1, (void **) &entry) == FAILURE) { - zval *section_arr; - - section_arr = (zval *) pemalloc(sizeof(zval), 1); - INIT_PZVAL(section_arr); - Z_TYPE_P(section_arr) = IS_ARRAY; - Z_ARRVAL_P(section_arr) = (HashTable *) pemalloc(sizeof(HashTable), 1); - zend_hash_init(Z_ARRVAL_P(section_arr), 0, NULL, (dtor_func_t) config_zval_dtor, 1); - zend_hash_update(target_hash, key, key_len + 1, section_arr, sizeof(zval), (void **) &entry); - free(section_arr); + if ((entry = zend_hash_str_find(target_hash, key, key_len)) == NULL) { + zval section_arr; + + ZVAL_NEW_PERSISTENT_ARR(§ion_arr); + zend_hash_init(Z_ARRVAL(section_arr), 0, NULL, (dtor_func_t) config_zval_dtor, 1); + entry = zend_hash_str_update(target_hash, key, key_len, §ion_arr); } active_ini_hash = Z_ARRVAL_P(entry); } @@ -598,12 +590,10 @@ int php_init_config(TSRMLS_D) { zval tmp; - Z_STRLEN(tmp) = strlen(fh.filename); - Z_STRVAL(tmp) = zend_strndup(fh.filename, Z_STRLEN(tmp)); - Z_TYPE(tmp) = IS_STRING; + ZVAL_STR(&tmp, STR_INIT(fh.filename, strlen(fh.filename), 1)); Z_SET_REFCOUNT(tmp, 0); - zend_hash_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path"), (void *) &tmp, sizeof(zval), NULL); + zend_hash_str_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path")-1, &tmp); if (php_ini_opened_path) { efree(php_ini_opened_path); } @@ -767,18 +757,17 @@ PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, Hash */ PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int stage TSRMLS_DC) { - char *str; + zend_string *str; zval *data; - uint str_len; ulong num_index; /* Walk through config hash and alter matching ini entries using the values found in the hash */ for (zend_hash_internal_pointer_reset(source_hash); - zend_hash_get_current_key_ex(source_hash, &str, &str_len, &num_index, 0, NULL) == HASH_KEY_IS_STRING; + zend_hash_get_current_key_ex(source_hash, &str, &num_index, 0, NULL) == HASH_KEY_IS_STRING; zend_hash_move_forward(source_hash) ) { - zend_hash_get_current_data(source_hash, (void **) &data); - zend_alter_ini_entry_ex(str, str_len, Z_STRVAL_P(data), Z_STRLEN_P(data), modify_type, stage, 0 TSRMLS_CC); + data = zend_hash_get_current_data(source_hash); + zend_alter_ini_entry_ex(str, Z_STRVAL_P(data), Z_STRLEN_P(data), modify_type, stage, 0 TSRMLS_CC); } } /* }}} */ @@ -824,7 +813,7 @@ PHPAPI void php_ini_activate_per_dir_config(char *path, uint path_len TSRMLS_DC) while ((ptr = strchr(ptr, '/')) != NULL) { *ptr = 0; /* Search for source array matching the path from configuration_hash */ - if (zend_hash_find(&configuration_hash, path, strlen(path) + 1, (void **) &tmp2) == SUCCESS) { + if ((tmp2 = zend_hash_str_find(&configuration_hash, path, strlen(path))) != NULL) { php_ini_activate_config(Z_ARRVAL_P(tmp2), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE TSRMLS_CC); } *ptr = '/'; @@ -850,7 +839,8 @@ PHPAPI void php_ini_activate_per_host_config(const char *host, uint host_len TSR if (has_per_host_config && host && host_len) { /* Search for source array matching the host from configuration_hash */ - if (zend_hash_find(&configuration_hash, host, host_len, (void **) &tmp) == SUCCESS) { +//??? remove -1 + if ((tmp = zend_hash_str_find(&configuration_hash, host, host_len-1)) != NULL) { php_ini_activate_config(Z_ARRVAL_P(tmp), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE TSRMLS_CC); } } @@ -861,13 +851,8 @@ PHPAPI void php_ini_activate_per_host_config(const char *host, uint host_len TSR */ PHPAPI zval *cfg_get_entry(const char *name, uint name_length) { - zval *tmp; - - if (zend_hash_find(&configuration_hash, name, name_length, (void **) &tmp) == SUCCESS) { - return tmp; - } else { - return NULL; - } +//??? remove -1 + return zend_hash_str_find(&configuration_hash, name, name_length-1); } /* }}} */ @@ -877,12 +862,11 @@ PHPAPI int cfg_get_long(const char *varname, long *result) { zval *tmp, var; - if (zend_hash_find(&configuration_hash, varname, strlen(varname) + 1, (void **) &tmp) == FAILURE) { + if ((tmp = zend_hash_str_find(&configuration_hash, varname, strlen(varname))) == NULL) { *result = 0; return FAILURE; } - var = *tmp; - zval_copy_ctor(&var); + ZVAL_DUP(&var, tmp); convert_to_long(&var); *result = Z_LVAL(var); return SUCCESS; @@ -895,12 +879,11 @@ PHPAPI int cfg_get_double(const char *varname, double *result) { zval *tmp, var; - if (zend_hash_find(&configuration_hash, varname, strlen(varname) + 1, (void **) &tmp) == FAILURE) { + if ((tmp = zend_hash_str_find(&configuration_hash, varname, strlen(varname))) == NULL) { *result = (double) 0; return FAILURE; } - var = *tmp; - zval_copy_ctor(&var); + ZVAL_DUP(&var, tmp); convert_to_double(&var); *result = Z_DVAL(var); return SUCCESS; @@ -913,7 +896,7 @@ PHPAPI int cfg_get_string(const char *varname, char **result) { zval *tmp; - if (zend_hash_find(&configuration_hash, varname, strlen(varname)+1, (void **) &tmp) == FAILURE) { + if ((tmp = zend_hash_str_find(&configuration_hash, varname, strlen(varname))) == NULL) { *result = NULL; return FAILURE; } -- cgit v1.2.1 From 2b9b9afa7a9a66f9c80013ce4121183bdff434e8 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 17 Feb 2014 17:59:18 +0400 Subject: Use better data structures (incomplete) --- main/php_ini.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'main/php_ini.c') diff --git a/main/php_ini.c b/main/php_ini.c index 118743fba3..cb68d83e65 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -193,9 +193,9 @@ PHPAPI void config_zval_dtor(zval *zvalue) { if (Z_TYPE_P(zvalue) == IS_ARRAY) { zend_hash_destroy(Z_ARRVAL_P(zvalue)); - free(Z_ARRVAL_P(zvalue)); + free(Z_ARR_P(zvalue)); } else if (Z_TYPE_P(zvalue) == IS_STRING) { - free(Z_STRVAL_P(zvalue)); + STR_RELEASE(Z_STR_P(zvalue)); } } /* Reset / free active_ini_sectin global */ @@ -591,8 +591,6 @@ int php_init_config(TSRMLS_D) zval tmp; ZVAL_STR(&tmp, STR_INIT(fh.filename, strlen(fh.filename), 1)); - Z_SET_REFCOUNT(tmp, 0); - zend_hash_str_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path")-1, &tmp); if (php_ini_opened_path) { efree(php_ini_opened_path); -- cgit v1.2.1 From 5de7115679522dec2f4725104c6f8c6e4a7bd8e4 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 18 Feb 2014 16:27:38 +0400 Subject: Use better data structures (incomplete; able to run bench.php) --- main/php_ini.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'main/php_ini.c') diff --git a/main/php_ini.c b/main/php_ini.c index cb68d83e65..0c2ccc958f 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -837,8 +837,7 @@ PHPAPI void php_ini_activate_per_host_config(const char *host, uint host_len TSR if (has_per_host_config && host && host_len) { /* Search for source array matching the host from configuration_hash */ -//??? remove -1 - if ((tmp = zend_hash_str_find(&configuration_hash, host, host_len-1)) != NULL) { + if ((tmp = zend_hash_str_find(&configuration_hash, host, host_len)) != NULL) { php_ini_activate_config(Z_ARRVAL_P(tmp), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE TSRMLS_CC); } } @@ -849,8 +848,7 @@ PHPAPI void php_ini_activate_per_host_config(const char *host, uint host_len TSR */ PHPAPI zval *cfg_get_entry(const char *name, uint name_length) { -//??? remove -1 - return zend_hash_str_find(&configuration_hash, name, name_length-1); + return zend_hash_str_find(&configuration_hash, name, name_length); } /* }}} */ -- cgit v1.2.1 From 069c158c20439c8cce8cb5087ec9da5d7477e5c3 Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Sun, 2 Mar 2014 21:31:38 +0800 Subject: Fixed php_info related --- main/php_ini.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'main/php_ini.c') diff --git a/main/php_ini.c b/main/php_ini.c index 0c2ccc958f..5fd5bfc852 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -121,22 +121,25 @@ static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type TSRMLS_DC) /* {{{ php_ini_displayer */ -static int php_ini_displayer(zend_ini_entry *ini_entry, int module_number TSRMLS_DC) +static int php_ini_displayer(zval *el, void *arg TSRMLS_DC) { + zend_ini_entry *ini_entry = (zend_ini_entry*)Z_PTR_P(el); + int module_number = *(int *)arg; + if (ini_entry->module_number != module_number) { return 0; } if (!sapi_module.phpinfo_as_text) { PUTS(""); PUTS(""); - PHPWRITE(ini_entry->name, ini_entry->name_length - 1); + PHPWRITE(ini_entry->name, ini_entry->name_length); PUTS(""); php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE TSRMLS_CC); PUTS(""); php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG TSRMLS_CC); PUTS("\n"); } else { - PHPWRITE(ini_entry->name, ini_entry->name_length - 1); + PHPWRITE(ini_entry->name, ini_entry->name_length); PUTS(" => "); php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE TSRMLS_CC); PUTS(" => "); @@ -149,10 +152,12 @@ static int php_ini_displayer(zend_ini_entry *ini_entry, int module_number TSRMLS /* {{{ php_ini_available */ -static int php_ini_available(zend_ini_entry *ini_entry, int *module_number_available TSRMLS_DC) +static int php_ini_available(zval *el, void *arg TSRMLS_DC) { - if (ini_entry->module_number == *module_number_available) { - *module_number_available = -1; + zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el); + int *module_number_available = (int *)arg; + if (ini_entry->module_number == *(int *)module_number_available) { + *(int *)module_number_available = -1; return ZEND_HASH_APPLY_STOP; } else { return ZEND_HASH_APPLY_KEEP; @@ -173,11 +178,11 @@ PHPAPI void display_ini_entries(zend_module_entry *module) module_number = 0; } module_number_available = module_number; - zend_hash_apply_with_argument(EG(ini_directives), (apply_func_arg_t) php_ini_available, &module_number_available TSRMLS_CC); + zend_hash_apply_with_argument(EG(ini_directives), php_ini_available, &module_number_available TSRMLS_CC); if (module_number_available == -1) { php_info_print_table_start(); php_info_print_table_header(3, "Directive", "Local Value", "Master Value"); - zend_hash_apply_with_argument(EG(ini_directives), (apply_func_arg_t) php_ini_displayer, (void *) (zend_intptr_t) module_number TSRMLS_CC); + zend_hash_apply_with_argument(EG(ini_directives), php_ini_displayer, (void *)&module_number TSRMLS_CC); php_info_print_table_end(); } } @@ -350,7 +355,6 @@ static void php_load_php_extension_cb(void *arg TSRMLS_DC) static void php_load_zend_extension_cb(void *arg TSRMLS_DC) { char *filename = *((char **) arg); - int length = strlen(filename); if (IS_ABSOLUTE_PATH(filename, length)) { zend_load_extension(filename TSRMLS_CC); -- cgit v1.2.1 From 76cc99fe60d1e446a0250b4d778f02bcdbd7fc09 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 3 Apr 2014 15:26:23 +0400 Subject: Refactored ZVAL flags usage to simplify various checks (e.g. Z_REFCOUNTED(), candidate for GC, etc) --- main/php_ini.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main/php_ini.c') diff --git a/main/php_ini.c b/main/php_ini.c index 5fd5bfc852..a1b2cecabc 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -594,7 +594,7 @@ int php_init_config(TSRMLS_D) { zval tmp; - ZVAL_STR(&tmp, STR_INIT(fh.filename, strlen(fh.filename), 1)); + ZVAL_NEW_STR(&tmp, STR_INIT(fh.filename, strlen(fh.filename), 1)); zend_hash_str_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path")-1, &tmp); if (php_ini_opened_path) { efree(php_ini_opened_path); -- cgit v1.2.1 From 3d17219cd88a73306acd6eeff8cbae02868318c6 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 7 Apr 2014 23:14:17 +0400 Subject: Refactored zend_hash_* iteration API zend_hash_fove_forward_ex(ht, pos) and family require second argument to be real pointer. &(ht)->nInternalPointer should be passed instead of NULL. zend_hash_update_current_key() may work only with internal pointer. --- main/php_ini.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main/php_ini.c') diff --git a/main/php_ini.c b/main/php_ini.c index a1b2cecabc..024dbe6821 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -765,7 +765,7 @@ PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int /* Walk through config hash and alter matching ini entries using the values found in the hash */ for (zend_hash_internal_pointer_reset(source_hash); - zend_hash_get_current_key_ex(source_hash, &str, &num_index, 0, NULL) == HASH_KEY_IS_STRING; + zend_hash_get_current_key(source_hash, &str, &num_index, 0) == HASH_KEY_IS_STRING; zend_hash_move_forward(source_hash) ) { data = zend_hash_get_current_data(source_hash); -- cgit v1.2.1 From 72c287bd232ef3a0dc5ae76a4b5b5879a8ee7786 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 21 Apr 2014 18:25:34 +0400 Subject: Combine HashTable.flags and HashTable.nApplyCount into single 32-bit word --- main/php_ini.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'main/php_ini.c') diff --git a/main/php_ini.c b/main/php_ini.c index 024dbe6821..ed7da808f7 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -262,7 +262,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t /* If option not found in hash or is not an array -> create array, otherwise add to existing array */ if ((find_arr = zend_hash_find(active_hash, Z_STR_P(arg1))) == NULL || Z_TYPE_P(find_arr) != IS_ARRAY) { ZVAL_NEW_PERSISTENT_ARR(&option_arr); - zend_hash_init(Z_ARRVAL(option_arr), 0, NULL, (dtor_func_t) config_zval_dtor, 1); + zend_hash_init(Z_ARRVAL(option_arr), 8, NULL, (dtor_func_t) config_zval_dtor, 1); find_arr = zend_hash_update(active_hash, Z_STR_P(arg1), &option_arr); } @@ -329,7 +329,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t zval section_arr; ZVAL_NEW_PERSISTENT_ARR(§ion_arr); - zend_hash_init(Z_ARRVAL(section_arr), 0, NULL, (dtor_func_t) config_zval_dtor, 1); + zend_hash_init(Z_ARRVAL(section_arr), 8, NULL, (dtor_func_t) config_zval_dtor, 1); entry = zend_hash_str_update(target_hash, key, key_len, §ion_arr); } active_ini_hash = Z_ARRVAL_P(entry); @@ -385,9 +385,7 @@ int php_init_config(TSRMLS_D) int free_ini_search_path = 0; zend_file_handle fh; - if (zend_hash_init(&configuration_hash, 0, NULL, (dtor_func_t) config_zval_dtor, 1) == FAILURE) { - return FAILURE; - } + zend_hash_init(&configuration_hash, 8, NULL, (dtor_func_t) config_zval_dtor, 1); if (sapi_module.ini_defaults) { sapi_module.ini_defaults(&configuration_hash); -- cgit v1.2.1 From 38c886a449a54574119a8eb1c6c5e5376acba6d8 Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Wed, 7 May 2014 07:31:21 +0200 Subject: -- missing length declaration, may have worked w/some gcc as length is not used in the macro but still need it, ifdef just make code uncertain. will get opt out anyway if not used --- main/php_ini.c | 1 + 1 file changed, 1 insertion(+) (limited to 'main/php_ini.c') diff --git a/main/php_ini.c b/main/php_ini.c index 2b62e80554..d742712758 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -355,6 +355,7 @@ static void php_load_php_extension_cb(void *arg TSRMLS_DC) static void php_load_zend_extension_cb(void *arg TSRMLS_DC) { char *filename = *((char **) arg); + const int length = strlen(filename); if (IS_ABSOLUTE_PATH(filename, length)) { zend_load_extension(filename TSRMLS_CC); -- cgit v1.2.1 From c242518bf0d2c3132c60c8f8dfba64329f73e90e Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Thu, 8 May 2014 15:20:13 +0800 Subject: There should been memory leaks(and don't use pointer cast) --- main/php_ini.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'main/php_ini.c') diff --git a/main/php_ini.c b/main/php_ini.c index d742712758..cdd4a61fb5 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -262,7 +262,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t /* If option not found in hash or is not an array -> create array, otherwise add to existing array */ if ((find_arr = zend_hash_find(active_hash, Z_STR_P(arg1))) == NULL || Z_TYPE_P(find_arr) != IS_ARRAY) { ZVAL_NEW_PERSISTENT_ARR(&option_arr); - zend_hash_init(Z_ARRVAL(option_arr), 8, NULL, (dtor_func_t) config_zval_dtor, 1); + zend_hash_init(Z_ARRVAL(option_arr), 8, NULL, config_zval_dtor, 1); find_arr = zend_hash_update(active_hash, Z_STR_P(arg1), &option_arr); } @@ -386,7 +386,7 @@ int php_init_config(TSRMLS_D) int free_ini_search_path = 0; zend_file_handle fh; - zend_hash_init(&configuration_hash, 8, NULL, (dtor_func_t) config_zval_dtor, 1); + zend_hash_init(&configuration_hash, 8, NULL, config_zval_dtor, 1); if (sapi_module.ini_defaults) { sapi_module.ini_defaults(&configuration_hash); -- cgit v1.2.1 From 8ee2a4a9b5de682c0b37670e1f4f86242b1650ce Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sat, 16 Aug 2014 11:16:11 +0200 Subject: first shot on merging the core fro the int64 branch --- main/php_ini.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'main/php_ini.c') diff --git a/main/php_ini.c b/main/php_ini.c index cdd4a61fb5..54944483d2 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -233,10 +233,10 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t /* PHP and Zend extensions are not added into configuration hash! */ if (!is_special_section && !strcasecmp(Z_STRVAL_P(arg1), PHP_EXTENSION_TOKEN)) { /* load PHP extension */ - extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2)); + extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRSIZE_P(arg2)); zend_llist_add_element(&extension_lists.functions, &extension_name); } else if (!is_special_section && !strcasecmp(Z_STRVAL_P(arg1), ZEND_EXTENSION_TOKEN)) { /* load Zend extension */ - extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2)); + extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRSIZE_P(arg2)); zend_llist_add_element(&extension_lists.engine, &extension_name); /* All other entries are added into either configuration_hash or active ini section array */ @@ -267,7 +267,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t } /* arg3 is possible option offset name */ - if (arg3 && Z_STRLEN_P(arg3) > 0) { + if (arg3 && Z_STRSIZE_P(arg3) > 0) { entry = zend_symtable_update(Z_ARRVAL_P(find_arr), Z_STR_P(arg3), arg2); } else { entry = zend_hash_next_index_insert(Z_ARRVAL_P(find_arr), arg2); @@ -287,7 +287,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t if (!strncasecmp(Z_STRVAL_P(arg1), "PATH", sizeof("PATH") - 1)) { key = Z_STRVAL_P(arg1); key = key + sizeof("PATH") - 1; - key_len = Z_STRLEN_P(arg1) - sizeof("PATH") + 1; + key_len = Z_STRSIZE_P(arg1) - sizeof("PATH") + 1; is_special_section = 1; has_per_dir_config = 1; @@ -298,7 +298,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t } else if (!strncasecmp(Z_STRVAL_P(arg1), "HOST", sizeof("HOST") - 1)) { key = Z_STRVAL_P(arg1); key = key + sizeof("HOST") - 1; - key_len = Z_STRLEN_P(arg1) - sizeof("HOST") + 1; + key_len = Z_STRSIZE_P(arg1) - sizeof("HOST") + 1; is_special_section = 1; has_per_host_config = 1; zend_str_tolower(key, key_len); /* host names are case-insensitive. */ @@ -545,7 +545,7 @@ int php_init_config(TSRMLS_D) /* Check if php_ini_file_name is a file and can be opened */ if (php_ini_file_name && php_ini_file_name[0]) { - struct stat statbuf; + php_stat_t statbuf; if (!VCWD_STAT(php_ini_file_name, &statbuf)) { if (!((statbuf.st_mode & S_IFMT) == S_IFDIR)) { @@ -598,7 +598,7 @@ int php_init_config(TSRMLS_D) if (php_ini_opened_path) { efree(php_ini_opened_path); } - php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRLEN(tmp)); + php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRSIZE(tmp)); } } @@ -614,7 +614,7 @@ int php_init_config(TSRMLS_D) if (!sapi_module.php_ini_ignore && php_ini_scanned_path_len) { struct dirent **namelist; int ndir, i; - struct stat sb; + php_stat_t sb; char ini_file[MAXPATHLEN]; char *p; zend_file_handle fh2; @@ -744,7 +744,7 @@ void php_ini_register_extensions(TSRMLS_D) */ PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash TSRMLS_DC) { - struct stat sb; + php_stat_t sb; char ini_file[MAXPATHLEN]; zend_file_handle fh; @@ -778,7 +778,7 @@ PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int { zend_string *str; zval *data; - ulong num_index; + zend_uint_t num_index; /* Walk through config hash and alter matching ini entries using the values found in the hash */ for (zend_hash_internal_pointer_reset(source_hash); @@ -786,7 +786,7 @@ PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int zend_hash_move_forward(source_hash) ) { data = zend_hash_get_current_data(source_hash); - zend_alter_ini_entry_ex(str, Z_STRVAL_P(data), Z_STRLEN_P(data), modify_type, stage, 0 TSRMLS_CC); + zend_alter_ini_entry_ex(str, Z_STRVAL_P(data), Z_STRSIZE_P(data), modify_type, stage, 0 TSRMLS_CC); } } /* }}} */ @@ -873,9 +873,9 @@ PHPAPI zval *cfg_get_entry(const char *name, uint name_length) } /* }}} */ -/* {{{ cfg_get_long +/* {{{ cfg_get_int */ -PHPAPI int cfg_get_long(const char *varname, long *result) +PHPAPI int cfg_get_int(const char *varname, zend_int_t *result) { zval *tmp, var; @@ -884,8 +884,8 @@ PHPAPI int cfg_get_long(const char *varname, long *result) return FAILURE; } ZVAL_DUP(&var, tmp); - convert_to_long(&var); - *result = Z_LVAL(var); + convert_to_int(&var); + *result = Z_IVAL(var); return SUCCESS; } /* }}} */ -- cgit v1.2.1 From c3e3c98ec666812daaaca896cf5ef758a8a6df14 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 25 Aug 2014 19:24:55 +0200 Subject: master renames phase 1 --- main/php_ini.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'main/php_ini.c') diff --git a/main/php_ini.c b/main/php_ini.c index 54944483d2..8621af24d7 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -200,7 +200,7 @@ PHPAPI void config_zval_dtor(zval *zvalue) zend_hash_destroy(Z_ARRVAL_P(zvalue)); free(Z_ARR_P(zvalue)); } else if (Z_TYPE_P(zvalue) == IS_STRING) { - STR_RELEASE(Z_STR_P(zvalue)); + zend_string_release(Z_STR_P(zvalue)); } } /* Reset / free active_ini_sectin global */ @@ -233,17 +233,17 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t /* PHP and Zend extensions are not added into configuration hash! */ if (!is_special_section && !strcasecmp(Z_STRVAL_P(arg1), PHP_EXTENSION_TOKEN)) { /* load PHP extension */ - extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRSIZE_P(arg2)); + extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2)); zend_llist_add_element(&extension_lists.functions, &extension_name); } else if (!is_special_section && !strcasecmp(Z_STRVAL_P(arg1), ZEND_EXTENSION_TOKEN)) { /* load Zend extension */ - extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRSIZE_P(arg2)); + extension_name = estrndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2)); zend_llist_add_element(&extension_lists.engine, &extension_name); /* All other entries are added into either configuration_hash or active ini section array */ } else { /* Store in active hash */ entry = zend_hash_update(active_hash, Z_STR_P(arg1), arg2); - Z_STR_P(entry) = STR_DUP(Z_STR_P(entry), 1); + Z_STR_P(entry) = zend_string_dup(Z_STR_P(entry), 1); } } break; @@ -267,12 +267,12 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t } /* arg3 is possible option offset name */ - if (arg3 && Z_STRSIZE_P(arg3) > 0) { + if (arg3 && Z_STRLEN_P(arg3) > 0) { entry = zend_symtable_update(Z_ARRVAL_P(find_arr), Z_STR_P(arg3), arg2); } else { entry = zend_hash_next_index_insert(Z_ARRVAL_P(find_arr), arg2); } - Z_STR_P(entry) = STR_DUP(Z_STR_P(entry), 1); + Z_STR_P(entry) = zend_string_dup(Z_STR_P(entry), 1); } break; @@ -287,7 +287,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t if (!strncasecmp(Z_STRVAL_P(arg1), "PATH", sizeof("PATH") - 1)) { key = Z_STRVAL_P(arg1); key = key + sizeof("PATH") - 1; - key_len = Z_STRSIZE_P(arg1) - sizeof("PATH") + 1; + key_len = Z_STRLEN_P(arg1) - sizeof("PATH") + 1; is_special_section = 1; has_per_dir_config = 1; @@ -298,7 +298,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t } else if (!strncasecmp(Z_STRVAL_P(arg1), "HOST", sizeof("HOST") - 1)) { key = Z_STRVAL_P(arg1); key = key + sizeof("HOST") - 1; - key_len = Z_STRSIZE_P(arg1) - sizeof("HOST") + 1; + key_len = Z_STRLEN_P(arg1) - sizeof("HOST") + 1; is_special_section = 1; has_per_host_config = 1; zend_str_tolower(key, key_len); /* host names are case-insensitive. */ @@ -593,12 +593,12 @@ int php_init_config(TSRMLS_D) { zval tmp; - ZVAL_NEW_STR(&tmp, STR_INIT(fh.filename, strlen(fh.filename), 1)); + ZVAL_NEW_STR(&tmp, zend_string_init(fh.filename, strlen(fh.filename), 1)); zend_hash_str_update(&configuration_hash, "cfg_file_path", sizeof("cfg_file_path")-1, &tmp); if (php_ini_opened_path) { efree(php_ini_opened_path); } - php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRSIZE(tmp)); + php_ini_opened_path = zend_strndup(Z_STRVAL(tmp), Z_STRLEN(tmp)); } } @@ -778,7 +778,7 @@ PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int { zend_string *str; zval *data; - zend_uint_t num_index; + zend_ulong num_index; /* Walk through config hash and alter matching ini entries using the values found in the hash */ for (zend_hash_internal_pointer_reset(source_hash); @@ -786,7 +786,7 @@ PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int zend_hash_move_forward(source_hash) ) { data = zend_hash_get_current_data(source_hash); - zend_alter_ini_entry_ex(str, Z_STRVAL_P(data), Z_STRSIZE_P(data), modify_type, stage, 0 TSRMLS_CC); + zend_alter_ini_entry_ex(str, Z_STRVAL_P(data), Z_STRLEN_P(data), modify_type, stage, 0 TSRMLS_CC); } } /* }}} */ @@ -873,9 +873,9 @@ PHPAPI zval *cfg_get_entry(const char *name, uint name_length) } /* }}} */ -/* {{{ cfg_get_int +/* {{{ cfg_get_long */ -PHPAPI int cfg_get_int(const char *varname, zend_int_t *result) +PHPAPI int cfg_get_long(const char *varname, zend_long *result) { zval *tmp, var; @@ -885,7 +885,7 @@ PHPAPI int cfg_get_int(const char *varname, zend_int_t *result) } ZVAL_DUP(&var, tmp); convert_to_int(&var); - *result = Z_IVAL(var); + *result = Z_LVAL(var); return SUCCESS; } /* }}} */ -- cgit v1.2.1 From 4d997f63d98c663b2d9acccd3655572652f61c7d Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 25 Aug 2014 20:22:49 +0200 Subject: master renames phase 3 --- main/php_ini.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'main/php_ini.c') diff --git a/main/php_ini.c b/main/php_ini.c index 8621af24d7..c94e412094 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -545,7 +545,7 @@ int php_init_config(TSRMLS_D) /* Check if php_ini_file_name is a file and can be opened */ if (php_ini_file_name && php_ini_file_name[0]) { - php_stat_t statbuf; + zend_stat_t statbuf; if (!VCWD_STAT(php_ini_file_name, &statbuf)) { if (!((statbuf.st_mode & S_IFMT) == S_IFDIR)) { @@ -614,7 +614,7 @@ int php_init_config(TSRMLS_D) if (!sapi_module.php_ini_ignore && php_ini_scanned_path_len) { struct dirent **namelist; int ndir, i; - php_stat_t sb; + zend_stat_t sb; char ini_file[MAXPATHLEN]; char *p; zend_file_handle fh2; @@ -744,7 +744,7 @@ void php_ini_register_extensions(TSRMLS_D) */ PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash TSRMLS_DC) { - php_stat_t sb; + zend_stat_t sb; char ini_file[MAXPATHLEN]; zend_file_handle fh; -- cgit v1.2.1 From af59e92b24c8f624672720d47ef65bd8457728b9 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 25 Aug 2014 21:51:49 +0200 Subject: master renames phase 7 --- main/php_ini.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main/php_ini.c') diff --git a/main/php_ini.c b/main/php_ini.c index c94e412094..783802c806 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -884,7 +884,7 @@ PHPAPI int cfg_get_long(const char *varname, zend_long *result) return FAILURE; } ZVAL_DUP(&var, tmp); - convert_to_int(&var); + convert_to_long(&var); *result = Z_LVAL(var); return SUCCESS; } -- cgit v1.2.1 From 88d7ca44f645c6e1bbdb17affd7a34113911093d Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 1 Sep 2014 20:57:33 +0400 Subject: Refactored INI subsystem to use zend_string* instead of char* --- main/php_ini.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'main/php_ini.c') diff --git a/main/php_ini.c b/main/php_ini.c index 783802c806..38dcf72747 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -83,9 +83,9 @@ static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type TSRMLS_DC) uint display_string_length, esc_html=0; if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) { - if (ini_entry->orig_value && ini_entry->orig_value[0]) { - display_string = ini_entry->orig_value; - display_string_length = ini_entry->orig_value_length; + if (ini_entry->orig_value && ini_entry->orig_value->val[0]) { + display_string = ini_entry->orig_value->val; + display_string_length = ini_entry->orig_value->len; esc_html = !sapi_module.phpinfo_as_text; } else { if (!sapi_module.phpinfo_as_text) { @@ -96,9 +96,9 @@ static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type TSRMLS_DC) display_string_length = sizeof("no value") - 1; } } - } else if (ini_entry->value && ini_entry->value[0]) { - display_string = ini_entry->value; - display_string_length = ini_entry->value_length; + } else if (ini_entry->value && ini_entry->value->val[0]) { + display_string = ini_entry->value->val; + display_string_length = ini_entry->value->len; esc_html = !sapi_module.phpinfo_as_text; } else { if (!sapi_module.phpinfo_as_text) { @@ -132,14 +132,14 @@ static int php_ini_displayer(zval *el, void *arg TSRMLS_DC) if (!sapi_module.phpinfo_as_text) { PUTS(""); PUTS(""); - PHPWRITE(ini_entry->name, ini_entry->name_length); + PHPWRITE(ini_entry->name->val, ini_entry->name->len); PUTS(""); php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE TSRMLS_CC); PUTS(""); php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG TSRMLS_CC); PUTS("\n"); } else { - PHPWRITE(ini_entry->name, ini_entry->name_length); + PHPWRITE(ini_entry->name->val, ini_entry->name->len); PUTS(" => "); php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE TSRMLS_CC); PUTS(" => "); @@ -355,7 +355,6 @@ static void php_load_php_extension_cb(void *arg TSRMLS_DC) static void php_load_zend_extension_cb(void *arg TSRMLS_DC) { char *filename = *((char **) arg); - const int length = strlen(filename); if (IS_ABSOLUTE_PATH(filename, length)) { zend_load_extension(filename TSRMLS_CC); @@ -786,7 +785,7 @@ PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int zend_hash_move_forward(source_hash) ) { data = zend_hash_get_current_data(source_hash); - zend_alter_ini_entry_ex(str, Z_STRVAL_P(data), Z_STRLEN_P(data), modify_type, stage, 0 TSRMLS_CC); + zend_alter_ini_entry_ex(str, Z_STR_P(data), modify_type, stage, 0 TSRMLS_CC); } } /* }}} */ @@ -865,6 +864,14 @@ PHPAPI void php_ini_activate_per_host_config(const char *host, uint host_len TSR } /* }}} */ +/* {{{ cfg_get_entry + */ +PHPAPI zval *cfg_get_entry_ex(zend_string *name) +{ + return zend_hash_find(&configuration_hash, name); +} +/* }}} */ + /* {{{ cfg_get_entry */ PHPAPI zval *cfg_get_entry(const char *name, uint name_length) -- cgit v1.2.1 From 481bf25b6ad70fcdc9c10f02b49c86a0bd4a3d0d Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Mon, 1 Sep 2014 20:34:33 +0200 Subject: restore the length var and fix the com_dotnet ini --- main/php_ini.c | 1 + 1 file changed, 1 insertion(+) (limited to 'main/php_ini.c') diff --git a/main/php_ini.c b/main/php_ini.c index 38dcf72747..b3dcd3e546 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -355,6 +355,7 @@ static void php_load_php_extension_cb(void *arg TSRMLS_DC) static void php_load_zend_extension_cb(void *arg TSRMLS_DC) { char *filename = *((char **) arg); + const int length = strlen(filename); if (IS_ABSOLUTE_PATH(filename, length)) { zend_load_extension(filename TSRMLS_CC); -- cgit v1.2.1 From d0cb715373c3fbe9dc095378ec5ed8c71f799f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Schl=C3=BCter?= Date: Fri, 19 Sep 2014 18:33:14 +0200 Subject: s/PHP 5/PHP 7/ --- main/php_ini.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'main/php_ini.c') diff --git a/main/php_ini.c b/main/php_ini.c index b3dcd3e546..c90dc9f29f 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -1,6 +1,6 @@ /* +----------------------------------------------------------------------+ - | PHP Version 5 | + | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ -- cgit v1.2.1