@@ -663,34 +663,43 @@ bool php_phongo_bson_visit_array(const bson_iter_t *iter ARG_UNUSED, const char
663
663
}
664
664
665
665
666
- int php_phongo_is_array_or_document (zval * * val TSRMLS_DC ) /* {{{ */
666
+ int php_phongo_is_array_or_document (zval * val TSRMLS_DC ) /* {{{ */
667
667
{
668
- HashTable * ht_data = HASH_OF (* val );
668
+ HashTable * ht_data = HASH_OF (val );
669
669
int count ;
670
670
671
- if (Z_TYPE_PP (val ) != IS_ARRAY ) {
671
+ if (Z_TYPE_P (val ) != IS_ARRAY ) {
672
672
return IS_OBJECT ;
673
673
}
674
674
675
675
count = ht_data ? zend_hash_num_elements (ht_data ) : 0 ;
676
676
if (count > 0 ) {
677
- char * key ;
678
- unsigned int key_len ;
679
- unsigned long index = 0 ;
680
- unsigned long idx = 0 ;
681
- int hash_type = 0 ;
682
- HashPosition pos ;
683
677
#if PHP_VERSION_ID >= 70000
684
- zend_string * zs_key ;
685
- #endif
678
+ zend_string * key ;
679
+ zend_ulong index , idx ;
680
+
681
+ idx = 0 ;
682
+ ZEND_HASH_FOREACH_KEY (ht_data , index , key ) {
683
+ if (key ) {
684
+ return IS_OBJECT ;
685
+ } else {
686
+ if (index != idx ) {
687
+ return IS_OBJECT ;
688
+ }
689
+ }
690
+ idx ++ ;
691
+ } ZEND_HASH_FOREACH_END ();
692
+ #else
693
+ char * key ;
694
+ unsigned int key_len ;
695
+ unsigned long index = 0 ;
696
+ unsigned long idx = 0 ;
697
+ int hash_type = 0 ;
698
+ HashPosition pos ;
686
699
687
700
zend_hash_internal_pointer_reset_ex (ht_data , & pos );
688
701
for (;; zend_hash_move_forward_ex (ht_data , & pos )) {
689
- #if PHP_VERSION_ID >= 70000
690
- hash_type = zend_hash_get_current_key_ex (ht_data , & zs_key , & index , & pos );
691
- #else
692
702
hash_type = zend_hash_get_current_key_ex (ht_data , & key , & key_len , & index , 0 , & pos );
693
- #endif
694
703
if (hash_type == HASH_KEY_NON_EXISTENT ) {
695
704
break ;
696
705
}
@@ -704,8 +713,9 @@ int php_phongo_is_array_or_document(zval **val TSRMLS_DC) /* {{{ */
704
713
}
705
714
idx ++ ;
706
715
}
716
+ #endif
707
717
} else {
708
- return Z_TYPE_PP (val );
718
+ return Z_TYPE_P (val );
709
719
}
710
720
711
721
return IS_ARRAY ;
0 commit comments