diff options
| author | George Peter Banyard <girgias@php.net> | 2020-07-03 13:43:29 +0200 |
|---|---|---|
| committer | George Peter Banyard <girgias@php.net> | 2020-09-15 19:12:02 +0200 |
| commit | 7a95e943d642e05532979a06221c476183eac7e4 (patch) | |
| tree | ded828cad622e5e55e06ec70c9e044e834fffc94 /ext/mysqli/tests | |
| parent | 7e61c2edd8456ff502e17e14d517da409f1e6193 (diff) | |
| download | php-git-7a95e943d642e05532979a06221c476183eac7e4.tar.gz | |
Promote warnings to Error in MySQLi extension
Closes GH-5803
Diffstat (limited to 'ext/mysqli/tests')
32 files changed, 388 insertions, 274 deletions
diff --git a/ext/mysqli/tests/bug55582.phpt b/ext/mysqli/tests/bug55582.phpt index 86626c0279..817f7eecfe 100644 --- a/ext/mysqli/tests/bug55582.phpt +++ b/ext/mysqli/tests/bug55582.phpt @@ -15,27 +15,31 @@ require_once("connect.inc"); var_dump($link->real_query("SELECT 1")); $res = $link->use_result(); - var_dump(mysqli_num_rows($res)); + try { + var_dump(mysqli_num_rows($res)); + } catch (\Error $e) { + echo $e->getMessage() . \PHP_EOL; + } var_dump($res->fetch_assoc()); - var_dump(mysqli_num_rows($res)); + try { + var_dump(mysqli_num_rows($res)); + } catch (\Error $e) { + echo $e->getMessage() . \PHP_EOL; + } var_dump($res->fetch_assoc()); var_dump(mysqli_num_rows($res)); $link->close(); echo "done\n"; ?> ---EXPECTF-- +--EXPECT-- bool(true) - -Warning: mysqli_num_rows(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d -int(0) +mysqli_num_rows() cannot be used with MYSQLI_USE_RESULT array(1) { [1]=> string(1) "1" } - -Warning: mysqli_num_rows(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d -int(0) +mysqli_num_rows() cannot be used with MYSQLI_USE_RESULT NULL int(1) done diff --git a/ext/mysqli/tests/bug74595.phpt b/ext/mysqli/tests/bug74595.phpt deleted file mode 100644 index 9d017eaa82..0000000000 --- a/ext/mysqli/tests/bug74595.phpt +++ /dev/null @@ -1,25 +0,0 @@ ---TEST-- -Bug #74595 (ReflectionMethod::getParameters returns incorrect number of parameters) ---SKIPIF-- -<?php -require_once('skipif.inc'); -?> ---FILE-- -<?php -$class = new ReflectionClass('mysqli'); -$method = $class->getMethod('query'); -var_dump($method->getParameters()); -?> ---EXPECTF-- -array(2) { - [0]=> - object(ReflectionParameter)#%d (1) { - ["name"]=> - string(5) "query" - } - [1]=> - object(ReflectionParameter)#%d (1) { - ["name"]=> - string(10) "resultmode" - } -} diff --git a/ext/mysqli/tests/connect.inc b/ext/mysqli/tests/connect.inc index 43bb3c4153..6bf393a2de 100644 --- a/ext/mysqli/tests/connect.inc +++ b/ext/mysqli/tests/connect.inc @@ -8,7 +8,7 @@ $driver = new mysqli_driver; - $host = getenv("MYSQL_TEST_HOST") ?: "localhost"; + $host = getenv("MYSQL_TEST_HOST") ?: "127.0.0.1"; $port = getenv("MYSQL_TEST_PORT") ?: 3306; $user = getenv("MYSQL_TEST_USER") ?: "root"; $passwd = getenv("MYSQL_TEST_PASSWD") ?: ""; diff --git a/ext/mysqli/tests/mysqli_begin_transaction.phpt b/ext/mysqli/tests/mysqli_begin_transaction.phpt index bed9b1bf61..7a9107b7e6 100644 --- a/ext/mysqli/tests/mysqli_begin_transaction.phpt +++ b/ext/mysqli/tests/mysqli_begin_transaction.phpt @@ -76,8 +76,11 @@ if (!have_innodb($link)) } } - if (!mysqli_begin_transaction($link, -1)) { - printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + try { + mysqli_begin_transaction($link, -1); + printf("[019] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; } if (mysqli_get_server_version($link) >= 50605) { @@ -96,9 +99,7 @@ if (!have_innodb($link)) <?php require_once("clean_table.inc"); ?> ---EXPECTF-- +--EXPECT-- NULL - -Warning: mysqli_begin_transaction(): Invalid value for parameter flags (-1) in %s on line %d -[019] [%d]%A +mysqli_begin_transaction(): Argument #2 ($flags) must be one of the MYSQLI_TRANS_* constants done! diff --git a/ext/mysqli/tests/mysqli_data_seek.phpt b/ext/mysqli/tests/mysqli_data_seek.phpt index 53c8b8354d..2b477af3fd 100644 --- a/ext/mysqli/tests/mysqli_data_seek.phpt +++ b/ext/mysqli/tests/mysqli_data_seek.phpt @@ -31,16 +31,22 @@ require_once('skipifconnectfailure.inc'); if (false !== ($tmp = mysqli_data_seek($res, 4))) printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - if (false !== ($tmp = mysqli_data_seek($res, -1))) - printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + try { + mysqli_data_seek($res, -1); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } mysqli_free_result($res); if (!$res = mysqli_query($link, 'SELECT * FROM test ORDER BY id', MYSQLI_USE_RESULT)) printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (false !== ($tmp = mysqli_data_seek($res, 3))) - printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + try { + var_dump(mysqli_data_seek($res, 3)); + } catch (\Error $e) { + echo $e->getMessage() . \PHP_EOL; + } mysqli_free_result($res); @@ -58,7 +64,8 @@ require_once('skipifconnectfailure.inc'); <?php require_once("clean_table.inc"); ?> ---EXPECTF-- -Warning: mysqli_data_seek(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d +--EXPECT-- +mysqli_data_seek(): Argument #2 ($offset) must be greater than or equal to 0 +mysqli_data_seek() cannot be used with MYSQLI_USE_RESULT mysqli_result object is already closed done! diff --git a/ext/mysqli/tests/mysqli_data_seek_oo.phpt b/ext/mysqli/tests/mysqli_data_seek_oo.phpt index 0d1ee8b79f..ccbf86542a 100644 --- a/ext/mysqli/tests/mysqli_data_seek_oo.phpt +++ b/ext/mysqli/tests/mysqli_data_seek_oo.phpt @@ -43,16 +43,22 @@ require_once('skipifconnectfailure.inc'); if (false !== ($tmp = $res->data_seek(4))) printf("[011] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); - if (false !== ($tmp = $res->data_seek(-1))) - printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + try { + $res->data_seek(-1); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } $res->free_result(); if (!$res = $mysqli->query('SELECT * FROM test ORDER BY id', MYSQLI_USE_RESULT)) printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - if (false !== ($tmp = $res->data_seek(3))) - printf("[014] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + try { + var_dump($res->data_seek(3)); + } catch (\Error $e) { + echo $e->getMessage() . \PHP_EOL; + } $res->free_result(); @@ -69,9 +75,9 @@ require_once('skipifconnectfailure.inc'); <?php require_once("clean_table.inc"); ?> ---EXPECTF-- +--EXPECT-- mysqli_result object is already closed - -Warning: mysqli_result::data_seek(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d +mysqli_result::data_seek(): Argument #1 ($offset) must be greater than or equal to 0 +mysqli_result::data_seek() cannot be used with MYSQLI_USE_RESULT mysqli_result object is already closed done! diff --git a/ext/mysqli/tests/mysqli_fetch_all.phpt b/ext/mysqli/tests/mysqli_fetch_all.phpt index 76c6b971f4..ab48821498 100644 --- a/ext/mysqli/tests/mysqli_fetch_all.phpt +++ b/ext/mysqli/tests/mysqli_fetch_all.phpt @@ -71,12 +71,12 @@ if (!function_exists('mysqli_fetch_all')) exit(1); } - do { - $illegal_mode = mt_rand(-10000, 10000); - } while (in_array($illegal_mode, array(MYSQLI_ASSOC, MYSQLI_NUM, MYSQLI_BOTH))); - // NOTE: for BC reasons with ext/mysql, ext/mysqli accepts invalid result modes. - - mysqli_fetch_all($res, $illegal_mode); + // Illegal mode + try { + mysqli_fetch_all($res, -10); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } mysqli_free_result($res); function func_mysqli_fetch_all($link, $engine, $sql_type, $sql_value, $php_value, $offset, $regexp_comparison = NULL) { @@ -315,7 +315,7 @@ if (!function_exists('mysqli_fetch_all')) <?php // require_once("clean_table.inc"); ?> ---EXPECTF-- +--EXPECT-- [005] array(2) { [0]=> @@ -443,7 +443,6 @@ array(1) { string(1) "1" } } - -Warning: mysqli_fetch_all(): Mode can be only MYSQLI_FETCH_NUM, MYSQLI_FETCH_ASSOC or MYSQLI_FETCH_BOTH in %s on line %d +mysqli_fetch_all(): Argument #2 ($mode) must be one of MYSQLI_FETCH_NUM, MYSQLI_FETCH_ASSOC, or MYSQLI_FETCH_BOTH mysqli_result object is already closed done! diff --git a/ext/mysqli/tests/mysqli_fetch_all_oo.phpt b/ext/mysqli/tests/mysqli_fetch_all_oo.phpt index 992a61a348..2b34670756 100644 --- a/ext/mysqli/tests/mysqli_fetch_all_oo.phpt +++ b/ext/mysqli/tests/mysqli_fetch_all_oo.phpt @@ -81,14 +81,14 @@ if (!function_exists('mysqli_fetch_all')) exit(1); } - do { - $illegal_mode = mt_rand(-10000, 10000); - } while (in_array($illegal_mode, array(MYSQLI_ASSOC, MYSQLI_NUM, MYSQLI_BOTH))); - // NOTE: for BC reasons with ext/mysql, ext/mysqli accepts invalid result modes. - $tmp = $res->fetch_all($illegal_mode); - if (false !== $tmp) - printf("[019] Expecting boolean/false although, got %s/%s. [%d] %s\n", - gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); + try { + $tmp = $res->fetch_all(-10); + if (false !== $tmp) + printf("[019] Expecting boolean/false although, got %s/%s. [%d] %s\n", + gettype($tmp), $tmp, $mysqli->errno, $mysqli->error); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } $res->free_result(); @@ -436,7 +436,6 @@ array(1) { string(1) "1" } } - -Warning: mysqli_result::fetch_all(): Mode can be only MYSQLI_FETCH_NUM, MYSQLI_FETCH_ASSOC or MYSQLI_FETCH_BOTH in %s on line %d +mysqli_result::fetch_all(): Argument #1 ($result_type) must be one of MYSQLI_FETCH_NUM, MYSQLI_FETCH_ASSOC, or MYSQLI_FETCH_BOTH mysqli_result object is already closed done! diff --git a/ext/mysqli/tests/mysqli_fetch_field_direct.phpt b/ext/mysqli/tests/mysqli_fetch_field_direct.phpt index 0afe6e4626..8b57cca094 100644 --- a/ext/mysqli/tests/mysqli_fetch_field_direct.phpt +++ b/ext/mysqli/tests/mysqli_fetch_field_direct.phpt @@ -16,9 +16,18 @@ require_once('skipifconnectfailure.inc'); printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } - var_dump(mysqli_fetch_field_direct($res, -1)); + try { + var_dump(mysqli_fetch_field_direct($res, -1)); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } var_dump(mysqli_fetch_field_direct($res, 0)); - var_dump(mysqli_fetch_field_direct($res, 2)); + + try { + var_dump(mysqli_fetch_field_direct($res, 2)); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } mysqli_free_result($res); @@ -36,8 +45,7 @@ require_once('skipifconnectfailure.inc'); require_once("clean_table.inc"); ?> --EXPECTF-- -Warning: mysqli_fetch_field_direct(): Field offset is invalid for resultset in %s on line %d -bool(false) +mysqli_fetch_field_direct(): Argument #2 ($offset) must be greater than or equal to 0 object(stdClass)#%d (13) { ["name"]=> string(2) "ID" @@ -66,8 +74,6 @@ object(stdClass)#%d (13) { ["decimals"]=> int(%d) } - -Warning: mysqli_fetch_field_direct(): Field offset is invalid for resultset in %s on line %d -bool(false) +mysqli_fetch_field_direct(): Argument #2 ($offset) must be less than the number of fields for this result set mysqli_result object is already closed done! diff --git a/ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt b/ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt index 33806f1c55..5dedefcdab 100644 --- a/ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt +++ b/ext/mysqli/tests/mysqli_fetch_field_direct_oo.phpt @@ -27,9 +27,19 @@ require_once('skipifconnectfailure.inc'); printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } - var_dump($res->fetch_field_direct(-1)); + try { + var_dump($res->fetch_field_direct(-1)); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } + var_dump($res->fetch_field_direct(0)); - var_dump($res->fetch_field_direct(2)); + + try { + var_dump($res->fetch_field_direct(2)); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } $res->free_result(); @@ -48,9 +58,7 @@ require_once('skipifconnectfailure.inc'); ?> --EXPECTF-- mysqli object is not fully initialized - -Warning: mysqli_result::fetch_field_direct(): Field offset is invalid for resultset in %s on line %d -bool(false) +mysqli_result::fetch_field_direct(): Argument #1 ($field_nr) must be greater than or equal to 0 object(stdClass)#%d (13) { ["name"]=> string(2) "ID" @@ -79,8 +87,6 @@ object(stdClass)#%d (13) { ["decimals"]=> int(%d) } - -Warning: mysqli_result::fetch_field_direct(): Field offset is invalid for resultset in %s on line %d -bool(false) +mysqli_result::fetch_field_direct(): Argument #1 ($field_nr) must be less than the number of fields for this result set mysqli_result object is already closed done! diff --git a/ext/mysqli/tests/mysqli_field_seek.phpt b/ext/mysqli/tests/mysqli_field_seek.phpt index 9eb9f0315b..bcc1e29526 100644 --- a/ext/mysqli/tests/mysqli_field_seek.phpt +++ b/ext/mysqli/tests/mysqli_field_seek.phpt @@ -69,7 +69,11 @@ require_once('skipifconnectfailure.inc'); printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } - var_dump(mysqli_field_seek($res, -1)); + try { + var_dump(mysqli_field_seek($res, -1)); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } var_dump(mysqli_fetch_field($res)); var_dump(mysqli_field_seek($res, 0)); var_dump(mysqli_fetch_field($res)); @@ -115,8 +119,7 @@ require_once('skipifconnectfailure.inc'); require_once("clean_table.inc"); ?> --EXPECTF-- -Warning: mysqli_field_seek(): Invalid field offset in %s on line %d -bool(false) +mysqli_field_seek(): Argument #2 ($field_nr) must be greater than or equal to 0 object(stdClass)#%d (13) { ["name"]=> string(2) "id" diff --git a/ext/mysqli/tests/mysqli_field_tell.phpt b/ext/mysqli/tests/mysqli_field_tell.phpt index bf169003aa..e8c344ec95 100644 --- a/ext/mysqli/tests/mysqli_field_tell.phpt +++ b/ext/mysqli/tests/mysqli_field_tell.phpt @@ -24,7 +24,11 @@ require_once('skipifconnectfailure.inc'); var_dump(mysqli_field_seek($res, 2)); var_dump(mysqli_field_tell($res)); - var_dump(mysqli_field_seek($res, -1)); + try { + var_dump(mysqli_field_seek($res, -1)); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } var_dump(mysqli_field_tell($res)); var_dump(mysqli_field_seek($res, 0)); @@ -85,9 +89,7 @@ int(1) Warning: mysqli_field_seek(): Invalid field offset in %s on line %d 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 greater than or equal to 0 int(1) bool(true) int(0) diff --git a/ext/mysqli/tests/mysqli_kill.phpt b/ext/mysqli/tests/mysqli_kill.phpt index 943e213a81..e4be618fc7 100644 --- a/ext/mysqli/tests/mysqli_kill.phpt +++ b/ext/mysqli/tests/mysqli_kill.phpt @@ -13,8 +13,11 @@ require_once('skipifconnectfailure.inc'); require('table.inc'); // Zend will cast the NULL to 0 - if (!is_bool($tmp = mysqli_kill($link, null))) - printf("[003] Expecting boolean/any, got %s/%s\n", gettype($tmp), $tmp); + try { + mysqli_kill($link, null); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } if (!$thread_id = mysqli_thread_id($link)) printf("[004] Cannot determine thread id, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); @@ -46,7 +49,11 @@ require_once('skipifconnectfailure.inc'); if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[010] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - mysqli_kill($link, -1); + try { + mysqli_kill($link, -1); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } if ((!$res = mysqli_query($link, "SELECT id FROM test LIMIT 1")) || (!$tmp = mysqli_fetch_assoc($res))) { printf("[011] Connection should not be gone, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); @@ -58,7 +65,12 @@ require_once('skipifconnectfailure.inc'); if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) printf("[012] Cannot connect, [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); - mysqli_change_user($link, "This might work if you accept anonymous users in your setup", "password", $db); mysqli_kill($link, -1); + mysqli_change_user($link, "This might work if you accept anonymous users in your setup", "password", $db); + try { + mysqli_kill($link, -1); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } mysqli_close($link); @@ -69,7 +81,7 @@ require_once('skipifconnectfailure.inc'); require_once("clean_table.inc"); ?> --EXPECTF-- -Warning: mysqli_kill(): processid should have positive value in %s on line %d +mysqli_kill(): Argument #2 ($connection_id) must be greater than 0 string(%d) "%s" bool(false) object(mysqli)#%d (%d) { @@ -120,12 +132,10 @@ object(mysqli)#%d (%d) { ["warning_count"]=> int(0) } - -Warning: mysqli_kill(): processid should have positive value in %s on line %d +mysqli_kill(): Argument #2 ($connection_id) must be greater than 0 array(1) { ["id"]=> string(1) "1" } - -Warning: mysqli_kill(): processid should have positive value in %s on line %d +mysqli_kill(): Argument #2 ($connection_id) must be greater than 0 done! diff --git a/ext/mysqli/tests/mysqli_num_rows.phpt b/ext/mysqli/tests/mysqli_num_rows.phpt index 3266f37dce..4d09c25682 100644 --- a/ext/mysqli/tests/mysqli_num_rows.phpt +++ b/ext/mysqli/tests/mysqli_num_rows.phpt @@ -56,8 +56,11 @@ require_once('skipifconnectfailure.inc'); if ($res = mysqli_query($link, 'SELECT id FROM test', MYSQLI_USE_RESULT)) { $row = mysqli_fetch_row($res); - if (0 !== ($tmp = mysqli_num_rows($res))) - printf("[031] Expecting int/0, got %s/%d\n", gettype($tmp), $tmp); + try { + var_dump(mysqli_num_rows($res)); + } catch (\Error $e) { + echo $e->getMessage() . \PHP_EOL; + } mysqli_free_result($res); } else { @@ -71,12 +74,11 @@ require_once('skipifconnectfailure.inc'); <?php require_once("clean_table.inc"); ?> ---EXPECTF-- +--EXPECT-- mysqli_result object is already closed mysqli_result object is already closed mysqli_result object is already closed mysqli_result object is already closed run_tests.php don't fool me with your 'ungreedy' expression '.+?'! - -Warning: mysqli_num_rows(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d +mysqli_num_rows() cannot be used with MYSQLI_USE_RESULT done! diff --git a/ext/mysqli/tests/mysqli_poll.phpt b/ext/mysqli/tests/mysqli_poll.phpt index 97b1a7e61a..cc3cc36b2f 100644 --- a/ext/mysqli/tests/mysqli_poll.phpt +++ b/ext/mysqli/tests/mysqli_poll.phpt @@ -30,12 +30,16 @@ if (!$IS_MYSQLND) printf("[009] Expecting int/0 got %s/%s\n", gettype($tmp), var_export($tmp, true)); $read = $error = $reject = array($link); - if (false !== ($tmp = (mysqli_poll($read, $error, $reject, -1, 1)))) - printf("[010] Expecting false got %s/%s\n", gettype($tmp), var_export($tmp, true)); - - $read = $error = $reject = array($link); - if (false !== ($tmp = (mysqli_poll($read, $error, $reject, 0, -1)))) - printf("[011] Expecting false got %s/%s\n", gettype($tmp), var_export($tmp, true)); + try { + mysqli_poll($read, $error, $reject, -1, 1); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } + try { + mysqli_poll($read, $error, $reject, 0, -1); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } function poll_async($offset, $link, $links, $errors, $reject, $exp_ready, $use_oo_syntax) { @@ -111,9 +115,8 @@ if (!$IS_MYSQLND) print "done!"; ?> --EXPECTF-- -Warning: mysqli_poll(): Negative values passed for sec and/or usec in %s on line %d - -Warning: mysqli_poll(): Negative values passed for sec and/or usec in %s on line %d +mysqli_poll(): Argument #4 ($sec) must be greater than or equal to 0 +mysqli_poll(): Argument #5 ($usec) must be greater than or equal to 0 [012 + 6] Rejecting thread %d: 0/ [013 + 6] Rejecting thread %d: 0/ [014 + 6] Rejecting thread %d: 0/ diff --git a/ext/mysqli/tests/mysqli_query.phpt b/ext/mysqli/tests/mysqli_query.phpt index ba159cf985..daac374cf7 100644 --- a/ext/mysqli/tests/mysqli_query.phpt +++ b/ext/mysqli/tests/mysqli_query.phpt @@ -12,8 +12,11 @@ require_once('skipifconnectfailure.inc'); require('table.inc'); - if (false !== ($tmp = @mysqli_query($link, ''))) - printf("[002a] Expecting boolean/false got %s/%s\n", gettype($tmp), $tmp); + try { + mysqli_query($link, ''); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } if (false !== ($tmp = mysqli_query($link, 'THIS IS NOT SQL'))) printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); @@ -82,11 +85,11 @@ require_once('skipifconnectfailure.inc'); printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); mysqli_free_result($res); - if (false !== ($res = @mysqli_query($link, "SELECT id FROM test ORDER BY id", 1234))) - printf("[013] Invalid mode should return false got %s/%s, [%d] %s\n", - gettype($res), (is_object($res)) ? 'object' : $res, - mysqli_errno($link), mysqli_error($link)); - + try { + mysqli_query($link, "SELECT id FROM test ORDER BY id", 1234); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } mysqli_close($link); @@ -113,6 +116,7 @@ if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) mysqli_close($link); ?> --EXPECT-- +mysqli_query(): Argument #2 ($query) cannot be empty array(1) { ["valid"]=> string(30) "this is sql but with semicolon" @@ -122,5 +126,6 @@ array(1) { string(1) "a" } string(1) "a" +mysqli_query(): Argument #3 ($result_mode) must be either MYSQLI_USE_RESULT, or MYSQLI_STORE_RESULT with MYSQLI_ASYNC as an optional bitmask flag mysqli object is already closed done! diff --git a/ext/mysqli/tests/mysqli_release_savepoint.phpt b/ext/mysqli/tests/mysqli_release_savepoint.phpt index 92f85c8b75..fa46366e7c 100644 --- a/ext/mysqli/tests/mysqli_release_savepoint.phpt +++ b/ext/mysqli/tests/mysqli_release_savepoint.phpt @@ -23,8 +23,11 @@ if (!have_innodb($link)) printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); - if (false !== ($tmp = mysqli_release_savepoint($link, ''))) - printf("[006] Expecting false, got %s/%s\n", gettype($tmp), $tmp); + try { + mysqli_release_savepoint($link, ''); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); @@ -61,8 +64,8 @@ if (!have_innodb($link)) <?php require_once("clean_table.inc"); ?> ---EXPECTF-- -Warning: mysqli_release_savepoint(): Savepoint name cannot be empty in %s on line %d +--EXPECT-- +mysqli_release_savepoint(): Argument #2 ($name) cannot be empty array(1) { ["id"]=> string(1) "1" diff --git a/ext/mysqli/tests/mysqli_report.phpt b/ext/mysqli/tests/mysqli_report.phpt index 17baea0f66..6f5733513c 100644 --- a/ext/mysqli/tests/mysqli_report.phpt +++ b/ext/mysqli/tests/mysqli_report.phpt @@ -37,7 +37,11 @@ require_once('skipifconnectfailure.inc'); mysqli_multi_query($link, "BAR; FOO;"); mysqli_query($link, "FOO"); - mysqli_kill($link, -1); + try { + mysqli_kill($link, -1); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } // mysqli_ping() cannot be tested, because one would need to cause an error inside the C function to test it mysqli_prepare($link, "FOO"); @@ -53,7 +57,11 @@ require_once('skipifconnectfailure.inc'); mysqli_multi_query($link, "BAR; FOO;"); mysqli_query($link, "FOO"); - mysqli_kill($link, -1); + try { + mysqli_kill($link, -1); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } mysqli_prepare($link, "FOO"); mysqli_real_query($link, "FOO"); mysqli_select_db($link, "Oh lord, let this be an unknown database name"); @@ -280,14 +288,12 @@ require_once('skipifconnectfailure.inc'); Warning: mysqli_multi_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'BAR; FOO' at line 1 in %s on line %d Warning: mysqli_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'FOO' at line 1 in %s on line %d - -Warning: mysqli_kill(): processid should have positive value in %s on line %d +mysqli_kill(): Argument #2 ($connection_id) must be greater than 0 Warning: mysqli_prepare(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'FOO' at line 1 in %s on line %d Warning: mysqli_real_query(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'FOO' at line 1 in %s on line %d - -Warning: mysqli_kill(): processid should have positive value in %s on line %d +mysqli_kill(): Argument #2 ($connection_id) must be greater than 0 Warning: mysqli_stmt_prepare(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'FOO' at line 1 in %s on line %d [013] Access denied for user '%s'@'%s' (using password: YES) diff --git a/ext/mysqli/tests/mysqli_result_invalid_mode.phpt b/ext/mysqli/tests/mysqli_result_invalid_mode.phpt index 9f902920db..374fccfa61 100644 --- a/ext/mysqli/tests/mysqli_result_invalid_mode.phpt +++ b/ext/mysqli/tests/mysqli_result_invalid_mode.phpt @@ -12,19 +12,19 @@ require_once('skipifconnectfailure.inc'); require('table.inc'); $valid = array(MYSQLI_STORE_RESULT, MYSQLI_USE_RESULT); - do { - $mode = mt_rand(-1000, 1000); - } while (in_array($mode, $valid)); - - if (!is_object($res = new mysqli_result($link, $mode))) - printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); - - print "done!"; + $invalidModes = [-1, 152]; + foreach ($invalidModes as $mode) { + try { + new mysqli_result($link, $mode); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } + } ?> --CLEAN-- <?php require_once("clean_table.inc"); ?> ---EXPECTF-- -Warning: mysqli_result::__construct(): Invalid value for resultmode in %s on line %d -done! +--EXPECT-- +mysqli_result::__construct(): Argument #2 ($result_mode) must be either MYSQLI_STORE_RESULT or MYSQLI_USE_RESULT +mysqli_result::__construct(): Argument #2 ($result_mode) must be either MYSQLI_STORE_RESULT or MYSQLI_USE_RESULT diff --git a/ext/mysqli/tests/mysqli_savepoint.phpt b/ext/mysqli/tests/mysqli_savepoint.phpt index 524d21e5c3..1001625667 100644 --- a/ext/mysqli/tests/mysqli_savepoint.phpt +++ b/ext/mysqli/tests/mysqli_savepoint.phpt @@ -21,8 +21,11 @@ if (!have_innodb($link)) printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); - if (false !== ($tmp = mysqli_savepoint($link, ''))) - printf("[006] Expecting false, got %s/%s\n", gettype($tmp), $tmp); + try { + mysqli_savepoint($link, ''); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); @@ -50,6 +53,6 @@ if (!have_innodb($link)) <?php require_once("clean_table.inc"); ?> ---EXPECTF-- -Warning: mysqli_savepoint(): Savepoint name cannot be empty in %s on line %d +--EXPECT-- +mysqli_savepoint(): Argument #2 ($name) cannot be empty done! diff --git a/ext/mysqli/tests/mysqli_stmt_attr_get.phpt b/ext/mysqli/tests/mysqli_stmt_attr_get.phpt index 0844a6c8ac..6179155e77 100644 --- a/ext/mysqli/tests/mysqli_stmt_attr_get.phpt +++ b/ext/mysqli/tests/mysqli_stmt_attr_get.phpt @@ -19,20 +19,17 @@ require_once('skipifconnectfailure.inc'); if ($IS_MYSQLND && mysqli_get_client_version() > 50007) $valid_attr["prefetch_rows"] = MYSQLI_STMT_ATTR_PREFETCH_ROWS; - do { - $invalid_attr = mt_rand(0, 10000); - } while (in_array($invalid_attr, $valid_attr)); - $stmt = mysqli_stmt_init($link); mysqli_stmt_prepare($stmt, 'SELECT * FROM test'); try { - mysqli_stmt_attr_get($stmt, $invalid_attr); - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; + mysqli_stmt_attr_get($stmt, -100); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; } foreach ($valid_attr as $k => $attr) { + /* This can't happen anymore as it only returns int */ if (false === ($tmp = mysqli_stmt_attr_get($stmt, $attr))) { printf("[006] Expecting any type, but not boolean/false, got %s/%s for attribute %s/%s\n", gettype($tmp), $tmp, $k, $attr); @@ -44,7 +41,7 @@ require_once('skipifconnectfailure.inc'); foreach ($valid_attr as $k => $attr) { try { mysqli_stmt_attr_get($stmt, $attr); - } catch (Error $exception) { + } catch (Throwable $exception) { echo $exception->getMessage() . "\n"; } } @@ -57,6 +54,7 @@ require_once('skipifconnectfailure.inc'); require_once("clean_table.inc"); ?> --EXPECT-- +mysqli_stmt_attr_get(): Argument #2 ($attr) must be one of MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, MYSQLI_STMT_ATTR_PREFETCH_ROWS, or STMT_ATTR_CURSOR_TYPE mysqli_stmt object is already closed mysqli_stmt object is already closed mysqli_stmt object is already closed diff --git a/ext/mysqli/tests/mysqli_stmt_attr_set.phpt b/ext/mysqli/tests/mysqli_stmt_attr_set.phpt index 4fad53cba2..870960e602 100644 --- a/ext/mysqli/tests/mysqli_stmt_attr_set.phpt +++ b/ext/mysqli/tests/mysqli_stmt_attr_set.phpt @@ -28,38 +28,28 @@ require_once("connect.inc"); $stmt = mysqli_stmt_init($link); try { mysqli_stmt_attr_set($stmt, 0, 0); - } catch (Error $exception) { - echo $exception->getMessage() . "\n"; + } catch (\Throwable $e) { + echo get_class($e) . ': ' . $e->getMessage() . PHP_EOL; } $stmt->prepare("SELECT * FROM test"); - - mt_srand(microtime(true)); - - for ($i = -100; $i < 1000; $i++) { - if (in_array($i, $valid_attr)) - continue; - $invalid_attr = $i; - if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0))) { - printf("[006a] Expecting boolean/false for attribute %d, got %s/%s\n", $invalid_attr, gettype($tmp), $tmp); - } + // Invalid Attribute (2nd argument) + try { + mysqli_stmt_attr_set($stmt, -1, 0); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; } - - for ($i = 0; $i < 2; $i++) { - do { - $invalid_attr = mt_rand(-1 * (min(4294967296, PHP_INT_MAX) + 1), min(4294967296, PHP_INT_MAX)); - } while (in_array($invalid_attr, $valid_attr)); - if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, $invalid_attr, 0))) { - printf("[006b] Expecting boolean/false for attribute %d, got %s/%s\n", $invalid_attr, gettype($tmp), $tmp); - } + // Invalid mode for MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH + try { + $stmt->attr_set(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, -1); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; } $stmt->close(); // // MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH // - - // expecting max_length not to be set and be 0 in all cases $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT label FROM test"); @@ -79,7 +69,7 @@ require_once("connect.inc"); // expecting max_length to _be_ set $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT label FROM test"); - $stmt->attr_set(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, 1); + var_dump($stmt->attr_set(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, 1)); $res = $stmt->attr_get(MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH); if ($res !== 1) printf("[007.1] max_length should be 1, got %s\n", $res); @@ -122,21 +112,15 @@ require_once("connect.inc"); if (mysqli_get_client_version() > 50003) { - $cursor_types = array( - MYSQLI_CURSOR_TYPE_NO_CURSOR, - MYSQLI_CURSOR_TYPE_READ_ONLY, - MYSQLI_CURSOR_TYPE_FOR_UPDATE, - MYSQLI_CURSOR_TYPE_SCROLLABLE - ); - do { - $invalid_cursor_type = mt_rand(-1000, 1000); - } while (in_array($invalid_cursor_type, $cursor_types)); - $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT id, label FROM test"); - if (false !== ($tmp = @$stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, $invalid_cursor_type))) - printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + // Invalid cursor type + try { + $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, -1); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } if (false !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_FOR_UPDATE))) printf("[011] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); @@ -209,6 +193,13 @@ require_once("connect.inc"); $stmt = mysqli_stmt_init($link); $stmt->prepare("SELECT id, label FROM test"); + // Invalid prefetch value + try { + $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, 0); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } + if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, 1))) printf("[020] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); $stmt->execute(); @@ -262,5 +253,10 @@ require_once("connect.inc"); require_once("clean_table.inc"); ?> --EXPECT-- -mysqli_stmt object is not fully initialized +Error: mysqli_stmt object is not fully initialized +mysqli_stmt_attr_set(): Argument #2 ($attr) must be one of MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, MYSQLI_STMT_ATTR_PREFETCH_ROWS, or STMT_ATTR_CURSOR_TYPE +mysqli_stmt::attr_set(): Argument #2 ($mode_in) must be 0 or 1 for attribute MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH +bool(true) +mysqli_stmt::attr_set(): Argument #2 ($mode_in) must be one of MYSQLI_CURSOR_TYPE_NO_CURSOR, MYSQLI_CURSOR_TYPE_READ_ONLY, MYSQLI_CURSOR_TYPE_FOR_UPDATE, or MYSQLI_CURSOR_TYPE_SCROLLABLE for attribute MYSQLI_STMT_ATTR_CURSOR_TYPE +mysqli_stmt::attr_set(): Argument #2 ($mode_in) must be greater than 0 for attribute MYSQLI_STMT_ATTR_PREFETCH_ROWS done! diff --git a/ext/mysqli/tests/mysqli_stmt_bind_param.phpt b/ext/mysqli/tests/mysqli_stmt_bind_param.phpt index aba40decf4..a12e01dc42 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_param.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_param.phpt @@ -32,35 +32,77 @@ require_once('skipifconnectfailure.inc'); libmysql gives a less descriptive error message but mysqlnd, we did not unify the error messages but ignore this slight difference silently */ - if (!false === ($tmp = @mysqli_stmt_bind_param($stmt, " ", $tmp))) - printf("[003d] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + try { + if (!false === ($tmp = mysqli_stmt_bind_param($stmt, " ", $tmp))) + printf("[003d] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + } catch (\ArgumentCountError $e) { + echo $e->getMessage() . \PHP_EOL; + } - if (!false === ($tmp = @mysqli_stmt_bind_param($stmt, "", $id, $label))) - printf("[003a] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + try { + if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "", $id, $label))) + printf("[003a] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } /* TODO: somehwhat undocumented syntax! */ $param = array($id); - if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "is", $param))) - printf("[003b] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + try { + if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "is", $param))) + printf("[003b] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + } catch (\ArgumentCountError $e) { + echo $e->getMessage() . \PHP_EOL; + } $param = array($id, $label, $id); - if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "is", $param))) - printf("[003c] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + try { + if (!false === ($tmp = mysqli_stmt_bind_param($stmt, " ", $tmp))) + printf("[003d] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + } catch (\ArgumentCountError $e) { + echo $e->getMessage() . \PHP_EOL; + } + try { + if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "is", $param))) + printf("[003c] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + } catch (\ArgumentCountError $e) { + echo $e->getMessage() . \PHP_EOL; + } - if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "a", $id))) - printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + try { + if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "a", $id))) + printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + } catch (\ArgumentCountError $e) { + echo $e->getMessage() . \PHP_EOL; + } - if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "a", $id, $label))) - printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + try { + if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "a", $id, $label))) + printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + } catch (\ArgumentCountError $e) { + echo $e->getMessage() . \PHP_EOL; + } - if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "aa", $id, $label))) - printf("[006] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + try { + if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "aa", $id, $label))) + printf("[006] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + } catch (\ArgumentCountError $e) { + echo $e->getMessage() . \PHP_EOL; + } - if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "ia", $id, $label))) - printf("[007] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + try { + if (!false === ($tmp = mysqli_stmt_bind_param($stmt, "ia", $id, $label))) + printf("[007] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + } catch (\ArgumentCountError $e) { + echo $e->getMessage() . \PHP_EOL; + } - if (!true === ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) - printf("[008] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + try { + if (!true === ($tmp = mysqli_stmt_bind_param($stmt, "is", $id, $label))) + printf("[008] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + } catch (\ArgumentCountError $e) { + echo $e->getMessage() . \PHP_EOL; + } if (function_exists("memory_get_usage")) { $mem = memory_get_usage(); @@ -374,13 +416,13 @@ require_once('skipifconnectfailure.inc'); require_once("clean_table.inc"); ?> --EXPECTF-- -Warning: mysqli_stmt_bind_param(): Number of elements in type definition string doesn't match number of bind variables in %s on line %d - -Warning: mysqli_stmt_bind_param(): Number of elements in type definition string doesn't match number of bind variables in %s on line %d - -Warning: mysqli_stmt_bind_param(): Number of variables doesn't match number of parameters in prepared statement in %s on line %d - -Warning: mysqli_stmt_bind_param(): Number of elements in type definition string doesn't match number of bind variables in %s on line %d +The number of variables must match the number of parameters in the prepared statement +mysqli_stmt_bind_param(): Argument #2 ($types) cannot be empty +The number of elements in the type definition string must match the number of bind variables +The number of variables must match the number of parameters in the prepared statement +The number of elements in the type definition string must match the number of bind variables +The number of variables must match the number of parameters in the prepared statement +The number of elements in the type definition string must match the number of bind variables Warning: mysqli_stmt_bind_param(): Undefined fieldtype a (parameter 3) in %s on line %d diff --git a/ext/mysqli/tests/mysqli_stmt_bind_result.phpt b/ext/mysqli/tests/mysqli_stmt_bind_result.phpt index c1dddca4f2..f9556ad0f6 100644 --- a/ext/mysqli/tests/mysqli_stmt_bind_result.phpt +++ b/ext/mysqli/tests/mysqli_stmt_bind_result.phpt @@ -31,14 +31,20 @@ require_once('skipifconnectfailure.inc'); if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 1")) printf("[004] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); - if (false !== ($tmp = mysqli_stmt_bind_result($stmt, $id))) - printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + try { + mysqli_stmt_bind_result($stmt, $id); + } catch (\ArgumentCountError $e) { + echo $e->getMessage() . PHP_EOL; + } if (true !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label))) printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp); - if (false !== ($tmp = mysqli_stmt_bind_result($stmt, $id, $label, $foo))) - printf("[007] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); + try { + mysqli_stmt_bind_result($stmt, $id, $label, $foo); + } catch (\ArgumentCountError $e) { + echo $e->getMessage() . PHP_EOL; + } if (!mysqli_stmt_execute($stmt)) printf("[008] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); @@ -290,8 +296,11 @@ require_once('skipifconnectfailure.inc'); printf("[3001] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); $id = null; - if (false !== @mysqli_stmt_bind_result($stmt, $id)) - printf("[3002] Bind result should not be allowed"); + try { + mysqli_stmt_bind_result($stmt, $id); + } catch (\ArgumentCountError $e) { + $e->getMessage() . \PHP_EOL; + } mysqli_stmt_close($stmt); @@ -304,10 +313,8 @@ require_once('skipifconnectfailure.inc'); ?> --EXPECTF-- mysqli_stmt object is not fully initialized - -Warning: mysqli_stmt_bind_result(): Number of bind variables doesn't match number of fields in prepared statement in %s on line %d - -Warning: mysqli_stmt_bind_result(): Number of bind variables doesn't match number of fields in prepared statement in %s on line %d +Number of bind variables doesn't match number of fields in prepared statement +Number of bind variables doesn't match number of fields in prepared statement int(1) %s(1) "a" done! diff --git a/ext/mysqli/tests/mysqli_stmt_data_seek.phpt b/ext/mysqli/tests/mysqli_stmt_data_seek.phpt index 72d807512f..5594600747 100644 --- a/ext/mysqli/tests/mysqli_stmt_data_seek.phpt +++ b/ext/mysqli/tests/mysqli_stmt_data_seek.phpt @@ -59,8 +59,11 @@ require_once('skipifconnectfailure.inc'); var_dump($id); - if (false !== ($tmp = mysqli_stmt_data_seek($stmt, -1))) - printf("[015] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); + try { + mysqli_stmt_data_seek($stmt, -1); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } if (mysqli_stmt_fetch($stmt)) printf("[016] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); @@ -87,8 +90,7 @@ mysqli_stmt object is not fully initialized int(3) int(1) int(1) - -Warning: mysqli_stmt_data_seek(): Offset must be positive in %s on line %d +mysqli_stmt_data_seek(): Argument #2 ($offset) must be greater than or equal to 0 int(1) mysqli_stmt object is already closed done! diff --git a/ext/mysqli/tests/mysqli_stmt_execute_stored_proc_out.phpt b/ext/mysqli/tests/mysqli_stmt_execute_stored_proc_out.phpt index c65330ebc9..7cbbc74988 100644 --- a/ext/mysqli/tests/mysqli_stmt_execute_stored_proc_out.phpt +++ b/ext/mysqli/tests/mysqli_stmt_execute_stored_proc_out.phpt @@ -44,8 +44,12 @@ if ($IS_MYSQLND) { printf("[008] More results: %s\n", (mysqli_more_results($link) ? "yes" : "no")); printf("[009] Next results: %s\n", (mysqli_next_result($link) ? "yes" : "no")); - if (!mysqli_stmt_bind_result($stmt, $ver_out) || !mysqli_stmt_fetch($stmt)) - printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + try { + if (!mysqli_stmt_bind_result($stmt, $ver_out) || !mysqli_stmt_fetch($stmt)) + printf("[010] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + } catch (\ArgumentCountError $e) { + echo $e->getMessage() . \PHP_EOL; + } if ("myversion" !== $ver_out) printf("[011] Results seem wrong got '%s'\n", $ver_out); diff --git a/ext/mysqli/tests/mysqli_stmt_field_count.phpt b/ext/mysqli/tests/mysqli_stmt_field_count.phpt index 51afb04e1b..5c725cd063 100644 --- a/ext/mysqli/tests/mysqli_stmt_field_count.phpt +++ b/ext/mysqli/tests/mysqli_stmt_field_count.phpt @@ -51,8 +51,12 @@ require_once('skipifconnectfailure.inc'); printf("[013] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); $label = null; - if (mysqli_stmt_bind_param($stmt, "s", $label)) - printf("[014] expected error - got ok\n"); + try { + if (mysqli_stmt_bind_param($stmt, "s", $label)) + printf("[014] expected error - got ok\n"); + } catch (\ArgumentCountError $e) { + echo $e->getMessage() . \PHP_EOL; + } while (mysqli_stmt_fetch($stmt)) if (1 !== ($tmp = mysqli_stmt_field_count($stmt))) printf("[015] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp); @@ -91,11 +95,10 @@ require_once('skipifconnectfailure.inc'); <?php require_once("clean_table.inc"); ?> ---EXPECTF-- +--EXPECT-- mysqli_stmt object is not fully initialized mysqli_stmt object is not fully initialized - -Warning: mysqli_stmt_bind_param(): Number of variables doesn't match number of parameters in prepared statement in %s on line %d +The number of variables must match the number of parameters in the prepared statement mysqli_stmt object is already closed mysqli_stmt object is already closed done! diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_metadata.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_metadata.phpt index cb95ed896a..9e6ddec044 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result_metadata.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result_metadata.phpt @@ -182,11 +182,19 @@ if (!function_exists('mysqli_stmt_get_result')) printf("[032] Expecting %s/%s got %s/%s\n", gettype($pos), $pos, gettype($tmp), $tmp); } else { - - if (false !== @mysqli_field_seek($res, $pos)) - printf("[033] field_seek(%d) did not fail\n", $pos); - if (false !== @mysqli_field_seek($res_meta, $pos)) - printf("[034] field_seek(%d) did not fail\n", $pos); + try { + $tmp = @mysqli_field_seek($res, $pos); + if ($pos >= $num && $tmp !== false) { + printf("[033] field_seek(%d) did not fail\n", $pos); + } + } catch (ValueError $e) { /* Suppress output because pos is RANDOM */} + + try { + $tmp = @mysqli_field_seek($res_meta, $pos); + if ($pos >= $num && $tmp !== false) { + printf("[034] field_seek(%d) did not fail\n", $pos); + } + } catch (ValueError $e) { /* Suppress output because pos is RANDOM */} } } diff --git a/ext/mysqli/tests/mysqli_stmt_get_result_seek.phpt b/ext/mysqli/tests/mysqli_stmt_get_result_seek.phpt index 68dad8b281..cf9e634cc9 100644 --- a/ext/mysqli/tests/mysqli_stmt_get_result_seek.phpt +++ b/ext/mysqli/tests/mysqli_stmt_get_result_seek.phpt @@ -61,8 +61,11 @@ if (!function_exists('mysqli_stmt_get_result')) } } - if (false !== ($tmp = $res->data_seek(-1))) - printf("[011] Expecting boolean/false got %s/%s\n", gettype($tmp), $tmp); + try { + $res->data_seek(-1); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } if (false !== ($tmp = $res->data_seek($res->num_rows + 1))) printf("[012] Expecting boolean/false got %s/%s\n", gettype($tmp), $tmp); @@ -70,18 +73,20 @@ if (!function_exists('mysqli_stmt_get_result')) for ($i = 0; $i < 100; $i++) { /* intentionally out of range! */ $pos = mt_rand(-1, 4); - $tmp = mysqli_data_seek($res, $pos); - if (($pos >= 0 && $pos < 3)) { - if (true !== $tmp) - printf("[015] Expecting boolan/true got %s/%s\n", gettype($tmp), $tmp); - $row = $res->fetch_array(MYSQLI_NUM); - if ($row[0] !== $pos + 1) - printf("[016] Expecting id = %d for pos %d got %s/%s\n", - $pos + 1, $pos, gettype($row[0]), $row[0]); - } else { - if (false !== $tmp) - printf("[014] Expecting boolan/false got %s/%s\n", gettype($tmp), $tmp); - } + try { + $tmp = @mysqli_data_seek($res, $pos); + if (($pos >= 0 && $pos < 3)) { + if (true !== $tmp) + printf("[015] Expecting boolan/true got %s/%s\n", gettype($tmp), $tmp); + $row = $res->fetch_array(MYSQLI_NUM); + if ($row[0] !== $pos + 1) + printf("[016] Expecting id = %d for pos %d got %s/%s\n", + $pos + 1, $pos, gettype($row[0]), $row[0]); + } else { + if (false !== $tmp) + printf("[014] Expecting boolan/false got %s/%s\n", gettype($tmp), $tmp); + } + } catch (\ValueError $e) { /* Suppress because RANDOM */} } mysqli_stmt_close($stmt); @@ -127,6 +132,7 @@ if (!function_exists('mysqli_stmt_get_result')) require_once("clean_table.inc"); ?> --EXPECT-- +mysqli_result::data_seek(): Argument #1 ($offset) must be greater than or equal to 0 mysqli_result object is already closed mysqli_result object is already closed mysqli_result object is already closed diff --git a/ext/mysqli/tests/mysqli_stmt_send_long_data.phpt b/ext/mysqli/tests/mysqli_stmt_send_long_data.phpt index 00afa5513d..705f19e8c2 100644 --- a/ext/mysqli/tests/mysqli_stmt_send_long_data.phpt +++ b/ext/mysqli/tests/mysqli_stmt_send_long_data.phpt @@ -64,9 +64,11 @@ require_once('skipifconnectfailure.inc'); */ assert(strlen($blob) <= $max_allowed_packet); - if (false !== ($tmp = mysqli_stmt_send_long_data($stmt, -1, $blob))) - printf("[012] Expecting boolean/false, got %s/%s. [%d] %s\n", - gettype($tmp), $tmp, mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt)); + try { + $tmp = mysqli_stmt_send_long_data($stmt, -1, $blob); + } catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; + } if (false !== ($tmp = mysqli_stmt_send_long_data($stmt, 999, $blob))) printf("[014] Expecting boolean/false, got %s/%s. [%d] %s\n", @@ -106,6 +108,6 @@ require_once('skipifconnectfailure.inc'); <?php require_once("clean_table.inc"); ?> ---EXPECTF-- -Warning: mysqli_stmt_send_long_data(): Invalid parameter number in %s on line %d +--EXPECT-- +mysqli_stmt_send_long_data(): Argument #2 ($param_nr) must be greater than or equal to 0 done! diff --git a/ext/mysqli/tests/mysqli_store_result_copy.phpt b/ext/mysqli/tests/mysqli_store_result_copy.phpt index 136e2c5d4d..c431a05a60 100644 --- a/ext/mysqli/tests/mysqli_store_result_copy.phpt +++ b/ext/mysqli/tests/mysqli_store_result_copy.phpt @@ -63,12 +63,16 @@ mysqlnd.fetch_data_copy=0 $no_result = 0; for ($i = 0; $i < 1000; $i++) { $idx = mt_rand(-100, 100); - if (true === @mysqli_data_seek($res, $idx)) { - $row = $res->fetch_assoc(); - if (!isset($row['id']) || !isset($row['label'])) { - printf("[010] Brute force seek %d returned %d\n", $idx, var_export($row, true)); + try { + if (true === @mysqli_data_seek($res, $idx)) { + $row = $res->fetch_assoc(); + if (!isset($row['id']) || !isset($row['label'])) { + printf("[010] Brute force seek %d returned %d\n", $idx, var_export($row, true)); + } + } else { + $no_result++; } - } else { + } catch (\ValueError $e) { $no_result++; } } diff --git a/ext/mysqli/tests/mysqli_use_result.phpt b/ext/mysqli/tests/mysqli_use_result.phpt index 1b679d142d..c309d3e391 100644 --- a/ext/mysqli/tests/mysqli_use_result.phpt +++ b/ext/mysqli/tests/mysqli_use_result.phpt @@ -19,9 +19,11 @@ require_once('skipifconnectfailure.inc'); printf("[004] Expecting object, got %s/%s. [%d] %s\n", gettype($res), $res, mysqli_errno($link), mysqli_error($link)); - if (false !== ($tmp = mysqli_data_seek($res, 2))) - printf("[005] Expecting boolean/true, got %s/%s. [%d] %s\n", - gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link)); + try { + var_dump(mysqli_data_seek($res, 2)); + } catch (\Error $e) { + echo $e->getMessage() . \PHP_EOL; + } mysqli_free_result($res); @@ -53,7 +55,7 @@ require_once('skipifconnectfailure.inc'); <?php require_once("clean_table.inc"); ?> ---EXPECTF-- -Warning: mysqli_data_seek(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d +--EXPECT-- +mysqli_data_seek() cannot be used with MYSQLI_USE_RESULT mysqli object is already closed done! |
