@@ -209,20 +209,20 @@ static int php_git2_config_resolve(zval **result, const char *var_name, zval *m_
209
209
return error ;
210
210
}
211
211
212
- static int php_git2_config_foreach (const char * var_name , const char * value , void * payload )
212
+ static int php_git2_config_foreach (const git_config_entry * entry , void * payload )
213
213
{
214
214
HashTable * hash ;
215
- zval * entry , * * target_offset ;
215
+ zval * zentry , * * target_offset ;
216
216
const char * config_value ;
217
217
char * current_key , * tmp_value , * savedptr , * k ;
218
218
php_git2_config_foreach_t * opaque = (php_git2_config_foreach_t * )payload ;
219
219
int error = 0 ;
220
220
221
221
hash = Z_ARRVAL_P (opaque -> result );
222
222
223
- error = git_config_get_string (& config_value , opaque -> config , var_name );
223
+ error = git_config_get_string (& config_value , opaque -> config , entry -> name );
224
224
225
- tmp_value = estrdup (var_name );
225
+ tmp_value = estrdup (entry -> name );
226
226
current_key = php_strtok_r (tmp_value , "." , & savedptr );
227
227
while (current_key != NULL ) {
228
228
k = current_key ;
@@ -234,20 +234,24 @@ static int php_git2_config_foreach(const char *var_name, const char *value, void
234
234
hash = Z_ARRVAL_P (* target_offset );
235
235
}
236
236
} else {
237
- MAKE_STD_ZVAL (entry );
238
- array_init (entry );
239
- zend_hash_add (hash , k , strlen (k )+ 1 , (void * * )& entry , sizeof (entry ), NULL );
240
- hash = Z_ARRVAL_P (entry );
237
+ MAKE_STD_ZVAL (zentry );
238
+ array_init (zentry );
239
+ zend_hash_add (hash , k , strlen (k )+ 1 , (void * * )& zentry , sizeof (zentry ), NULL );
240
+ hash = Z_ARRVAL_P (zentry );
241
241
}
242
242
}
243
243
}
244
244
245
245
if (k != NULL ) {
246
- MAKE_STD_ZVAL (entry );
247
- ZVAL_STRING (entry , config_value , 1 );
248
- zend_hash_add (hash , k , strlen (k )+ 1 , (void * * )& entry , sizeof (entry ), NULL );
249
- Z_ADDREF_P (entry );
250
- zval_ptr_dtor (& entry );
246
+ MAKE_STD_ZVAL (zentry );
247
+ if (config_value ) {
248
+ ZVAL_STRING (zentry , config_value , 1 );
249
+ } else {
250
+ ZVAL_NULL (zentry );
251
+ }
252
+ zend_hash_add (hash , k , strlen (k )+ 1 , (void * * )& zentry , sizeof (zentry ), NULL );
253
+ Z_ADDREF_P (zentry );
254
+ zval_ptr_dtor (& zentry );
251
255
}
252
256
efree (tmp_value );
253
257
@@ -273,7 +277,7 @@ static int php_git2_config_reload(zval *object, unsigned short dtor TSRMLS_DC)
273
277
274
278
payload .config = m_config -> config ;
275
279
payload .result = entry ;
276
- error = git_config_foreach (m_config -> config ,& php_git2_config_foreach ,& payload );
280
+ error = git_config_foreach (m_config -> config , & php_git2_config_foreach , & payload );
277
281
add_property_zval (object , "configs" , entry );
278
282
if (dtor == 1 ) {
279
283
zval_ptr_dtor (& entry );
0 commit comments