@@ -634,49 +634,6 @@ static bool pdo_do_key_pair_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation o
634
634
return true;
635
635
}
636
636
637
- /* Previous the legacy zend_fcall_info_args_ex() function was used to set the
638
- * constructor arguments. The particularity of this function is to it "wraps" arguments
639
- * that need to be passed by-ref in a reference.
640
- * As this API only supported positional args, we don't bother doing this for named arguments. */
641
- static HashTable * pdo_class_fetch_prepare_constructor_arguments (const zend_function * constructor , HashTable * ctor_args )
642
- {
643
- zend_ulong index ;
644
- zend_string * arg_name = NULL ;
645
- zval * arg_value = NULL ;
646
- bool needs_duplication = false;
647
- ZEND_HASH_FOREACH_KEY_VAL (ctor_args , index , arg_name , arg_value ) {
648
- /* Named param, means we can assume no positional arguments exist after */
649
- if (arg_name ) {
650
- break ;
651
- }
652
- if (!Z_ISREF_P (arg_value ) && ARG_SHOULD_BE_SENT_BY_REF (constructor , index + 1 )) {
653
- needs_duplication = true;
654
- break ;
655
- }
656
- } ZEND_HASH_FOREACH_END ();
657
- if (needs_duplication ) {
658
- HashTable * duplicated = zend_new_array (zend_hash_num_elements (ctor_args ));
659
- ZEND_HASH_FOREACH_KEY_VAL (ctor_args , index , arg_name , arg_value ) {
660
- if (arg_name ) {
661
- zend_hash_add (duplicated , arg_name , arg_value );
662
- } else {
663
- zval val ;
664
- if (!Z_ISREF_P (arg_value ) && ARG_SHOULD_BE_SENT_BY_REF (constructor , index + 1 )) {
665
- Z_TRY_ADDREF_P (arg_value );
666
- ZVAL_NEW_REF (& val , arg_value );
667
- } else {
668
- ZVAL_COPY_VALUE (& val , arg_value );
669
- }
670
- zend_hash_index_add (duplicated , index , & val );
671
- }
672
- } ZEND_HASH_FOREACH_END ();
673
- return duplicated ;
674
- } else {
675
- GC_TRY_ADDREF (ctor_args );
676
- return ctor_args ;
677
- }
678
- }
679
-
680
637
/* Return value MUST be an initialized object */
681
638
static bool pdo_call_fetch_object_constructor (zend_function * constructor , HashTable * ctor_args , zval * return_value )
682
639
{
@@ -1118,7 +1075,8 @@ PHP_METHOD(PDOStatement, fetchObject)
1118
1075
zend_argument_value_error (2 , "must be empty when class provided in argument #1 ($class) does not have a constructor" );
1119
1076
goto reset_old_ctor_args ;
1120
1077
}
1121
- stmt -> fetch .cls .ctor_args = pdo_class_fetch_prepare_constructor_arguments (ce -> constructor , ctor_args );
1078
+ GC_TRY_ADDREF (ctor_args );
1079
+ stmt -> fetch .cls .ctor_args = ctor_args ;
1122
1080
}
1123
1081
} else {
1124
1082
stmt -> fetch .cls .ce = zend_standard_class_def ;
@@ -1230,7 +1188,8 @@ PHP_METHOD(PDOStatement, fetchAll)
1230
1188
zend_argument_value_error (3 , "must be empty when class provided in argument #2 ($class) does not have a constructor" );
1231
1189
goto reset_old_ctor_args ;
1232
1190
}
1233
- stmt -> fetch .cls .ctor_args = pdo_class_fetch_prepare_constructor_arguments (stmt -> fetch .cls .ce -> constructor , ctor_args );
1191
+ GC_TRY_ADDREF (ctor_args );
1192
+ stmt -> fetch .cls .ctor_args = ctor_args ;
1234
1193
}
1235
1194
break ;
1236
1195
@@ -1753,7 +1712,8 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a
1753
1712
zend_argument_value_error (3 , "must be empty when class provided in argument #2 ($class) does not have a constructor" );
1754
1713
return false;
1755
1714
}
1756
- stmt -> fetch .cls .ctor_args = pdo_class_fetch_prepare_constructor_arguments (cep -> constructor , Z_ARRVAL (args [1 ]));
1715
+ GC_TRY_ADDREF (Z_ARRVAL (args [1 ]));
1716
+ stmt -> fetch .cls .ctor_args = Z_ARRVAL (args [1 ]);
1757
1717
}
1758
1718
}
1759
1719
stmt -> fetch .cls .ce = cep ;
0 commit comments