@@ -2016,9 +2016,9 @@ static void free_cb(void *arg) /* {{{ */
2016
2016
2017
2017
static inline int build_mime_structure_from_hash (php_curl * ch , zval * zpostfields ) /* {{{ */
2018
2018
{
2019
+ HashTable * postfields = Z_ARRVAL_P (zpostfields );
2019
2020
CURLcode error = CURLE_OK ;
2020
2021
zval * current ;
2021
- HashTable * postfields ;
2022
2022
zend_string * string_key ;
2023
2023
zend_ulong num_key ;
2024
2024
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
@@ -2031,12 +2031,6 @@ static inline int build_mime_structure_from_hash(php_curl *ch, zval *zpostfields
2031
2031
CURLFORMcode form_error ;
2032
2032
#endif
2033
2033
2034
- postfields = HASH_OF (zpostfields );
2035
- if (!postfields ) {
2036
- php_error_docref (NULL , E_WARNING , "Couldn't get HashTable in CURLOPT_POSTFIELDS" );
2037
- return FAILURE ;
2038
- }
2039
-
2040
2034
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
2041
2035
if (zend_hash_num_elements (postfields ) > 0 ) {
2042
2036
mime = curl_mime_init (ch -> cp );
@@ -2046,7 +2040,7 @@ static inline int build_mime_structure_from_hash(php_curl *ch, zval *zpostfields
2046
2040
}
2047
2041
#endif
2048
2042
2049
- ZEND_HASH_FOREACH_KEY_VAL_IND (postfields , num_key , string_key , current ) {
2043
+ ZEND_HASH_FOREACH_KEY_VAL (postfields , num_key , string_key , current ) {
2050
2044
zend_string * postval , * tmp_postval ;
2051
2045
/* Pretend we have a string_key here */
2052
2046
if (!string_key ) {
@@ -2659,8 +2653,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
2659
2653
zend_string * val , * tmp_val ;
2660
2654
struct curl_slist * slist = NULL ;
2661
2655
2662
- ph = HASH_OF (zvalue );
2663
- if (!ph ) {
2656
+ if (Z_TYPE_P (zvalue ) != IS_ARRAY ) {
2664
2657
char * name = NULL ;
2665
2658
switch (option ) {
2666
2659
case CURLOPT_HTTPHEADER :
@@ -2698,11 +2691,12 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
2698
2691
break ;
2699
2692
#endif
2700
2693
}
2701
- php_error_docref (NULL , E_WARNING , "You must pass either an object or an array with the %s argument" , name );
2694
+ php_error_docref (NULL , E_WARNING , "You must pass an array with the %s argument" , name );
2702
2695
return FAILURE ;
2703
2696
}
2704
2697
2705
- ZEND_HASH_FOREACH_VAL_IND (ph , current ) {
2698
+ ph = Z_ARRVAL_P (zvalue );
2699
+ ZEND_HASH_FOREACH_VAL (ph , current ) {
2706
2700
ZVAL_DEREF (current );
2707
2701
val = zval_get_tmp_string (current , & tmp_val );
2708
2702
slist = curl_slist_append (slist , ZSTR_VAL (val ));
@@ -2745,7 +2739,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
2745
2739
break ;
2746
2740
2747
2741
case CURLOPT_POSTFIELDS :
2748
- if (Z_TYPE_P (zvalue ) == IS_ARRAY || Z_TYPE_P ( zvalue ) == IS_OBJECT ) {
2742
+ if (Z_TYPE_P (zvalue ) == IS_ARRAY ) {
2749
2743
return build_mime_structure_from_hash (ch , zvalue );
2750
2744
} else {
2751
2745
zend_string * tmp_str ;
0 commit comments