2323#include "zend_alloc.h"
2424#include "zend_operators.h"
2525#include "zend_strtod.h"
26+ #include "zend_modules.h"
2627
2728static HashTable * registered_zend_ini_directives ;
2829
@@ -194,7 +195,7 @@ ZEND_API void zend_ini_sort_entries(void) /* {{{ */
194195/*
195196 * Registration / unregistration
196197 */
197- ZEND_API zend_result zend_register_ini_entries (const zend_ini_entry_def * ini_entry , int module_number ) /* {{{ */
198+ ZEND_API zend_result zend_register_ini_entries_ex (const zend_ini_entry_def * ini_entry , int module_number , int module_type ) /* {{{ */
198199{
199200 zend_ini_entry * p ;
200201 zval * default_value ;
@@ -210,7 +211,10 @@ ZEND_API zend_result zend_register_ini_entries(const zend_ini_entry_def *ini_ent
210211 * lead to death.
211212 */
212213 if (directives != EG (ini_directives )) {
214+ ZEND_ASSERT (module_type == MODULE_TEMPORARY );
213215 directives = EG (ini_directives );
216+ } else {
217+ ZEND_ASSERT (module_type == MODULE_PERSISTENT );
214218 }
215219#endif
216220
@@ -234,7 +238,7 @@ ZEND_API zend_result zend_register_ini_entries(const zend_ini_entry_def *ini_ent
234238 if (p -> name ) {
235239 zend_string_release_ex (p -> name , 1 );
236240 }
237- zend_unregister_ini_entries (module_number );
241+ zend_unregister_ini_entries_ex (module_number , module_type );
238242 return FAILURE ;
239243 }
240244 if (((default_value = zend_get_configuration_directive (p -> name )) != NULL ) &&
@@ -255,9 +259,46 @@ ZEND_API zend_result zend_register_ini_entries(const zend_ini_entry_def *ini_ent
255259}
256260/* }}} */
257261
262+ ZEND_API zend_result zend_register_ini_entries (const zend_ini_entry_def * ini_entry , int module_number ) /* {{{ */
263+ {
264+ zend_module_entry * module ;
265+
266+ /* Module is likely to be the last one in the list */
267+ ZEND_HASH_REVERSE_FOREACH_PTR (& module_registry , module ) {
268+ if (module -> module_number == module_number ) {
269+ return zend_register_ini_entries_ex (ini_entry , module_number , module -> type );
270+ }
271+ } ZEND_HASH_FOREACH_END ();
272+
273+ return FAILURE ;
274+ }
275+ /* }}} */
276+
277+ ZEND_API void zend_unregister_ini_entries_ex (int module_number , int module_type ) /* {{{ */
278+ {
279+ static HashTable * ini_directives ;
280+
281+ if (module_type == MODULE_TEMPORARY ) {
282+ ini_directives = EG (ini_directives );
283+ } else {
284+ ini_directives = registered_zend_ini_directives ;
285+ }
286+
287+ zend_hash_apply_with_argument (ini_directives , zend_remove_ini_entries , (void * ) & module_number );
288+ }
289+ /* }}} */
290+
258291ZEND_API void zend_unregister_ini_entries (int module_number ) /* {{{ */
259292{
260- zend_hash_apply_with_argument (registered_zend_ini_directives , zend_remove_ini_entries , (void * ) & module_number );
293+ zend_module_entry * module ;
294+
295+ /* Module is likely to be the last one in the list */
296+ ZEND_HASH_REVERSE_FOREACH_PTR (& module_registry , module ) {
297+ if (module -> module_number == module_number ) {
298+ zend_unregister_ini_entries_ex (module_number , module -> type );
299+ return ;
300+ }
301+ } ZEND_HASH_FOREACH_END ();
261302}
262303/* }}} */
263304
0 commit comments