3636#include "zend_observer.h"
3737#include "zend_extensions.h"
3838
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 );
4040
4141void pdo_throw_exception (unsigned int driver_errcode , char * driver_errmsg , pdo_error_type * pdo_error )
4242{
@@ -513,7 +513,7 @@ PDO_API void php_pdo_internal_construct_driver(INTERNAL_FUNCTION_PARAMETERS, zen
513513 ZVAL_DEREF (attr_value );
514514
515515 /* 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 );
517517 } ZEND_HASH_FOREACH_END ();
518518 }
519519
@@ -815,7 +815,7 @@ PDO_API bool pdo_get_bool_param(bool *bval, const zval *value)
815815}
816816
817817/* 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 ) /* {{{ */
819819{
820820 zend_long lval ;
821821 bool bval ;
@@ -832,7 +832,7 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /
832832 dbh -> error_mode = lval ;
833833 return true;
834834 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" );
836836 return false;
837837 }
838838 return false;
@@ -848,7 +848,7 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /
848848 dbh -> desired_case = lval ;
849849 return true;
850850 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" );
852852 return false;
853853 }
854854 return false;
@@ -866,7 +866,7 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /
866866 zval * tmp ;
867867 if ((tmp = zend_hash_index_find (Z_ARRVAL_P (value ), 0 )) != NULL && Z_TYPE_P (tmp ) == IS_LONG ) {
868868 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" );
870870 return false;
871871 }
872872 }
@@ -877,7 +877,7 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /
877877 }
878878 }
879879 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" );
881881 return false;
882882 }
883883 dbh -> default_fetch_type = lval ;
@@ -907,25 +907,25 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /
907907 return false;
908908 }
909909 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" ,
911911 zend_zval_value_name (value ));
912912 return false;
913913 }
914914 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 "
916916 "array(classname, constructor_args)" );
917917 return false;
918918 }
919919 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" );
921921 return false;
922922 }
923923 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" );
925925 return false;
926926 }
927927 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" );
929929 return false;
930930 }
931931 dbh -> def_stmt_ce = pce ;
@@ -935,7 +935,7 @@ static bool pdo_dbh_attribute_set(pdo_dbh_t *dbh, zend_long attr, zval *value) /
935935 }
936936 if ((item = zend_hash_index_find (Z_ARRVAL_P (value ), 1 )) != NULL ) {
937937 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" ,
939939 zend_zval_value_name (value ));
940940 return false;
941941 }
@@ -981,7 +981,7 @@ PHP_METHOD(PDO, setAttribute)
981981 PDO_DBH_CLEAR_ERR ();
982982 PDO_CONSTRUCT_CHECK ;
983983
984- RETURN_BOOL (pdo_dbh_attribute_set (dbh , attr , value ));
984+ RETURN_BOOL (pdo_dbh_attribute_set (dbh , attr , value , 2 ));
985985}
986986/* }}} */
987987
0 commit comments