summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeev Suraski <zeev@php.net>2000-02-26 15:36:23 +0000
committerZeev Suraski <zeev@php.net>2000-02-26 15:36:23 +0000
commit1261271839aa515a30685ccf1fba5d0b3811b866 (patch)
treec977cb48c69a5ad9693396b863ecba803d5d3872
parentfd344d36026b0f9d8f91be968284b4755d9eed76 (diff)
downloadphp-git-1261271839aa515a30685ccf1fba5d0b3811b866.tar.gz
Allow the INI callbacks to know at what stage PHP is
-rw-r--r--ext/standard/basic_functions.c4
-rw-r--r--main/configuration-parser.y2
-rw-r--r--main/main.c2
-rw-r--r--main/php_ini.c28
-rw-r--r--main/php_ini.h14
-rw-r--r--sapi/cgi/cgi_main.c2
-rw-r--r--win32/registry.c2
7 files changed, 30 insertions, 24 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 38a92857d4..24cd046a09 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -1338,7 +1338,7 @@ PHP_FUNCTION(ini_set)
old_value = php_ini_string((*varname)->value.str.val, (*varname)->value.str.len+1, 0);
- if (php_alter_ini_entry((*varname)->value.str.val, (*varname)->value.str.len+1, (*new_value)->value.str.val, (*new_value)->value.str.len, PHP_INI_USER)==FAILURE) {
+ if (php_alter_ini_entry((*varname)->value.str.val, (*varname)->value.str.len+1, (*new_value)->value.str.val, (*new_value)->value.str.len, PHP_INI_USER, PHP_INI_STAGE_RUNTIME)==FAILURE) {
RETURN_FALSE;
}
if (old_value) {
@@ -1360,7 +1360,7 @@ PHP_FUNCTION(ini_restore)
convert_to_string_ex(varname);
- php_restore_ini_entry((*varname)->value.str.val, (*varname)->value.str.len);
+ php_restore_ini_entry((*varname)->value.str.val, (*varname)->value.str.len, PHP_INI_STAGE_RUNTIME);
}
diff --git a/main/configuration-parser.y b/main/configuration-parser.y
index b5db10b03c..c31b2751bc 100644
--- a/main/configuration-parser.y
+++ b/main/configuration-parser.y
@@ -410,7 +410,7 @@ statement:
if (parsing_mode==PARSING_MODE_CFG) {
zend_hash_update(active_hash_table, $1.value.str.val, $1.value.str.len+1, &$3, sizeof(zval), NULL);
if (active_hash_table == &configuration_hash) {
- php_alter_ini_entry($1.value.str.val, $1.value.str.len+1, $3.value.str.val, $3.value.str.len+1, PHP_INI_SYSTEM);
+ php_alter_ini_entry($1.value.str.val, $1.value.str.len+1, $3.value.str.val, $3.value.str.len+1, PHP_INI_SYSTEM, PHP_INI_STAGE_STARTUP);
}
} else if (parsing_mode==PARSING_MODE_BROWSCAP) {
if (current_section) {
diff --git a/main/main.c b/main/main.c
index e21fa781ba..981b2adced 100644
--- a/main/main.c
+++ b/main/main.c
@@ -690,7 +690,7 @@ static int php_body_write_wrapper(const char *str, uint str_length)
#ifdef ZTS
static void php_new_thread_end_handler(THREAD_T thread_id)
{
- php_ini_refresh_caches();
+ php_ini_refresh_caches(PHP_INI_STAGE_STARTUP);
}
#endif
diff --git a/main/php_ini.c b/main/php_ini.c
index cfd6f97058..a49a3c9e28 100644
--- a/main/php_ini.c
+++ b/main/php_ini.c
@@ -41,11 +41,11 @@ static int php_remove_ini_entries(php_ini_entry *ini_entry, int *module_number)
}
-static int php_restore_ini_entry_cb(php_ini_entry *ini_entry)
+static int php_restore_ini_entry_cb(php_ini_entry *ini_entry, int stage)
{
if (ini_entry->modified) {
if (ini_entry->on_modify) {
- ini_entry->on_modify(ini_entry, ini_entry->orig_value, ini_entry->orig_value_length, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3);
+ ini_entry->on_modify(ini_entry, ini_entry->orig_value, ini_entry->orig_value_length, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage);
}
efree(ini_entry->value);
ini_entry->value = ini_entry->orig_value;
@@ -78,7 +78,7 @@ int php_ini_mshutdown()
int php_ini_rshutdown()
{
- zend_hash_apply(&known_directives, (int (*)(void *)) php_restore_ini_entry_cb);
+ zend_hash_apply_with_argument(&known_directives, (int (*)(void *, void *)) php_restore_ini_entry_cb, (void *) PHP_INI_STAGE_DEACTIVATE);
return SUCCESS;
}
@@ -99,17 +99,17 @@ PHPAPI int php_register_ini_entries(php_ini_entry *ini_entry, int module_number)
return FAILURE;
}
if (hashed_ini_entry->on_modify) {
- hashed_ini_entry->on_modify(hashed_ini_entry, hashed_ini_entry->value, hashed_ini_entry->value_length, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3);
+ hashed_ini_entry->on_modify(hashed_ini_entry, hashed_ini_entry->value, hashed_ini_entry->value_length, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3, PHP_INI_STAGE_STARTUP);
}
if ((default_value=cfg_get_entry(p->name, p->name_length))) {
if (!hashed_ini_entry->on_modify
- || hashed_ini_entry->on_modify(hashed_ini_entry, default_value->value.str.val, default_value->value.str.len, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3)==SUCCESS) {
+ || hashed_ini_entry->on_modify(hashed_ini_entry, default_value->value.str.val, default_value->value.str.len, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3, PHP_INI_STAGE_STARTUP)==SUCCESS) {
hashed_ini_entry->value = default_value->value.str.val;
hashed_ini_entry->value_length = default_value->value.str.len;
}
} else {
if (hashed_ini_entry->on_modify) {
- hashed_ini_entry->on_modify(hashed_ini_entry, hashed_ini_entry->value, hashed_ini_entry->value_length, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3);
+ hashed_ini_entry->on_modify(hashed_ini_entry, hashed_ini_entry->value, hashed_ini_entry->value_length, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3, PHP_INI_STAGE_STARTUP);
}
}
hashed_ini_entry->modified = 0;
@@ -125,22 +125,22 @@ PHPAPI void php_unregister_ini_entries(int module_number)
}
-static int php_ini_refresh_cache(php_ini_entry *p)
+static int php_ini_refresh_cache(php_ini_entry *p, int stage)
{
if (p->on_modify) {
- p->on_modify(p, p->value, p->value_length, p->mh_arg1, p->mh_arg2, p->mh_arg3);
+ p->on_modify(p, p->value, p->value_length, p->mh_arg1, p->mh_arg2, p->mh_arg3, stage);
}
return 0;
}
-PHPAPI void php_ini_refresh_caches()
+PHPAPI void php_ini_refresh_caches(int stage)
{
- zend_hash_apply(&known_directives, (int (*)(void *)) php_ini_refresh_cache);
+ zend_hash_apply_with_argument(&known_directives, (int (*)(void *, void *)) php_ini_refresh_cache, (void *) stage);
}
-PHPAPI int php_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type)
+PHPAPI int php_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type, int stage)
{
php_ini_entry *ini_entry;
char *duplicate;
@@ -156,7 +156,7 @@ PHPAPI int php_alter_ini_entry(char *name, uint name_length, char *new_value, ui
duplicate = estrndup(new_value, new_value_length);
if (!ini_entry->on_modify
- || ini_entry->on_modify(ini_entry, duplicate, new_value_length, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3)==SUCCESS) {
+ || ini_entry->on_modify(ini_entry, duplicate, new_value_length, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage)==SUCCESS) {
if (!ini_entry->modified) {
ini_entry->orig_value = ini_entry->value;
ini_entry->orig_value_length = ini_entry->value_length;
@@ -174,7 +174,7 @@ PHPAPI int php_alter_ini_entry(char *name, uint name_length, char *new_value, ui
}
-PHPAPI int php_restore_ini_entry(char *name, uint name_length)
+PHPAPI int php_restore_ini_entry(char *name, uint name_length, int stage)
{
php_ini_entry *ini_entry;
@@ -182,7 +182,7 @@ PHPAPI int php_restore_ini_entry(char *name, uint name_length)
return FAILURE;
}
- php_restore_ini_entry_cb(ini_entry);
+ php_restore_ini_entry_cb(ini_entry, stage);
return SUCCESS;
}
diff --git a/main/php_ini.h b/main/php_ini.h
index f8266e802e..58fbd539ff 100644
--- a/main/php_ini.h
+++ b/main/php_ini.h
@@ -27,7 +27,7 @@
typedef struct _php_ini_entry php_ini_entry;
-#define PHP_INI_MH(name) int name(php_ini_entry *entry, char *new_value, uint new_value_length, void *mh_arg1, void *mh_arg2, void *mh_arg3)
+#define PHP_INI_MH(name) int name(php_ini_entry *entry, char *new_value, uint new_value_length, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage)
#define PHP_INI_DISP(name) void name(php_ini_entry *ini_entry, int type)
struct _php_ini_entry {
@@ -57,9 +57,9 @@ int php_ini_rshutdown(void);
PHPAPI int php_register_ini_entries(php_ini_entry *ini_entry, int module_number);
PHPAPI void php_unregister_ini_entries(int module_number);
-PHPAPI void php_ini_refresh_caches(void);
-PHPAPI int php_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type);
-PHPAPI int php_restore_ini_entry(char *name, uint name_length);
+PHPAPI void php_ini_refresh_caches(int stage);
+PHPAPI int php_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type, int stage);
+PHPAPI int php_restore_ini_entry(char *name, uint name_length, int stage);
PHPAPI void display_ini_entries(zend_module_entry *module);
PHPAPI long php_ini_long(char *name, uint name_length, int orig);
@@ -147,4 +147,10 @@ PHPAPI PHP_INI_MH(OnUpdateStringUnempty);
#define PHP_INI_DISPLAY_ORIG 1
#define PHP_INI_DISPLAY_ACTIVE 2
+#define PHP_INI_STAGE_STARTUP (1<<0)
+#define PHP_INI_STAGE_SHUTDOWN (1<<1)
+#define PHP_INI_STAGE_ACTIVATE (1<<2)
+#define PHP_INI_STAGE_DEACTIVATE (1<<3)
+#define PHP_INI_STAGE_RUNTIME (1<<4)
+
#endif /* _PHP_INI_H */
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index 459b5cbf66..3b44e4d1e7 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -306,7 +306,7 @@ static void define_command_line_ini_entry(char *arg)
} else {
value = "1";
}
- php_alter_ini_entry(name, strlen(name), value, strlen(value), PHP_INI_SYSTEM);
+ php_alter_ini_entry(name, strlen(name), value, strlen(value), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
}
diff --git a/win32/registry.c b/win32/registry.c
index 2d098a14a0..66ce5380d5 100644
--- a/win32/registry.c
+++ b/win32/registry.c
@@ -63,7 +63,7 @@ void UpdateIniFromRegistry(char *path)
continue;
}
printf("%s -> %s\n", namebuf, valuebuf);
- php_alter_ini_entry(namebuf, namebuf_length+1, valuebuf, valuebuf_length+1, PHP_INI_PERDIR);
+ php_alter_ini_entry(namebuf, namebuf_length+1, valuebuf, valuebuf_length+1, PHP_INI_PERDIR, PHP_INI_STAGE_ACTIVATE);
}
RegCloseKey(hKey);