35
35
#include "zend_observer.h"
36
36
#include "zend_extensions.h"
37
37
38
- static bool pdo_dbh_attribute_set (pdo_dbh_t * dbh , zend_long attr , zval * value );
38
+ static bool pdo_dbh_attribute_set (pdo_dbh_t * dbh , zend_long attr , zval * value , uint32_t value_arg_num );
39
39
40
40
void pdo_throw_exception (unsigned int driver_errcode , char * driver_errmsg , pdo_error_type * pdo_error )
41
41
{
@@ -512,7 +512,7 @@ PDO_API void php_pdo_internal_construct_driver(INTERNAL_FUNCTION_PARAMETERS, zen
512
512
ZVAL_DEREF (attr_value );
513
513
514
514
/* TODO: Should the constructor fail when the attribute cannot be set? */
515
- pdo_dbh_attribute_set (dbh , long_key , attr_value );
515
+ pdo_dbh_attribute_set (dbh , long_key , attr_value , 3 );
516
516
} ZEND_HASH_FOREACH_END ();
517
517
}
518
518
@@ -814,7 +814,7 @@ PDO_API bool pdo_get_bool_param(bool *bval, const zval *value)
814
814
}
815
815
816
816
/* Return false on failure, true otherwise */
817
- static bool pdo_dbh_attribute_set (pdo_dbh_t * dbh , zend_long attr , zval * value ) /* {{{ */
817
+ static bool pdo_dbh_attribute_set (pdo_dbh_t * dbh , zend_long attr , zval * value , uint32_t value_arg_num ) /* {{{ */
818
818
{
819
819
zend_long lval ;
820
820
bool bval ;
@@ -831,7 +831,7 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /
831
831
dbh -> error_mode = lval ;
832
832
return true;
833
833
default :
834
- zend_value_error ( "Error mode must be one of the PDO::ERRMODE_* constants" );
834
+ zend_argument_value_error ( value_arg_num , "Error mode must be one of the PDO::ERRMODE_* constants" );
835
835
return false;
836
836
}
837
837
return false;
@@ -847,7 +847,7 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /
847
847
dbh -> desired_case = lval ;
848
848
return true;
849
849
default :
850
- zend_value_error ( "Case folding mode must be one of the PDO::CASE_* constants" );
850
+ zend_argument_value_error ( value_arg_num , "Case folding mode must be one of the PDO::CASE_* constants" );
851
851
return false;
852
852
}
853
853
return false;
@@ -865,7 +865,7 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /
865
865
zval * tmp ;
866
866
if ((tmp = zend_hash_index_find (Z_ARRVAL_P (value ), 0 )) != NULL && Z_TYPE_P (tmp ) == IS_LONG ) {
867
867
if (Z_LVAL_P (tmp ) == PDO_FETCH_INTO || Z_LVAL_P (tmp ) == PDO_FETCH_CLASS ) {
868
- zend_value_error ( "PDO::FETCH_INTO and PDO::FETCH_CLASS cannot be set as the default fetch mode" );
868
+ zend_argument_value_error ( value_arg_num , "PDO::FETCH_INTO and PDO::FETCH_CLASS cannot be set as the default fetch mode" );
869
869
return false;
870
870
}
871
871
}
@@ -876,7 +876,7 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /
876
876
}
877
877
}
878
878
if (lval == PDO_FETCH_USE_DEFAULT ) {
879
- zend_value_error ( "Fetch mode must be a bitmask of PDO::FETCH_* constants" );
879
+ zend_argument_value_error ( value_arg_num , "Fetch mode must be a bitmask of PDO::FETCH_* constants" );
880
880
return false;
881
881
}
882
882
dbh -> default_fetch_type = lval ;
@@ -906,25 +906,25 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /
906
906
return false;
907
907
}
908
908
if (Z_TYPE_P (value ) != IS_ARRAY ) {
909
- zend_type_error ( "PDO::ATTR_STATEMENT_CLASS value must be of type array, %s given" ,
909
+ zend_argument_type_error ( value_arg_num , "PDO::ATTR_STATEMENT_CLASS value must be of type array, %s given" ,
910
910
zend_zval_value_name (value ));
911
911
return false;
912
912
}
913
913
if ((item = zend_hash_index_find (Z_ARRVAL_P (value ), 0 )) == NULL ) {
914
- zend_value_error ( "PDO::ATTR_STATEMENT_CLASS value must be an array with the format "
914
+ zend_argument_value_error ( value_arg_num , "PDO::ATTR_STATEMENT_CLASS value must be an array with the format "
915
915
"array(classname, constructor_args)" );
916
916
return false;
917
917
}
918
918
if (Z_TYPE_P (item ) != IS_STRING || (pce = zend_lookup_class (Z_STR_P (item ))) == NULL ) {
919
- zend_type_error ( "PDO::ATTR_STATEMENT_CLASS class must be a valid class" );
919
+ zend_argument_type_error ( value_arg_num , "PDO::ATTR_STATEMENT_CLASS class must be a valid class" );
920
920
return false;
921
921
}
922
922
if (!instanceof_function (pce , pdo_dbstmt_ce )) {
923
- zend_type_error ( "PDO::ATTR_STATEMENT_CLASS class must be derived from PDOStatement" );
923
+ zend_argument_type_error ( value_arg_num , "PDO::ATTR_STATEMENT_CLASS class must be derived from PDOStatement" );
924
924
return false;
925
925
}
926
926
if (pce -> constructor && !(pce -> constructor -> common .fn_flags & (ZEND_ACC_PRIVATE |ZEND_ACC_PROTECTED ))) {
927
- zend_type_error ( "User-supplied statement class cannot have a public constructor" );
927
+ zend_argument_type_error ( value_arg_num , "User-supplied statement class cannot have a public constructor" );
928
928
return false;
929
929
}
930
930
dbh -> def_stmt_ce = pce ;
@@ -934,7 +934,7 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /
934
934
}
935
935
if ((item = zend_hash_index_find (Z_ARRVAL_P (value ), 1 )) != NULL ) {
936
936
if (Z_TYPE_P (item ) != IS_ARRAY ) {
937
- zend_type_error ( "PDO::ATTR_STATEMENT_CLASS constructor_args must be of type ?array, %s given" ,
937
+ zend_argument_type_error ( value_arg_num , "PDO::ATTR_STATEMENT_CLASS constructor_args must be of type ?array, %s given" ,
938
938
zend_zval_value_name (value ));
939
939
return false;
940
940
}
@@ -980,7 +980,7 @@ PHP_METHOD(PDO, setAttribute)
980
980
PDO_DBH_CLEAR_ERR ();
981
981
PDO_CONSTRUCT_CHECK ;
982
982
983
- RETURN_BOOL (pdo_dbh_attribute_set (dbh , attr , value ));
983
+ RETURN_BOOL (pdo_dbh_attribute_set (dbh , attr , value , 2 ));
984
984
}
985
985
/* }}} */
986
986
0 commit comments