mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
ext/pgsql: php_pgsql_convert converts E_NOTICE to TypeError/ValueError exceptions.
Close GH-11238
This commit is contained in:
parent
9ce6980b4d
commit
16a63d7b07
5 changed files with 47 additions and 20 deletions
|
@ -4529,7 +4529,6 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
|
|||
data_type = php_pgsql_get_data_type(Z_STR_P(type));
|
||||
}
|
||||
|
||||
/* TODO: Should E_NOTICE be converted to type error if PHP type cannot be converted to field type? */
|
||||
switch(data_type)
|
||||
{
|
||||
case PG_BOOL:
|
||||
|
@ -4554,7 +4553,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
|
|||
ZVAL_STRINGL(&new_val, "'f'", sizeof("'f'")-1);
|
||||
}
|
||||
else {
|
||||
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));
|
||||
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));
|
||||
err = 1;
|
||||
}
|
||||
}
|
||||
|
@ -4586,7 +4585,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
|
|||
}
|
||||
PGSQL_CONV_CHECK_IGNORE();
|
||||
if (err) {
|
||||
php_error_docref(NULL, E_NOTICE, "Expects string, null, long or boolelan value for PostgreSQL '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field));
|
||||
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));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -4630,7 +4629,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
|
|||
}
|
||||
PGSQL_CONV_CHECK_IGNORE();
|
||||
if (err) {
|
||||
php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for pgsql '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field));
|
||||
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));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -4679,7 +4678,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
|
|||
}
|
||||
PGSQL_CONV_CHECK_IGNORE();
|
||||
if (err) {
|
||||
php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for PostgreSQL '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field));
|
||||
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));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -4740,7 +4739,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
|
|||
}
|
||||
PGSQL_CONV_CHECK_IGNORE();
|
||||
if (err) {
|
||||
php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for PostgreSQL '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field));
|
||||
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));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -4782,7 +4781,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
|
|||
}
|
||||
PGSQL_CONV_CHECK_IGNORE();
|
||||
if (err) {
|
||||
php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field));
|
||||
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));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -4801,7 +4800,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
|
|||
at all though and let the server side to handle it.*/
|
||||
if (php_pgsql_convert_match(Z_STR_P(val), REGEX0, sizeof(REGEX0)-1, 0) == FAILURE
|
||||
&& php_pgsql_convert_match(Z_STR_P(val), REGEX1, sizeof(REGEX1)-1, 0) == FAILURE) {
|
||||
err = 1;
|
||||
err = 2;
|
||||
}
|
||||
else {
|
||||
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 *
|
|||
}
|
||||
PGSQL_CONV_CHECK_IGNORE();
|
||||
if (err) {
|
||||
php_error_docref(NULL, E_NOTICE, "Expects NULL or IPv4 or IPv6 address string for '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field));
|
||||
if (err == 2) {
|
||||
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));
|
||||
} else {
|
||||
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));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -4854,7 +4857,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
|
|||
}
|
||||
PGSQL_CONV_CHECK_IGNORE();
|
||||
if (err) {
|
||||
php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), ZSTR_VAL(field));
|
||||
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));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -4886,7 +4889,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
|
|||
}
|
||||
PGSQL_CONV_CHECK_IGNORE();
|
||||
if (err) {
|
||||
php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), ZSTR_VAL(field));
|
||||
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));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -4918,7 +4921,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
|
|||
}
|
||||
PGSQL_CONV_CHECK_IGNORE();
|
||||
if (err) {
|
||||
php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), ZSTR_VAL(field));
|
||||
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));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -4996,7 +4999,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
|
|||
}
|
||||
PGSQL_CONV_CHECK_IGNORE();
|
||||
if (err) {
|
||||
php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), ZSTR_VAL(field));
|
||||
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));
|
||||
}
|
||||
break;
|
||||
case PG_BYTEA:
|
||||
|
@ -5037,7 +5040,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
|
|||
}
|
||||
PGSQL_CONV_CHECK_IGNORE();
|
||||
if (err) {
|
||||
php_error_docref(NULL, E_NOTICE, "Expects NULL, string, long or double value for PostgreSQL '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field));
|
||||
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));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -5068,7 +5071,7 @@ PHP_PGSQL_API zend_result php_pgsql_convert(PGconn *pg_link, const zend_string *
|
|||
}
|
||||
PGSQL_CONV_CHECK_IGNORE();
|
||||
if (err) {
|
||||
php_error_docref(NULL, E_NOTICE, "Expects NULL or string for PostgreSQL %s field (%s)", Z_STRVAL_P(type), ZSTR_VAL(field));
|
||||
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));
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue