File php-5.1.2-zend_ini.patch of Package php
--- Zend/zend_ini.c 2006/05/15 14:53:47 1.46
+++ Zend/zend_ini.c 2006/05/19 15:39:36 1.47
@@ -120,6 +120,7 @@
{
zend_ini_entry ini_entry;
+ EG(modified_ini_directives) = NULL;
EG(ini_directives) = (HashTable *) malloc(sizeof(HashTable));
if (zend_hash_init_ex(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, NULL, 1, 0)==FAILURE) {
return FAILURE;
--- Zend/zend_ini.c 2006/01/04 23:53:04 1.39.2.2
+++ Zend/zend_ini.c 2006/05/15 14:52:35 1.39.2.2.2.1
@@ -65,6 +65,12 @@
return 0;
}
+static int zend_restore_ini_entry_wrapper(zend_ini_entry **ini_entry TSRMLS_DC)
+{
+ zend_restore_ini_entry_cb(*ini_entry, ZEND_INI_STAGE_DEACTIVATE TSRMLS_CC);
+ return 1;
+}
+
/*
* Startup / shutdown
*/
@@ -73,6 +79,7 @@
registered_zend_ini_directives = (HashTable *) malloc(sizeof(HashTable));
EG(ini_directives) = registered_zend_ini_directives;
+ EG(modified_ini_directives) = NULL;
if (zend_hash_init_ex(registered_zend_ini_directives, 100, NULL, NULL, 1, 0)==FAILURE) {
return FAILURE;
}
@@ -98,7 +105,12 @@
ZEND_API int zend_ini_deactivate(TSRMLS_D)
{
- zend_hash_apply_with_argument(EG(ini_directives), (apply_func_arg_t) zend_restore_ini_entry_cb, (void *) ZEND_INI_STAGE_DEACTIVATE TSRMLS_CC);
+ if (EG(modified_ini_directives)) {
+ zend_hash_apply(EG(modified_ini_directives), (apply_func_t) zend_restore_ini_entry_wrapper TSRMLS_CC);
+ zend_hash_destroy(EG(modified_ini_directives));
+ FREE_HASHTABLE(EG(modified_ini_directives));
+ EG(modified_ini_directives) = NULL;
+ }
return SUCCESS;
}
@@ -237,12 +249,17 @@
if (!ini_entry->modified) {
ini_entry->orig_value = ini_entry->value;
ini_entry->orig_value_length = ini_entry->value_length;
+ ini_entry->modified = 1;
+ if (!EG(modified_ini_directives)) {
+ ALLOC_HASHTABLE(EG(modified_ini_directives));
+ zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, 0);
+ }
+ zend_hash_add(EG(modified_ini_directives), name, name_length, &ini_entry, sizeof(zend_ini_entry*), NULL);
} else { /* we already changed the value, free the changed value */
efree(ini_entry->value);
}
ini_entry->value = duplicate;
ini_entry->value_length = new_value_length;
- ini_entry->modified = 1;
} else {
efree(duplicate);
}
@@ -260,7 +277,11 @@
return FAILURE;
}
- zend_restore_ini_entry_cb(ini_entry, stage TSRMLS_CC);
+ if (EG(modified_ini_directives)) {
+ zend_restore_ini_entry_cb(ini_entry, stage TSRMLS_CC);
+ zend_hash_del(EG(modified_ini_directives), name, name_length);
+ }
+
return SUCCESS;
}
--- Zend/zend_globals.h 2006/05/09 23:53:23 1.141.2.3.2.1
+++ Zend/zend_globals.h 2006/05/15 14:52:35 1.141.2.3.2.2
@@ -227,6 +227,8 @@
int lambda_count;
HashTable *ini_directives;
+ HashTable *modified_ini_directives;
+
zend_objects_store objects_store;
zval *exception;
zend_op *opline_before_exception;