]> granicus.if.org Git - php/commitdiff
Allow the INI callbacks to know at what stage PHP is
authorZeev Suraski <zeev@php.net>
Sat, 26 Feb 2000 15:36:23 +0000 (15:36 +0000)
committerZeev Suraski <zeev@php.net>
Sat, 26 Feb 2000 15:36:23 +0000 (15:36 +0000)
ext/standard/basic_functions.c
main/configuration-parser.y
main/main.c
main/php_ini.c
main/php_ini.h
sapi/cgi/cgi_main.c
win32/registry.c

index 38a92857d407059b5c71fe463a04870976aa8061..24cd046a09a0105178aafe81eff83353a97af9bf 100644 (file)
@@ -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);
 }
 
 
index b5db10b03c27f36d6080fefcfdf3b51db80bf8cb..c31b2751bc8a106af4dd85e2f0e263a53509d3e9 100644 (file)
@@ -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) {
index e21fa781ba149ed0f3ff989d58ba09d292b53b67..981b2adcede06a43131b02c732997cbf81fa1270 100644 (file)
@@ -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
 
index cfd6f97058fe07e20838a463bd9c6b80a1d225c5..a49a3c9e28f7d2f142b47258d5e0457060b4624a 100644 (file)
@@ -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;
 }
 
index f8266e802e427e8b8074cb28c0383a335bb3924e..58fbd539ff6f7eff5bc451ac85f79850425a440f 100644 (file)
@@ -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 */
index 459b5cbf66feb3421a71871ba5369dcbaa8ece38..3b44e4d1e7ce047ef4c02f38f9cb850ff8e7e2f2 100644 (file)
@@ -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);
 }
 
 
index 2d098a14a0b6272c011de3a17a7d2471917a2e2d..66ce5380d504f000128da985ddca2ec544f19764 100644 (file)
@@ -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);