@@ -117,6 +117,23 @@ static const char *php_apache_phpini_set(cmd_parms *cmd, void *mconfig, const ch
117
117
return NULL ;
118
118
}
119
119
120
+ static zend_bool should_overwrite_per_dir_entry (HashTable * target_ht , php_dir_entry * new_per_dir_entry , zend_hash_key * hash_key , void * pData )
121
+ {
122
+ php_dir_entry * orig_per_dir_entry ;
123
+
124
+ if (zend_hash_find (target_ht , hash_key -> arKey , hash_key -> nKeyLength , (void * * ) & orig_per_dir_entry )== FAILURE ) {
125
+ return 1 ; /* does not exist in dest, copy from source */
126
+ }
127
+
128
+ if (new_per_dir_entry -> status >= orig_per_dir_entry -> status ) {
129
+ /* use new entry */
130
+ phpapdebug ((stderr , "ADDING/OVERWRITING %s (%d vs. %d)\n" , hash_key -> arKey , new_per_dir_entry -> status , orig_per_dir_entry -> status ));
131
+ return 1 ;
132
+ } else {
133
+ return 0 ;
134
+ }
135
+ }
136
+
120
137
121
138
void * merge_php_config (apr_pool_t * p , void * base_conf , void * new_conf )
122
139
{
@@ -128,9 +145,12 @@ void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf)
128
145
ulong num_index ;
129
146
130
147
n = create_php_config (p , "merge_php_config" );
131
- zend_hash_copy (& n -> config , & e -> config , NULL , NULL , sizeof (php_dir_entry ));
132
-
148
+ /* copy old config */
149
+ zend_hash_copy (& n -> config , & d -> config , NULL , NULL , sizeof (php_dir_entry ));
150
+ /* merge new config */
133
151
phpapdebug ((stderr , "Merge dir (%p)+(%p)=(%p)\n" , base_conf , new_conf , n ));
152
+ zend_hash_merge_ex (& n -> config , & e -> config , NULL , sizeof (php_dir_entry ), (merge_checker_func_t ) should_overwrite_per_dir_entry , NULL );
153
+ #if STAS_0
134
154
for (zend_hash_internal_pointer_reset (& d -> config );
135
155
zend_hash_get_current_key_ex (& d -> config , & str , & str_len ,
136
156
& num_index , 0 , NULL ) == HASH_KEY_IS_STRING ;
@@ -140,10 +160,10 @@ void *merge_php_config(apr_pool_t *p, void *base_conf, void *new_conf)
140
160
if (zend_hash_find (& n -> config , str , str_len , (void * * ) & pe ) == SUCCESS ) {
141
161
if (pe -> status >= data -> status ) continue ;
142
162
}
143
- zend_hash_update (& n -> config , str , str_len , data , sizeof (* data ), NULL );
144
163
phpapdebug ((stderr , "ADDING/OVERWRITING %s (%d vs. %d)\n" , str , data -> status , pe ?pe -> status :-1 ));
164
+ zend_hash_update (& n -> config , str , str_len , data , sizeof (* data ), NULL );
145
165
}
146
-
166
+ #endif
147
167
return n ;
148
168
}
149
169
0 commit comments