3535#include "zend_observer.h"
3636#include "zend_extensions.h"
3737
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 );
3939
4040void pdo_throw_exception (unsigned int driver_errcode , char * driver_errmsg , pdo_error_type * pdo_error )
4141{
@@ -512,7 +512,7 @@ PDO_API void php_pdo_internal_construct_driver(INTERNAL_FUNCTION_PARAMETERS, zen
512512 ZVAL_DEREF (attr_value );
513513
514514 /* 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 );
516516 } ZEND_HASH_FOREACH_END ();
517517 }
518518
@@ -814,7 +814,7 @@ PDO_API bool pdo_get_bool_param(bool *bval, const zval *value)
814814}
815815
816816/* 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 ) /* {{{ */
818818{
819819 zend_long lval ;
820820 bool bval ;
@@ -831,7 +831,7 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /
831831 dbh -> error_mode = lval ;
832832 return true;
833833 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" );
835835 return false;
836836 }
837837 return false;
@@ -847,7 +847,7 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /
847847 dbh -> desired_case = lval ;
848848 return true;
849849 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" );
851851 return false;
852852 }
853853 return false;
@@ -865,7 +865,7 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /
865865 zval * tmp ;
866866 if ((tmp = zend_hash_index_find (Z_ARRVAL_P (value ), 0 )) != NULL && Z_TYPE_P (tmp ) == IS_LONG ) {
867867 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" );
869869 return false;
870870 }
871871 }
@@ -876,7 +876,7 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /
876876 }
877877 }
878878 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" );
880880 return false;
881881 }
882882 dbh -> default_fetch_type = lval ;
@@ -906,25 +906,25 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /
906906 return false;
907907 }
908908 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" ,
910910 zend_zval_value_name (value ));
911911 return false;
912912 }
913913 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 "
915915 "array(classname, constructor_args)" );
916916 return false;
917917 }
918918 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" );
920920 return false;
921921 }
922922 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" );
924924 return false;
925925 }
926926 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" );
928928 return false;
929929 }
930930 dbh -> def_stmt_ce = pce ;
@@ -934,7 +934,7 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /
934934 }
935935 if ((item = zend_hash_index_find (Z_ARRVAL_P (value ), 1 )) != NULL ) {
936936 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" ,
938938 zend_zval_value_name (value ));
939939 return false;
940940 }
@@ -980,7 +980,7 @@ PHP_METHOD(PDO, setAttribute)
980980 PDO_DBH_CLEAR_ERR ();
981981 PDO_CONSTRUCT_CHECK ;
982982
983- RETURN_BOOL (pdo_dbh_attribute_set (dbh , attr , value ));
983+ RETURN_BOOL (pdo_dbh_attribute_set (dbh , attr , value , 2 ));
984984}
985985/* }}} */
986986
0 commit comments