@@ -4529,7 +4529,6 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
45294529 data_type = php_pgsql_get_data_type (Z_STR_P (type ));
45304530 }
45314531
4532- /* TODO: Should E_NOTICE be converted to type error if PHP type cannot be converted to field type? */
45334532 switch (data_type )
45344533 {
45354534 case PG_BOOL :
@@ -4554,7 +4553,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
45544553 ZVAL_STRINGL (& new_val , "'f'" , sizeof ("'f'" )- 1 );
45554554 }
45564555 else {
4557- php_error_docref ( NULL , E_NOTICE , "Detected invalid value (%s) for PostgreSQL %s field (%s)" , Z_STRVAL_P ( val ), Z_STRVAL_P ( type ), ZSTR_VAL ( field ));
4556+ zend_value_error ( "%s(): Field \"%s\" must be of type bool, invalid PostgreSQL string boolean value \"%s\" given" , get_active_function_name ( ), ZSTR_VAL ( field ), Z_STRVAL_P ( val ));
45584557 err = 1 ;
45594558 }
45604559 }
@@ -4586,7 +4585,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
45864585 }
45874586 PGSQL_CONV_CHECK_IGNORE ();
45884587 if (err ) {
4589- php_error_docref ( NULL , E_NOTICE , "Expects string, null, long or boolelan value for PostgreSQL '%s' (%s) " , Z_STRVAL_P ( type ), ZSTR_VAL (field ));
4588+ zend_type_error ( "%s(): Field \"%s\" must be of type string|null|int|bool, %s given " , get_active_function_name ( ), ZSTR_VAL (field ), Z_STRVAL_P ( type ));
45904589 }
45914590 break ;
45924591
@@ -4630,7 +4629,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
46304629 }
46314630 PGSQL_CONV_CHECK_IGNORE ();
46324631 if (err ) {
4633- php_error_docref ( NULL , E_NOTICE , "Expects NULL, string, long or double value for pgsql '%s' (%s) " , Z_STRVAL_P ( type ), ZSTR_VAL (field ));
4632+ zend_type_error ( "%s(): Field \"%s\" must be of type int|null, %s given " , get_active_function_name ( ), ZSTR_VAL (field ), Z_STRVAL_P ( type ));
46344633 }
46354634 break ;
46364635
@@ -4679,7 +4678,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
46794678 }
46804679 PGSQL_CONV_CHECK_IGNORE ();
46814680 if (err ) {
4682- php_error_docref ( NULL , E_NOTICE , "Expects NULL, string, long or double value for PostgreSQL '%s' (%s) " , Z_STRVAL_P ( type ), ZSTR_VAL (field ));
4681+ zend_type_error ( "%s(): Field \"%s\" must be of type %s|int|null, %s given " , get_active_function_name ( ), ( data_type == PG_MONEY ? "money" : "float" ), ZSTR_VAL (field ), Z_STRVAL_P ( type ));
46834682 }
46844683 break ;
46854684
@@ -4740,7 +4739,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
47404739 }
47414740 PGSQL_CONV_CHECK_IGNORE ();
47424741 if (err ) {
4743- php_error_docref ( NULL , E_NOTICE , "Expects NULL, string, long or double value for PostgreSQL '%s' (%s) " , Z_STRVAL_P ( type ), ZSTR_VAL (field ));
4742+ zend_type_error ( "%s(): Field \"%s\" must be of type string|null, %s given " , get_active_function_name ( ), ZSTR_VAL (field ), Z_STRVAL_P ( type ));
47444743 }
47454744 break ;
47464745
@@ -4782,7 +4781,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
47824781 }
47834782 PGSQL_CONV_CHECK_IGNORE ();
47844783 if (err ) {
4785- php_error_docref ( NULL , E_NOTICE , "Expects NULL, string, long or double value for '%s' (%s) " , Z_STRVAL_P ( type ), ZSTR_VAL (field ));
4784+ zend_type_error ( "%s(): Field \"%s\" must be of type int|null, %s given " , get_active_function_name ( ), ZSTR_VAL (field ), zend_zval_value_name ( val ));
47864785 }
47874786 break ;
47884787
@@ -4801,7 +4800,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
48014800 at all though and let the server side to handle it.*/
48024801 if (php_pgsql_convert_match (Z_STR_P (val ), REGEX0 , sizeof (REGEX0 )- 1 , 0 ) == FAILURE
48034802 && php_pgsql_convert_match (Z_STR_P (val ), REGEX1 , sizeof (REGEX1 )- 1 , 0 ) == FAILURE ) {
4804- err = 1 ;
4803+ err = 2 ;
48054804 }
48064805 else {
48074806 ZVAL_STR (& new_val , php_pgsql_add_quotes (Z_STR_P (val )));
@@ -4820,7 +4819,11 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
48204819 }
48214820 PGSQL_CONV_CHECK_IGNORE ();
48224821 if (err ) {
4823- php_error_docref (NULL , E_NOTICE , "Expects NULL or IPv4 or IPv6 address string for '%s' (%s)" , Z_STRVAL_P (type ), ZSTR_VAL (field ));
4822+ if (err == 2 ) {
4823+ zend_value_error ("%s(): Field \"%s\" must be a valid IPv4 or IPv6 address string, \"%s\" given" , get_active_function_name (), ZSTR_VAL (field ), Z_STRVAL_P (val ));
4824+ } else {
4825+ zend_type_error ("%s(): Field \"%s\" must be of type string|null, given %s" , get_active_function_name (), ZSTR_VAL (field ), zend_zval_value_name (val ));
4826+ }
48244827 }
48254828 break ;
48264829
@@ -4854,7 +4857,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
48544857 }
48554858 PGSQL_CONV_CHECK_IGNORE ();
48564859 if (err ) {
4857- php_error_docref ( NULL , E_NOTICE , "Expects NULL or string for PostgreSQL %s field (%s) " , Z_STRVAL_P ( type ), ZSTR_VAL (field ));
4860+ zend_type_error ( "%s(): Field \"%s\" must be of type string|null, %s given " , get_active_function_name ( ), ZSTR_VAL (field ), Z_STRVAL_P ( type ));
48584861 }
48594862 break ;
48604863
@@ -4886,7 +4889,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
48864889 }
48874890 PGSQL_CONV_CHECK_IGNORE ();
48884891 if (err ) {
4889- php_error_docref ( NULL , E_NOTICE , "Expects NULL or string for PostgreSQL %s field (%s) " , Z_STRVAL_P ( type ), ZSTR_VAL (field ));
4892+ zend_type_error ( "%s(): Field \"%s\" must be of type string|null, %s given " , get_active_function_name ( ), ZSTR_VAL (field ), Z_STRVAL_P ( type ));
48904893 }
48914894 break ;
48924895
@@ -4918,7 +4921,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
49184921 }
49194922 PGSQL_CONV_CHECK_IGNORE ();
49204923 if (err ) {
4921- php_error_docref ( NULL , E_NOTICE , "Expects NULL or string for PostgreSQL %s field (%s) " , Z_STRVAL_P ( type ), ZSTR_VAL (field ));
4924+ zend_type_error ( "%s(): Field \"%s\" must be of type string|null, %s given " , get_active_function_name ( ), ZSTR_VAL (field ), Z_STRVAL_P ( type ));
49224925 }
49234926 break ;
49244927
@@ -4996,7 +4999,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
49964999 }
49975000 PGSQL_CONV_CHECK_IGNORE ();
49985001 if (err ) {
4999- php_error_docref ( NULL , E_NOTICE , "Expects NULL or string for PostgreSQL %s field (%s) " , Z_STRVAL_P ( type ), ZSTR_VAL (field ));
5002+ zend_type_error ( "%s(): Field \"%s\" must be of type string|null, %s given " , get_active_function_name ( ), ZSTR_VAL (field ), Z_STRVAL_P ( type ));
50005003 }
50015004 break ;
50025005 case PG_BYTEA :
@@ -5037,7 +5040,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
50375040 }
50385041 PGSQL_CONV_CHECK_IGNORE ();
50395042 if (err ) {
5040- php_error_docref ( NULL , E_NOTICE , "Expects NULL, string, long or double value for PostgreSQL '%s' (%s) " , Z_STRVAL_P ( type ), ZSTR_VAL (field ));
5043+ zend_type_error ( "%s(): Field \"%s\" must be of type string|null, %s given " , get_active_function_name ( ), ZSTR_VAL (field ), Z_STRVAL_P ( type ));
50415044 }
50425045 break ;
50435046
@@ -5068,7 +5071,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
50685071 }
50695072 PGSQL_CONV_CHECK_IGNORE ();
50705073 if (err ) {
5071- php_error_docref ( NULL , E_NOTICE , "Expects NULL or string for PostgreSQL %s field (%s) " , Z_STRVAL_P ( type ), ZSTR_VAL (field ));
5074+ zend_type_error ( "%s(): Field \"%s\" must be of type string|null, %s given " , get_active_function_name ( ), ZSTR_VAL (field ), Z_STRVAL_P ( type ));
50725075 }
50735076 break ;
50745077
0 commit comments