diff options
author | Dharman <tekiela246@gmail.com> | 2020-09-16 15:41:02 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-09-17 09:42:42 +0200 |
commit | 8f56b7a7555c7381ab4005ae56a76c23d5da226a (patch) | |
tree | 7da4fe3b8dabfd45d3a768172bc2e40f20644e2c | |
parent | 46d22e435f43529aa55b54460dd265c4bd22409f (diff) | |
download | php-git-8f56b7a7555c7381ab4005ae56a76c23d5da226a.tar.gz |
mysqli: Promote warning in field_seek
Aligning the behaviour of fetch_field and field_seek.
-rw-r--r-- | ext/mysqli/mysqli_api.c | 5 | ||||
-rw-r--r-- | ext/mysqli/tests/mysqli_field_seek.phpt | 10 | ||||
-rw-r--r-- | ext/mysqli/tests/mysqli_field_tell.phpt | 10 |
3 files changed, 14 insertions, 11 deletions
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index e949053af0..3af7654733 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -1286,9 +1286,8 @@ PHP_FUNCTION(mysqli_field_seek) MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID); if ((uint32_t)fieldnr >= mysql_num_fields(result)) { - // TODO ValueError? - php_error_docref(NULL, E_WARNING, "Invalid field offset"); - RETURN_FALSE; + zend_argument_value_error(ERROR_ARG_POS(2), "must be less than the number of fields for this result set"); + RETURN_THROWS(); } mysql_field_seek(result, fieldnr); diff --git a/ext/mysqli/tests/mysqli_field_seek.phpt b/ext/mysqli/tests/mysqli_field_seek.phpt index bcc1e29526..d4f160deb0 100644 --- a/ext/mysqli/tests/mysqli_field_seek.phpt +++ b/ext/mysqli/tests/mysqli_field_seek.phpt @@ -92,7 +92,11 @@ require_once('skipifconnectfailure.inc'); } var_dump(mysqli_field_tell($res)); - var_dump(mysqli_field_seek($res, 2)); + try { + var_dump(mysqli_field_seek($res, 2)); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } var_dump(mysqli_fetch_field($res)); mysqli_free_result($res); @@ -207,9 +211,7 @@ object(stdClass)#%d (13) { int(0) } int(2) - -Warning: mysqli_field_seek(): Invalid field offset in %s on line %d -bool(false) +mysqli_field_seek(): Argument #2 ($field_nr) must be less than the number of fields for this result set bool(false) bool(true) object(stdClass)#%d (13) { diff --git a/ext/mysqli/tests/mysqli_field_tell.phpt b/ext/mysqli/tests/mysqli_field_tell.phpt index e8c344ec95..1a2be4d70c 100644 --- a/ext/mysqli/tests/mysqli_field_tell.phpt +++ b/ext/mysqli/tests/mysqli_field_tell.phpt @@ -21,7 +21,11 @@ require_once('skipifconnectfailure.inc'); var_dump(mysqli_fetch_field($res)); var_dump(mysqli_field_tell($res)); - var_dump(mysqli_field_seek($res, 2)); + try { + var_dump(mysqli_field_seek($res, 2)); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } var_dump(mysqli_field_tell($res)); try { @@ -85,9 +89,7 @@ object(stdClass)#%d (13) { } bool(false) int(1) - -Warning: mysqli_field_seek(): Invalid field offset in %s on line %d -bool(false) +mysqli_field_seek(): Argument #2 ($field_nr) must be less than the number of fields for this result set int(1) mysqli_field_seek(): Argument #2 ($field_nr) must be greater than or equal to 0 int(1) |