Skip to content

Commit

Permalink
Fix issues #1051 for 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamsxin committed Aug 12, 2013
1 parent dc7e7ca commit c876f9b
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion ext/mvc/model/metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#include "kernel/fcall.h"
#include "kernel/object.h"
#include "kernel/hash.h"
#include "kernel/array.h"
#include "kernel/concat.h"
#include "kernel/exception.h"
Expand Down Expand Up @@ -446,7 +447,10 @@ PHP_METHOD(Phalcon_Mvc_Model_MetaData, readMetaDataIndex){
PHP_METHOD(Phalcon_Mvc_Model_MetaData, writeMetaDataIndex){

zval *model, *index, *data, *table, *schema, *class_name;
zval *key, *meta_data = NULL;
zval *key, *meta_data = NULL, *arr, *value;
HashTable *ah2;
HashPosition hp2;
zval **hd;

PHALCON_MM_GROW();

Expand Down Expand Up @@ -492,6 +496,25 @@ PHP_METHOD(Phalcon_Mvc_Model_MetaData, writeMetaDataIndex){

PHALCON_OBS_NVAR(meta_data);
phalcon_read_property_this(&meta_data, this_ptr, SL("_metaData"), PH_NOISY_CC);
} else {
PHALCON_OBS_VAR(arr);
phalcon_array_fetch(&arr, meta_data, key, PH_NOISY);

PHALCON_OBS_VAR(value);
phalcon_array_fetch(&value, arr, index, PH_NOISY);

PHALCON_SEPARATE_PARAM(data);
phalcon_is_iterable(value, &ah2, &hp2, 0, 0);

while (zend_hash_get_current_data_ex(ah2, (void**) &hd, &hp2) == SUCCESS) {
zval key2 = phalcon_get_current_key_w(ah2, &hp2);

if (!phalcon_array_isset(data, &key2)) {
phalcon_array_update_zval(&data, &key2, hd, PH_COPY | PH_SEPARATE);
}

zend_hash_move_forward_ex(ah2, &hp2);
}
}

phalcon_array_update_multi_2(&meta_data, key, index, &data, 0);
Expand Down

0 comments on commit c876f9b

Please sign in to comment.