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