1
0
mirror of https://github.com/php/php-src.git synced 2026-04-13 02:52:48 +02:00

Promote mysqli warnings to exceptions

Closes GH-5058
This commit is contained in:
Máté Kocsis
2020-01-05 19:49:34 +01:00
parent 453713868f
commit 5bf6aedae4
113 changed files with 1263 additions and 787 deletions

View File

@@ -312,7 +312,7 @@ zval *mysqli_read_property(zend_object *object, zend_string *name, int type, voi
}
if (hnd) {
if (hnd->read_func(obj, rv, type == BP_VAR_IS) == SUCCESS || type != BP_VAR_IS) {
if (hnd->read_func(obj, rv, type == BP_VAR_IS) == SUCCESS) {
retval = rv;
} else {
retval = &EG(uninitialized_zval);
@@ -409,6 +409,7 @@ HashTable *mysqli_object_get_debug_info(zend_object *object, int *is_temp)
ZEND_HASH_FOREACH_PTR(props, entry) {
zval rv;
zval *value;
value = mysqli_read_property(object, entry->name, BP_VAR_IS, 0, &rv);
if (value != &EG(uninitialized_zval)) {
zend_hash_add(retval, entry->name, value);
@@ -470,7 +471,7 @@ static MYSQLND *mysqli_convert_zv_to_mysqlnd(zval * zv)
mysqli_object *intern = Z_MYSQLI_P(zv);
if (!(my_res = (MYSQLI_RESOURCE *)intern->ptr)) {
/* We know that we have a mysqli object, so this failure should be emitted */
php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(intern->zo.ce->name));
zend_throw_error(NULL, "%s object is already closed", ZSTR_VAL(intern->zo.ce->name));
return NULL;
}
mysql = (MY_MYSQL *)(my_res->ptr);

View File

@@ -731,7 +731,7 @@ static int mysqlnd_zval_array_to_mysqlnd_array(zval *in_array, MYSQLND ***out_ar
int i = 0, current = 0;
if (Z_TYPE_P(in_array) != IS_ARRAY) {
return 0;
return SUCCESS;
}
*out_array = ecalloc(zend_hash_num_elements(Z_ARRVAL_P(in_array)) + 1, sizeof(MYSQLND *));
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(in_array), elem) {
@@ -744,18 +744,18 @@ static int mysqlnd_zval_array_to_mysqlnd_array(zval *in_array, MYSQLND ***out_ar
MYSQLI_RESOURCE *my_res;
mysqli_object *intern = Z_MYSQLI_P(elem);
if (!(my_res = (MYSQLI_RESOURCE *)intern->ptr)) {
php_error_docref(NULL, E_WARNING, "[%d] Couldn't fetch %s", i, ZSTR_VAL(intern->zo.ce->name));
continue;
zend_throw_error(NULL, "%s object is already closed", ZSTR_VAL(intern->zo.ce->name));
return FAILURE;
}
mysql = (MY_MYSQL*) my_res->ptr;
if (MYSQLI_STATUS_VALID && my_res->status < MYSQLI_STATUS_VALID) {
php_error_docref(NULL, E_WARNING, "Invalid object %d or resource %s", i, ZSTR_VAL(intern->zo.ce->name));
continue;
zend_throw_error(NULL, "%s object is not fully initialized", ZSTR_VAL(intern->zo.ce->name));
return FAILURE;
}
(*out_array)[current++] = mysql->mysql;
}
} ZEND_HASH_FOREACH_END();
return 0;
return SUCCESS;
}
/* }}} */
@@ -859,10 +859,16 @@ PHP_FUNCTION(mysqli_poll)
}
if (r_array != NULL) {
mysqlnd_zval_array_to_mysqlnd_array(r_array, &new_r_array);
if (mysqlnd_zval_array_to_mysqlnd_array(r_array, &new_r_array) == FAILURE) {
efree(new_r_array);
RETURN_THROWS();
}
}
if (e_array != NULL) {
mysqlnd_zval_array_to_mysqlnd_array(e_array, &new_e_array);
if (mysqlnd_zval_array_to_mysqlnd_array(e_array, &new_e_array) == FAILURE) {
efree(new_e_array);
RETURN_THROWS();
}
}
ret = mysqlnd_poll(new_r_array, new_e_array, &new_dont_poll_array, sec, usec, &desc_num);

View File

@@ -30,9 +30,8 @@
#define CHECK_STATUS(value, quiet) \
if (!obj->ptr || ((MYSQLI_RESOURCE *)obj->ptr)->status < value ) { \
if (!quiet) { \
php_error_docref(NULL, E_WARNING, "Property access is not allowed yet"); \
zend_throw_error(NULL, "Property access is not allowed yet"); \
} \
ZVAL_FALSE(retval); \
return FAILURE; \
} \
@@ -40,9 +39,8 @@
MYSQL *p; \
if (!obj->ptr || !(MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr) { \
if (!quiet) { \
php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(obj->zo.ce->name)); \
zend_throw_error(NULL, "%s object is already closed", ZSTR_VAL(obj->zo.ce->name)); \
} \
ZVAL_FALSE(retval);\
return FAILURE; \
} else { \
CHECK_STATUS(statusval, quiet);\
@@ -53,9 +51,8 @@ if (!obj->ptr || !(MY_MYSQL *)((MYSQLI_RESOURCE *)(obj->ptr))->ptr) { \
MYSQL_RES *p; \
if (!obj->ptr) { \
if (!quiet) { \
php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(obj->zo.ce->name)); \
zend_throw_error(NULL, "%s object is already closed", ZSTR_VAL(obj->zo.ce->name)); \
} \
ZVAL_NULL(retval);\
return FAILURE; \
} else { \
CHECK_STATUS(statusval, quiet);\
@@ -66,9 +63,8 @@ if (!obj->ptr) { \
MYSQL_STMT *p; \
if (!obj->ptr) { \
if (!quiet) { \
php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(obj->zo.ce->name)); \
zend_throw_error(NULL, "%s object is already closed", ZSTR_VAL(obj->zo.ce->name)); \
} \
ZVAL_NULL(retval);\
return FAILURE; \
} else { \
CHECK_STATUS(statusval, quiet); \

View File

@@ -203,9 +203,8 @@ static int mysqli_warning_message(mysqli_object *obj, zval *retval, zend_bool qu
if (!obj->ptr || !((MYSQLI_RESOURCE *)(obj->ptr))->ptr) {
if (!quiet) {
php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(obj->zo.ce->name));
zend_throw_error(NULL, "Couldn't fetch %s", ZSTR_VAL(obj->zo.ce->name));
}
ZVAL_NULL(retval);
return FAILURE;
}
@@ -224,9 +223,8 @@ static int mysqli_warning_sqlstate(mysqli_object *obj, zval *retval, zend_bool q
if (!obj->ptr || !((MYSQLI_RESOURCE *)(obj->ptr))->ptr) {
if (!quiet) {
php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(obj->zo.ce->name));
zend_throw_error(NULL, "Couldn't fetch %s", ZSTR_VAL(obj->zo.ce->name));
}
ZVAL_NULL(retval);
return FAILURE;
}
@@ -245,9 +243,8 @@ static int mysqli_warning_errno(mysqli_object *obj, zval *retval, zend_bool quie
if (!obj->ptr || !((MYSQLI_RESOURCE *)(obj->ptr))->ptr) {
if (!quiet) {
php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(obj->zo.ce->name));
zend_throw_error(NULL, "Couldn't fetch %s", ZSTR_VAL(obj->zo.ce->name));
}
ZVAL_NULL(retval);
return FAILURE;
}

View File

@@ -246,13 +246,13 @@ extern void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * resul
MYSQLI_RESOURCE *my_res; \
mysqli_object *intern = Z_MYSQLI_P(__id); \
if (!(my_res = (MYSQLI_RESOURCE *)intern->ptr)) {\
php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(intern->zo.ce->name));\
RETURN_FALSE;\
zend_throw_error(NULL, "%s object is already closed", ZSTR_VAL(intern->zo.ce->name));\
RETURN_THROWS();\
}\
__ptr = (__type)my_res->ptr; \
if (__check && my_res->status < __check) { \
php_error_docref(NULL, E_WARNING, "invalid object or resource %s\n", ZSTR_VAL(intern->zo.ce->name)); \
RETURN_FALSE;\
zend_throw_error(NULL, "%s object is not fully initialized", ZSTR_VAL(intern->zo.ce->name)); \
RETURN_THROWS();\
}\
}
@@ -260,12 +260,12 @@ extern void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * resul
{ \
MYSQLI_RESOURCE *my_res; \
if (!(my_res = (MYSQLI_RESOURCE *)(__obj->ptr))) {\
php_error_docref(NULL, E_WARNING, "Couldn't fetch %s", ZSTR_VAL(intern->zo.ce->name));\
return;\
}\
zend_throw_error(NULL, "%s object is already closed", ZSTR_VAL(intern->zo.ce->name));\
return;\
}\
__ptr = (__type)my_res->ptr; \
if (__check && my_res->status < __check) { \
php_error_docref(NULL, E_WARNING, "invalid object or resource %s\n", ZSTR_VAL(intern->zo.ce->name)); \
zend_throw_error(NULL, "%s object is not fully initialized", ZSTR_VAL(intern->zo.ce->name)); \
return;\
}\
}

View File

@@ -22,7 +22,11 @@ require_once('skipifconnectfailure.inc');
$mysql = new my_mysql();
var_dump($mysql->p_test);
var_dump($mysql->errno);
try {
$mysql->errno;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
$mysql->connect($host, $user, $passwd, $db, $port, $socket);
$mysql->select_db("nonexistingdb");
@@ -38,7 +42,5 @@ array(2) {
[1]=>
%s(3) "bar"
}
Warning: main(): Couldn't fetch my_mysql in %s on line %d
bool(false)
my_mysql object is already closed
bool(true)

View File

@@ -14,15 +14,22 @@ $mysqli = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$result = $mysqli->query('select 1');
$result->close();
echo $result->num_rows;
try {
$result->num_rows;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
$mysqli->close();
echo $result->num_rows;
try {
$result->num_rows;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
echo "Done\n";
?>
--EXPECTF--
Warning: main(): Couldn't fetch mysqli_result in %s on line %d
Warning: main(): Couldn't fetch mysqli_result in %s on line %d
mysqli_result object is already closed
mysqli_result object is already closed
Done

View File

@@ -15,27 +15,35 @@ Bug #36802 (crashes with with mysqli_set_charset())
/* following operations should not work */
if (method_exists($mysql, 'set_charset')) {
$x[0] = @$mysql->set_charset('utf8');
try {
$mysql->set_charset('utf8');
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
} else {
$x[0] = false;
}
$x[1] = @$mysql->query("SELECT 'foo' FROM DUAL");
try {
$mysql->query("SELECT 'foo' FROM DUAL");
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
/* following operations should work */
$x[2] = ($mysql->client_version > 0);
$x[3] = $mysql->errno;
$x[1] = ($mysql->client_version > 0);
$x[2] = $mysql->errno;
$mysql->close();
var_dump($x);
?>
--EXPECT--
array(4) {
[0]=>
bool(false)
mysqli object is not fully initialized
mysqli object is not fully initialized
array(2) {
[1]=>
bool(false)
[2]=>
bool(true)
[3]=>
[2]=>
int(0)
}

View File

@@ -19,18 +19,14 @@ mysqli_close($link);
$read = $error = $reject = array();
$read[] = $error[] = $reject[] = $link;
mysqli_poll($read, $error, $reject, 1);
try {
mysqli_poll($read, $error, $reject, 1);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
echo "okey";
?>
--EXPECTF--
Warning: mysqli_poll(): [1] Couldn't fetch mysqli in %sbug63398.php on line %d
Warning: mysqli_poll(): [1] Couldn't fetch mysqli in %sbug63398.php on line %d
Warning: mysqli_poll(): No stream arrays were passed in %sbug63398.php on line %d
Warning: mysqli_poll(): [1] Couldn't fetch mysqli in %sbug63398.php on line %d
Warning: mysqli_poll(): [1] Couldn't fetch mysqli in %sbug63398.php on line %d
mysqli object is already closed
okey

View File

@@ -19,7 +19,11 @@ require_once('skipifconnectfailure.inc');
/* Failed connection to invalid host */
$mysql_2 = @new mysqli(' !!! invalid !!! ', $user, $passwd, $db);
@$mysql_2->close();
try {
$mysql_2->close();
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
/* Re-use persistent connection */
$mysql_3 = new mysqli('p:'.$host, $user, $passwd, $db);
@@ -38,4 +42,5 @@ require_once('skipifconnectfailure.inc');
print "done!";
?>
--EXPECT--
mysqli object is already closed
done!

View File

@@ -11,9 +11,11 @@ require_once('skipifconnectfailure.inc');
require_once 'connect.inc';
$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
mysqli_close($link);
$stmt = mysqli_prepare($link, 'SELECT VERSION()');
var_dump($stmt);
?>
--EXPECTF--
Warning: mysqli_prepare(): Couldn't fetch mysqli in %s on line %d
bool(false)
try {
mysqli_prepare($link, 'SELECT VERSION()');
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
--EXPECT--
mysqli object is already closed

View File

@@ -110,8 +110,11 @@ mysqli_affected_rows()
mysqli_close($link);
if (false !== ($tmp = @mysqli_affected_rows($link)))
printf("[033] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_affected_rows($link);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -120,4 +123,5 @@ mysqli_affected_rows()
require_once("clean_table.inc");
?>
--EXPECT--
mysqli object is already closed
done!

View File

@@ -11,8 +11,11 @@ mysqli->affected_rows
require_once("connect.inc");
$mysqli = new mysqli();
if (false !== ($tmp = @$mysqli->affected_rows))
printf("[000a] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
$mysqli->affected_rows;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) {
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
@@ -101,8 +104,11 @@ mysqli->affected_rows
$mysqli->close();
if (false !== ($tmp = @$mysqli->affected_rows))
printf("[026] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
$mysqli->affected_rows;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -111,4 +117,6 @@ mysqli->affected_rows
require_once("clean_table.inc");
?>
--EXPECT--
Property access is not allowed yet
Property access is not allowed yet
done!

View File

@@ -122,14 +122,17 @@ mysqli_autocommit()
mysqli_close($link);
if (false !== ($tmp = @mysqli_autocommit($link, false)))
printf("[033] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_autocommit($link, false);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--CLEAN--
<?php
require_once("clean_table.inc");
?>
--EXPECT--
mysqli object is already closed
done!

View File

@@ -124,8 +124,11 @@ mysqli->autocommit()
$mysqli->close();
if (false !== ($tmp = @$mysqli->autocommit( false)))
printf("[030] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
$mysqli->autocommit(false);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -134,4 +137,5 @@ mysqli->autocommit()
require_once("clean_table.inc");
?>
--EXPECT--
my_mysqli object is already closed
done!

View File

@@ -87,8 +87,11 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
if (false !== ($tmp = @mysqli_change_user($link, $user, $passwd, $db)))
printf("[018] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_change_user($link, $user, $passwd, $db);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[019] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
@@ -127,4 +130,5 @@ require_once('skipifconnectfailure.inc');
print "done!";
?>
--EXPECT--
mysqli object is already closed
done!

View File

@@ -50,10 +50,13 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
if (false !== ($tmp = @mysqli_character_set_name($link)))
printf("[013] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_character_set_name($link);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECT--
mysqli object is already closed
done!

View File

@@ -54,14 +54,20 @@ mysqli_chararcter_set_name(), mysql_client_encoding() [alias]
$mysqli->close();
if (false !== ($tmp = @$mysqli->character_set_name()))
printf("[013] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
$mysqli->character_set_name();
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
/* Make sure that the function alias exists */
if (false !== ($tmp = @$mysqli->character_set_name()))
printf("[014] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
$mysqli->character_set_name();
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECT--
my_mysqli object is already closed
my_mysqli object is already closed
done!

View File

@@ -16,94 +16,188 @@ require_once('skipifconnectfailure.inc');
$variables = array_keys(get_class_vars(get_class($mysqli)));
sort($variables);
foreach ($variables as $k => $var) {
printf("%s = '%s'\n", $var, var_export(@$mysqli->$var, true));
try {
printf("%s = '%s'\n", $var, var_export($mysqli->$var, true));
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
}
printf("\nObject variables:\n");
$variables = array_keys(get_object_vars($mysqli));
foreach ($variables as $k => $var) {
printf("%s = '%s'\n", $var, var_export(@$mysqli->$var, true));
foreach ($variables as $k => $var) {
try {
printf("%s = '%s'\n", $var, var_export($mysqli->$var, true));
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
}
printf("\nMagic, magic properties:\n");
try {
mysqli_affected_rows($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
assert(@mysqli_affected_rows($mysqli) === @$mysqli->affected_rows);
printf("mysqli->affected_rows = '%s'/%s ('%s'/%s)\n",
@$mysqli->affected_rows, gettype(@$mysqli->affected_rows),
@mysqli_affected_rows($mysqli), gettype(@mysqli_affected_rows($mysqli)));
try {
$mysqli->affected_rows;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
assert(@mysqli_get_client_info() === @$mysqli->client_info);
printf("mysqli->client_info = '%s'/%s ('%s'/%s)\n",
@$mysqli->client_info, gettype(@$mysqli->client_info),
@mysqli_get_client_info(), gettype(@mysqli_get_client_info()));
try {
$mysqli->client_info;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
assert(@mysqli_get_client_version() === @$mysqli->client_version);
printf("mysqli->client_version = '%s'/%s ('%s'/%s)\n",
@$mysqli->client_version, gettype(@$mysqli->client_version),
@mysqli_get_client_version(), gettype(@mysqli_get_client_version()));
printf("mysqli->client_version = '%s'/%s\n", $mysqli->client_version, gettype($mysqli->client_version));
assert(@mysqli_errno($mysqli) === @$mysqli->errno);
printf("mysqli->errno = '%s'/%s ('%s'/%s)\n",
@$mysqli->errno, gettype(@$mysqli->errno),
try {
mysqli_errno($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
@mysqli_errno($mysqli), gettype(@mysqli_errno($mysqli)));
try {
$mysqli->errno;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
assert(@mysqli_error($mysqli) === @$mysqli->error);
printf("mysqli->error = '%s'/%s ('%s'/%s)\n",
@$mysqli->error, gettype(@$mysqli->error),
@mysqli_error($mysqli), gettype(@mysqli_error($mysqli)));
try {
mysqli_error($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
assert(@mysqli_field_count($mysqli) === @$mysqli->field_count);
printf("mysqli->field_count = '%s'/%s ('%s'/%s)\n",
@$mysqli->field_count, gettype(@$mysqli->field_count),
@mysqli_field_count($mysqli), gettype(@mysqli_field_count($mysqli)));
try {
$mysqli->error;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
assert(@mysqli_insert_id($mysqli) === @$mysqli->insert_id);
printf("mysqli->insert_id = '%s'/%s ('%s'/%s)\n",
@$mysqli->insert_id, gettype(@$mysqli->insert_id),
@mysqli_insert_id($mysqli), gettype(@mysqli_insert_id($mysqli)));
try {
mysqli_field_count($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
assert(@mysqli_sqlstate($mysqli) === @$mysqli->sqlstate);
printf("mysqli->sqlstate = '%s'/%s ('%s'/%s)\n",
@$mysqli->sqlstate, gettype(@$mysqli->sqlstate),
@mysqli_sqlstate($mysqli), gettype(@mysqli_sqlstate($mysqli)));
try {
$mysqli->field_count;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
assert(@mysqli_get_host_info($mysqli) === @$mysqli->host_info);
printf("mysqli->host_info = '%s'/%s ('%s'/%s)\n",
@$mysqli->host_info, gettype(@$mysqli->host_info),
@mysqli_get_host_info($mysqli), gettype(@mysqli_get_host_info($mysqli)));
try {
mysqli_insert_id($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
/* note that the data types are different */
assert(@mysqli_info($mysqli) == @$mysqli->info);
printf("mysqli->info = '%s'/%s ('%s'/%s)\n",
@$mysqli->info, gettype(@$mysqli->info),
@mysqli_info($mysqli), gettype(@mysqli_info($mysqli)));
try {
$mysqli->insert_id;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
assert(@mysqli_thread_id($mysqli) > @$mysqli->thread_id);
assert(gettype(@$mysqli->thread_id) == gettype(@mysqli_thread_id($mysqli)));
printf("mysqli->thread_id = '%s'/%s ('%s'/%s)\n",
@$mysqli->thread_id, gettype(@$mysqli->thread_id),
@mysqli_thread_id($mysqli), gettype(@mysqli_thread_id($mysqli)));
try {
mysqli_sqlstate($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
assert(@mysqli_get_proto_info($mysqli) === @$mysqli->protocol_version);
printf("mysqli->protocol_version = '%s'/%s ('%s'/%s)\n",
@$mysqli->protocol_version, gettype(@$mysqli->protocol_version),
@mysqli_get_proto_info($mysqli), gettype(@mysqli_get_proto_info($mysqli)));
try {
$mysqli->sqlstate;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
assert(@mysqli_get_server_info($mysqli) === @$mysqli->server_info);
printf("mysqli->server_info = '%s'/%s ('%s'/%s)\n",
@$mysqli->server_info, gettype(@$mysqli->server_info),
@mysqli_get_server_info($mysqli), gettype(@mysqli_get_server_info($mysqli)));
try {
mysqli_get_host_info($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
assert(@mysqli_get_server_version($mysqli) === @$mysqli->server_version);
printf("mysqli->server_version = '%s'/%s ('%s'/%s)\n",
@$mysqli->server_version, gettype(@$mysqli->server_version),
@mysqli_get_server_version($mysqli), gettype(@mysqli_get_server_version($mysqli)));
try {
$mysqli->host_info;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
try {
mysqli_info($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
try {
$mysqli->info;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
try {
mysqli_thread_id($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
try {
$mysqli->thread_id;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
try {
mysqli_get_proto_info($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
try {
$mysqli->protocol_version;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
try {
mysqli_get_server_info($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
try {
$mysqli->server_info;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
try {
mysqli_get_server_version($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
try {
$mysqli->server_version;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
try {
mysqli_warning_count($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
try {
$mysqli->warning_count;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
assert(@mysqli_warning_count($mysqli) === @$mysqli->warning_count);
printf("mysqli->warning_count = '%s'/%s ('%s'/%s)\n",
@$mysqli->warning_count, gettype(@$mysqli->warning_count),
@mysqli_warning_count($mysqli), gettype(@mysqli_warning_count($mysqli)));
printf("\nAccess to undefined properties:\n");
printf("mysqli->unknown = '%s'\n", @$mysqli->unknown);
@@ -131,9 +225,13 @@ require_once('skipifconnectfailure.inc');
$mysqli = @new mysqli($host, $user, $passwd . "invalid", $db, $port, $socket);
dump_properties($mysqli);
printf("With RS\n");
printf("\nWith RS\n");
$mysqli = @new mysqli($host, $user, $passwd . "invalid", $db, $port, $socket);
$res = @$mysqli->query("SELECT * FROM test");
try {
$mysqli->query("SELECT * FROM test");
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
dump_properties($mysqli);
print "done!";
@@ -144,65 +242,74 @@ require_once('skipifconnectfailure.inc');
Without RS
Class variables:
affected_rows = 'false'
client_info = 'false'
Property access is not allowed yet
Property access is not allowed yet
client_version = '%s'
connect_errno = '%s'
connect_error = ''%s'
errno = 'false'
error = 'false'
error_list = 'false'
field_count = 'false'
host_info = 'false'
info = 'false'
insert_id = 'false'
protocol_version = 'false'
server_info = 'false'
server_version = 'false'
sqlstate = 'false'
thread_id = 'false'
warning_count = 'false'
mysqli object is already closed
mysqli object is already closed
Property access is not allowed yet
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
Object variables:
affected_rows = 'false'
client_info = 'false'
Property access is not allowed yet
Property access is not allowed yet
client_version = '%s'
connect_errno = '%s'
connect_error = '%s'
errno = 'false'
error = 'false'
error_list = 'false'
field_count = 'false'
host_info = 'false'
info = 'false'
insert_id = 'false'
server_info = 'false'
server_version = 'false'
sqlstate = 'false'
protocol_version = 'false'
thread_id = 'false'
warning_count = 'false'
connect_error = ''%s'
mysqli object is already closed
mysqli object is already closed
Property access is not allowed yet
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
Magic, magic properties:
mysqli->affected_rows = ''/boolean (''/boolean)
Warning: assert(): assert(@mysqli_get_client_info() === @$mysqli->client_info) failed in %s on line %d
mysqli->client_info = ''/boolean ('%s'/%s)
mysqli->client_version = '%s'/integer ('%s'/integer)
mysqli->errno = ''/boolean (''/boolean)
mysqli->error = ''/boolean (''/boolean)
mysqli->field_count = ''/boolean (''/boolean)
mysqli->insert_id = ''/boolean (''/boolean)
mysqli->sqlstate = ''/boolean (''/boolean)
mysqli->host_info = ''/boolean (''/boolean)
mysqli->info = ''/boolean (''/boolean)
Warning: assert(): assert(@mysqli_thread_id($mysqli) > @$mysqli->thread_id) failed in %s on line %d
mysqli->thread_id = ''/boolean (''/boolean)
mysqli->protocol_version = ''/boolean (''/boolean)
mysqli->server_info = ''/boolean (''/boolean)
mysqli->server_version = ''/boolean (''/boolean)
mysqli->warning_count = ''/boolean (''/boolean)
mysqli object is already closed
Property access is not allowed yet
Property access is not allowed yet
mysqli->client_version = '80000'/integer
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
Access to undefined properties:
mysqli->unknown = ''
@@ -212,68 +319,79 @@ setting mysqli->unknown, @mysqli_unknown = 'friday'
Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):
mysqli->connect_error = '%s'/%s)
mysqli->connect_errno = '%s'/integer ('%s'/integer)
With RS
mysqli object is already closed
Class variables:
affected_rows = 'false'
client_info = 'false'
Property access is not allowed yet
Property access is not allowed yet
client_version = '%s'
connect_errno = '%s'
connect_error = '%s'
errno = 'false'
error = 'false'
error_list = 'false'
field_count = 'false'
host_info = 'false'
info = 'false'
insert_id = 'false'
protocol_version = 'false'
server_info = 'false'
server_version = 'false'
sqlstate = 'false'
thread_id = 'false'
warning_count = 'false'
mysqli object is already closed
mysqli object is already closed
Property access is not allowed yet
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
Object variables:
affected_rows = 'false'
client_info = 'false'
Property access is not allowed yet
Property access is not allowed yet
client_version = '%s'
connect_errno = '%s'
connect_error = '%s'
errno = 'false'
error = 'false'
error_list = 'false'
field_count = 'false'
host_info = 'false'
info = 'false'
insert_id = 'false'
server_info = 'false'
server_version = 'false'
sqlstate = 'false'
protocol_version = 'false'
thread_id = 'false'
warning_count = 'false'
mysqli object is already closed
mysqli object is already closed
Property access is not allowed yet
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
Magic, magic properties:
mysqli->affected_rows = ''/boolean (''/boolean)
Warning: assert(): assert(@mysqli_get_client_info() === @$mysqli->client_info) failed in %s on line %d
mysqli->client_info = ''/boolean ('%s'/%s)
mysqli->client_version = '%s'/integer ('%s'/integer)
mysqli->errno = ''/boolean (''/boolean)
mysqli->error = ''/boolean (''/boolean)
mysqli->field_count = ''/boolean (''/boolean)
mysqli->insert_id = ''/boolean (''/boolean)
mysqli->sqlstate = ''/boolean (''/boolean)
mysqli->host_info = ''/boolean (''/boolean)
mysqli->info = ''/boolean (''/boolean)
Warning: assert(): assert(@mysqli_thread_id($mysqli) > @$mysqli->thread_id) failed in %s on line %d
mysqli->thread_id = ''/boolean (''/boolean)
mysqli->protocol_version = ''/boolean (''/boolean)
mysqli->server_info = ''/boolean (''/boolean)
mysqli->server_version = ''/boolean (''/boolean)
mysqli->warning_count = ''/boolean (''/boolean)
mysqli object is already closed
Property access is not allowed yet
Property access is not allowed yet
mysqli->client_version = '80000'/integer
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
mysqli object is already closed
Access to undefined properties:
mysqli->unknown = ''

View File

@@ -113,8 +113,11 @@ require_once('skipifconnectfailure.inc');
if (!is_object($res = new mysqli_result($link)))
printf("[001] Expecting object/mysqli_result got %s/%s\n", gettye($res), $res);
if (null !== ($tmp = @$res->num_rows))
printf("[002] Expecting NULL got %s/%s\n", gettype($tmp), $tmp);
try {
$res->num_rows;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!mysqli_query($link, "SELECT id FROM test ORDER BY id"))
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -177,4 +180,5 @@ Access to undefined properties:
mysqli_result->unknown = ''
Constructor:
mysqli_result object is already closed
done!

View File

@@ -81,12 +81,21 @@ Interface of the class mysqli_stmt
printf("\nMagic, magic properties:\n");
assert(mysqli_stmt_affected_rows($stmt) === $stmt->affected_rows);
printf("stmt->affected_rows = '%s'\n", $stmt->affected_rows);
try {
mysqli_stmt_affected_rows($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!$stmt->prepare("INSERT INTO test(id, label) VALUES (100, 'z')") ||
!$stmt->execute())
printf("[001] [%d] %s\n", $stmt->errno, $stmt->error);
try {
$stmt->affected_rows;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!$stmt->prepare("INSERT INTO test(id, label) VALUES (100, 'z')") || !$stmt->execute()) {
printf("[001] [%d] %s\n", $stmt->errno, $stmt->error);
}
assert(mysqli_stmt_affected_rows($stmt) === $stmt->affected_rows);
printf("stmt->affected_rows = '%s'\n", $stmt->affected_rows);
@@ -157,14 +166,8 @@ sqlstate
id
Magic, magic properties:
Warning: mysqli_stmt_affected_rows(): invalid object or resource mysqli_stmt
in %s on line %d
Warning: main(): Property access is not allowed yet in %s on line %d
Warning: main(): Property access is not allowed yet in %s on line %d
stmt->affected_rows = ''
mysqli_stmt object is not fully initialized
Property access is not allowed yet
stmt->affected_rows = '1'
stmt->errno = '0'
stmt->error = ''

View File

@@ -100,13 +100,9 @@ Warning: mysqli_warning::mysqli_warning() expects parameter 1 to be object, null
Warning: Wrong parameter count for mysqli_warning::mysqli_warning() in %s on line %d
Warning: mysqli_warning::mysqli_warning(): Couldn't fetch mysqli in %s on line %d
Warning: mysqli_warning::mysqli_warning(): invalid object or resource mysqli_stmt
in %s on line %d
Warning: mysqli_warning::mysqli_warning(): invalid object or resource mysqli_stmt
in %s on line %d
Warning: mysqli_warning::mysqli_warning(): mysqli object is already closed in %s on line %d
mysqli_stmt object is not fully initialized
mysqli_stmt object is not fully initialized
Warning: mysqli_warning::mysqli_warning(): Invalid class argument in /home/nixnutz/php6_mysqlnd/ext/mysqli/tests/mysqli_class_mysqli_warning.php on line 19

View File

@@ -18,10 +18,13 @@ require_once('skipifconnectfailure.inc');
if (true !== $tmp)
printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
if (false !== ($tmp = @mysqli_query($link, "SELECT 1")))
printf("[006] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_query($link, "SELECT 1");
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECT--
mysqli object is already closed
done!

View File

@@ -21,13 +21,21 @@ require_once('skipifconnectfailure.inc');
if (true !== $tmp)
printf("[003] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
if (false !== ($tmp = @$mysqli->close()))
printf("[004] Expecting false got %s/%s\n", gettype($tmp), $tmp);
try {
$mysqli->close();
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (false !== ($tmp = @$mysqli->query("SELECT 1")))
printf("[005] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
$mysqli->query("SELECT 1");
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECT--
my_mysqli object is already closed
my_mysqli object is already closed
done!

View File

@@ -52,8 +52,11 @@ if (!have_innodb($link))
mysqli_close($link);
if (false !== ($tmp = @mysqli_commit($link)))
printf("[014] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_commit($link);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -62,4 +65,5 @@ if (!have_innodb($link))
require_once("clean_table.inc");
?>
--EXPECT--
mysqli object is already closed
done!

View File

@@ -21,9 +21,11 @@ if (!have_innodb($link))
$link = NULL;
$mysqli = new mysqli();
if (false !== ($tmp = @$mysqli->commit())) {
printf("[013] Expecting false got %s/%s\n", gettype($tmp), $tmp);
}
try {
$mysqli->commit();
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket)) {
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
@@ -90,20 +92,24 @@ if (!have_innodb($link))
$mysqli->close();
if (false !== ($tmp = @$mysqli->commit())) {
printf("[017] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
}
try {
$mysqli->commit();
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--CLEAN--
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
mysqli object is not fully initialized
Warning: mysqli::commit(): Transaction name truncated. Must be only [0-9A-Za-z\-_=]+ in %s on line %d
Warning: mysqli::commit(): Transaction name truncated. Must be only [0-9A-Za-z\-_=]+ in %s on line %d
Warning: mysqli::commit(): Transaction name truncated. Must be only [0-9A-Za-z\-_=]+ in %s on line %d
my_mysqli object is already closed
done!

View File

@@ -56,13 +56,14 @@ require_once('skipifconnectfailure.inc');
printf("[012] Failed to create mysqli object\n");
} else {
// There shall be NO connection! Using new mysqli(void) shall not use defaults for a connection!
// We had long discussions on this and found that the ext/mysqli API as
// such is broken. As we can't fix it, we document how it has behaved from
// the first day on. And that's: no connection.
if (false !== ($tmp = @$mysqli->query('SELECT 1'))) {
printf("[013] There shall be no connection!\n");
$mysqli->close();
}
// We had long discussions on this and found that the ext/mysqli API as
// such is broken. As we can't fix it, we document how it has behaved from
// the first day on. And that's: no connection.
try {
$mysqli->query('SELECT 1');
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
}
if ($IS_MYSQLND) {
@@ -75,9 +76,10 @@ require_once('skipifconnectfailure.inc');
// We had long discussions on this and found that the ext/mysqli API as
// such is broken. As we can't fix it, we document how it has behaved from
// the first day on. And that's: no connection.
if (false !== ($tmp = @$mysqli->query('SELECT 1'))) {
printf("[011] There shall be no connection!\n");
$mysqli->close();
try {
$mysqli->query('SELECT 1');
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
}
}
@@ -148,6 +150,8 @@ require_once('skipifconnectfailure.inc');
?>
--EXPECTF--
Warning: mysqli::__construct(): (%s/%d): Access denied for user '%sunknown%s'@'%s' (using password: %s) in %s on line %d
mysqli object is not fully initialized
mysqli object is not fully initialized
... and now Exceptions
Access denied for user '%s'@'%s' (using password: %s)
done!

View File

@@ -44,8 +44,11 @@ require_once('skipifconnectfailure.inc');
mysqli_free_result($res);
if (false !== ($tmp = mysqli_data_seek($res, 1)))
printf("[013] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_data_seek($res, 1);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
@@ -57,6 +60,5 @@ require_once('skipifconnectfailure.inc');
?>
--EXPECTF--
Warning: mysqli_data_seek(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d
Warning: mysqli_data_seek(): Couldn't fetch mysqli_result in %s on line %d
mysqli_result object is already closed
done!

View File

@@ -16,8 +16,12 @@ require_once('skipifconnectfailure.inc');
$host, $user, $db, $port, $socket);
$res = new mysqli_result($mysqli);
if (false !== ($tmp = @$res->data_seek(0)))
printf("[002] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
$res->data_seek(0);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!$res = $mysqli->query('SELECT * FROM test ORDER BY id LIMIT 4', MYSQLI_STORE_RESULT))
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -52,19 +56,22 @@ require_once('skipifconnectfailure.inc');
$res->free_result();
if (false !== ($tmp = $res->data_seek(1)))
printf("[015] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
$res->data_seek(1);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
$mysqli->close();
print "done!";
?>
--CLEAN--
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_result::data_seek(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d
mysqli_result object is already closed
Warning: mysqli_result::data_seek(): Couldn't fetch mysqli_result in %s on line %d
Warning: mysqli_result::data_seek(): Function cannot be used with MYSQL_USE_RESULT in %s on line %d
mysqli_result object is already closed
done!

View File

@@ -43,5 +43,5 @@ if (!function_exists('mysqli_disable_reads_from_master')) {
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_disable_reads_from_master(): Couldn't fetch mysqli in %s on line %d
Warning: mysqli_disable_reads_from_master(): mysqli object is already closed in %s on line %d
done!

View File

@@ -23,13 +23,13 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
if (false !== ($tmp = mysqli_dump_debug_info($link)))
printf("[005] Expecting NULL, got %s/%s, [%d] %s\n",
gettype($tmp), $tmp,
mysqli_errno($link), mysqli_error($link));
try {
mysqli_dump_debug_info($link);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECTF--
Warning: mysqli_dump_debug_info(): Couldn't fetch mysqli in %s on line %d
--EXPECT--
mysqli object is already closed
done!

View File

@@ -23,13 +23,14 @@ require_once('skipifconnectfailure.inc');
$mysqli->close();
if (false !== ($tmp = $mysqli->dump_debug_info()))
printf("[004] Expecting false, got %s/%s, [%d] %s\n",
gettype($tmp), $tmp,
$mysqli->errno, $mysqli->error);
try {
$mysqli->dump_debug_info();
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECTF--
Warning: mysqli::dump_debug_info(): Couldn't fetch mysqli in %s on line %d
--EXPECT--
mysqli object is already closed
done!

View File

@@ -31,7 +31,11 @@ if (!function_exists('mysqli_enable_reads_from_master')) {
if (!is_bool($tmp = mysqli_enable_reads_from_master($link)))
printf("[004] Expecting boolean/[true|false] value, got %s/%s\n", gettype($tmp), $tmp);
mysqli_close($link);
try {
mysqli_close($link);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (NULL !== ($tmp = mysqli_enable_reads_from_master($link)))
printf("[005] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
@@ -39,5 +43,5 @@ if (!function_exists('mysqli_enable_reads_from_master')) {
print "done!";
?>
--EXPECTF--
Warning: mysqli_enable_reads_from_master(): Couldn't fetch mysqli in %s on line %d
mysqli object is already closed
done!

View File

@@ -30,14 +30,16 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
var_dump(mysqli_errno($link));
try {
mysqli_errno($link);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECTF--
int(0)
int(%d)
Warning: mysqli_errno(): Couldn't fetch mysqli in %s on line %d
bool(false)
mysqli object is already closed
done!

View File

@@ -36,14 +36,16 @@ require_once('skipifconnectfailure.inc');
$mysqli->close();
var_dump($mysqli->errno);
try {
$mysqli->errno;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECTF--
int(0)
int(%d)
Warning: main(): Couldn't fetch mysqli in %s on line %d
bool(false)
mysqli object is already closed
done!

View File

@@ -30,11 +30,14 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
var_dump(mysqli_error($link));
try {
mysqli_error($link);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECTF--
Warning: mysqli_error(): Couldn't fetch mysqli in %s on line %d
bool(false)
--EXPECT--
mysqli object is already closed
done!

View File

@@ -36,11 +36,14 @@ require_once('skipifconnectfailure.inc');
$mysqli->close();
var_dump($mysqli->error);
try {
$mysqli->error;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECTF--
Warning: main(): Couldn't fetch mysqli in %s on line %d
bool(false)
--EXPECT--
mysqli object is already closed
done!

View File

@@ -28,13 +28,14 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
var_dump(mysqli_error($link));
try {
mysqli_error($link);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECTF--
string(%d) "Table 'нямаакавааблица' doesn't exist"
Warning: mysqli_error(): Couldn't fetch mysqli in %s on line %d
bool(false)
mysqli object is already closed
done!

View File

@@ -75,11 +75,8 @@ if (!function_exists('mysqli_fetch_all'))
$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 = mysqli_fetch_all($res, $illegal_mode);
if (false !== $tmp)
printf("[019] Expecting boolean/false although, got %s/%s. [%d] %s\n",
gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
mysqli_fetch_all($res, $illegal_mode);
mysqli_free_result($res);
function func_mysqli_fetch_all($link, $engine, $sql_type, $sql_value, $php_value, $offset, $regexp_comparison = NULL) {
@@ -287,8 +284,11 @@ if (!function_exists('mysqli_fetch_all'))
mysqli_close($link);
if (false !== ($tmp = mysqli_fetch_array($res, MYSQLI_ASSOC)))
printf("[015] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_fetch_array($res, MYSQLI_ASSOC);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
printf("[016] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
@@ -309,7 +309,6 @@ if (!function_exists('mysqli_fetch_all'))
var_dump($rows);
}
print "done!";
?>
--CLEAN--
@@ -446,6 +445,5 @@ array(1) {
}
Warning: mysqli_fetch_all(): Mode can be only MYSQLI_FETCH_NUM, MYSQLI_FETCH_ASSOC or MYSQLI_FETCH_BOTH in %s on line %d
Warning: mysqli_fetch_array(): Couldn't fetch mysqli_result in %s on line %d
mysqli_result object is already closed
done!

View File

@@ -298,8 +298,11 @@ if (!function_exists('mysqli_fetch_all'))
mysqli_close($link);
if (false !== ($tmp = $res->fetch_array(MYSQLI_ASSOC)))
printf("[015] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
$res->fetch_array(MYSQLI_ASSOC);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -435,6 +438,5 @@ array(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
Warning: mysqli_result::fetch_array(): Couldn't fetch mysqli_result in %s on line %d
mysqli_result object is already closed
done!

View File

@@ -279,8 +279,11 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
if (false !== ($tmp = mysqli_fetch_array($res, MYSQLI_ASSOC)))
printf("[015] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_fetch_array($res, MYSQLI_ASSOC);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -361,6 +364,5 @@ array(11) {
Warning: mysqli_fetch_array(): The result type should be either MYSQLI_NUM, MYSQLI_ASSOC or MYSQLI_BOTH in %s on line %d
Warning: mysqli_fetch_array(): The result type should be either MYSQLI_NUM, MYSQLI_ASSOC or MYSQLI_BOTH in %s on line %d
Warning: mysqli_fetch_array(): Couldn't fetch mysqli_result in %s on line %d
mysqli_result object is already closed
done!

View File

@@ -271,8 +271,11 @@ require_once('skipifconnectfailure.inc');
$mysqli->close();
if (false !== ($tmp = $res->fetch_array(MYSQLI_ASSOC)))
printf("[015] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
$res->fetch_array(MYSQLI_ASSOC);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -357,6 +360,5 @@ array(11) {
Warning: mysqli_result::fetch_array(): The result type should be either MYSQLI_NUM, MYSQLI_ASSOC or MYSQLI_BOTH in %s on line %d
Warning: mysqli_result::fetch_array(): The result type should be either MYSQLI_NUM, MYSQLI_ASSOC or MYSQLI_BOTH in %s on line %d
Warning: mysqli_result::fetch_array(): Couldn't fetch mysqli_result in %s on line %d
mysqli_result object is already closed
done!

View File

@@ -51,8 +51,11 @@ require_once('skipifconnectfailure.inc');
mysqli_free_result($res);
if (false !== ($tmp = mysqli_fetch_assoc($res)))
printf("[008] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_fetch_assoc($res);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
@@ -62,7 +65,7 @@ require_once('skipifconnectfailure.inc');
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
--EXPECT--
[005]
array(2) {
["id"]=>
@@ -105,6 +108,5 @@ array(15) {
["-02"]=>
string(1) "f"
}
Warning: mysqli_fetch_assoc(): Couldn't fetch mysqli_result in %s on line %d
mysqli_result object is already closed
done!

View File

@@ -15,9 +15,11 @@ require_once('skipifconnectfailure.inc');
// Note: no SQL type tests, internally the same function gets used as for mysqli_fetch_array() which does a lot of SQL type test
$mysqli = new mysqli();
$res = @new mysqli_result($mysqli);
if (false !== ($tmp = @$res->fetch_assoc()))
printf("[001] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
new mysqli_result($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
require('table.inc');
if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
@@ -44,8 +46,11 @@ require_once('skipifconnectfailure.inc');
$res->free_result();
if (false !== ($tmp = $res->fetch_assoc()))
printf("[008] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
$res->fetch_assoc();
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
@@ -55,7 +60,8 @@ require_once('skipifconnectfailure.inc');
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
--EXPECT--
mysqli object is not fully initialized
[005]
array(2) {
["id"]=>
@@ -78,6 +84,5 @@ array(5) {
["e"]=>
string(1) "1"
}
Warning: mysqli_result::fetch_assoc(): Couldn't fetch mysqli_result in %s on line %d
mysqli_result object is already closed
done!

View File

@@ -50,8 +50,11 @@ require_once('skipifconnectfailure.inc');
mysqli_free_result($res);
// Read http://bugs.php.net/bug.php?id=42344 on defaults!
if (false !== ($tmp = mysqli_fetch_field($res)))
printf("[006] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_fetch_field($res);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -136,8 +139,7 @@ object(stdClass)#%d (13) {
int(0)
}
bool(false)
Warning: mysqli_fetch_field(): Couldn't fetch mysqli_result in %s on line %d
mysqli_result object is already closed
array(1) {
["_default_test"]=>
string(1) "2"

View File

@@ -22,8 +22,11 @@ require_once('skipifconnectfailure.inc');
mysqli_free_result($res);
if (false !== ($tmp = mysqli_fetch_field_direct($res, 0)))
printf("[005] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_fetch_field_direct($res, 0);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
print "done!";
@@ -66,6 +69,5 @@ object(stdClass)#%d (13) {
Warning: mysqli_fetch_field_direct(): Field offset is invalid for resultset in %s on line %d
bool(false)
Warning: mysqli_fetch_field_direct(): Couldn't fetch mysqli_result in %s on line %d
mysqli_result object is already closed
done!

View File

@@ -11,7 +11,11 @@ require_once('skipifconnectfailure.inc');
require_once("connect.inc");
$mysqli = new mysqli();
$res = @new mysqli_result($mysqli);
try {
new mysqli_result($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
require('table.inc');
@@ -29,8 +33,11 @@ require_once('skipifconnectfailure.inc');
$res->free_result();
if (false !== ($tmp = $res->fetch_field_direct(0)))
printf("[007] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
$res->fetch_field_direct(0);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
$mysqli->close();
print "done!";
@@ -40,6 +47,8 @@ require_once('skipifconnectfailure.inc');
require_once("clean_table.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)
object(stdClass)#%d (13) {
@@ -73,6 +82,5 @@ object(stdClass)#%d (13) {
Warning: mysqli_result::fetch_field_direct(): Field offset is invalid for resultset in %s on line %d
bool(false)
Warning: mysqli_result::fetch_field_direct(): Couldn't fetch mysqli_result in %s on line %d
mysqli_result object is already closed
done!

View File

@@ -12,7 +12,12 @@ require_once('skipifconnectfailure.inc');
// Note: no SQL type tests, internally the same function gets used as for mysqli_fetch_array() which does a lot of SQL type test
$mysqli = new mysqli();
$res = @new mysqli_result($mysqli);
$res = false;
try {
new mysqli_result($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
require('table.inc');
if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
@@ -51,8 +56,11 @@ require_once('skipifconnectfailure.inc');
$res->free_result();
if (false !== ($tmp = $res->fetch_field()))
printf("[007] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
$res->fetch_field();
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
$mysqli->close();
print "done!";
@@ -62,6 +70,7 @@ require_once('skipifconnectfailure.inc');
require_once("clean_table.inc");
?>
--EXPECTF--
mysqli object is not fully initialized
object(stdClass)#%d (13) {
["name"]=>
string(2) "ID"
@@ -119,6 +128,5 @@ object(stdClass)#%d (13) {
int(0)
}
bool(false)
Warning: mysqli_result::fetch_field(): Couldn't fetch mysqli_result in %s on line %d
mysqli_result object is already closed
done!

View File

@@ -47,8 +47,11 @@ require_once('skipifconnectfailure.inc');
mysqli_free_result($res);
if (false !== ($tmp = mysqli_fetch_fields($res)))
printf("[006] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_fetch_fields($res);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
print "done!";
@@ -114,6 +117,5 @@ object(stdClass)#%d (13) {
["decimals"]=>
int(0)
}
Warning: mysqli_fetch_fields(): Couldn't fetch mysqli_result in %s on line %d
mysqli_result object is already closed
done!

View File

@@ -27,7 +27,11 @@ require_once('skipifconnectfailure.inc');
mysqli_free_result($res);
var_dump(mysqli_fetch_lengths($res));
try {
mysqli_fetch_lengths($res);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
print "done!";
@@ -36,7 +40,7 @@ require_once('skipifconnectfailure.inc');
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
--EXPECT--
bool(false)
array(2) {
[0]=>
@@ -45,7 +49,5 @@ array(2) {
int(1)
}
bool(false)
Warning: mysqli_fetch_lengths(): Couldn't fetch mysqli_result in %s on line %d
bool(false)
mysqli_result object is already closed
done!

View File

@@ -24,7 +24,11 @@ require_once('skipifconnectfailure.inc');
var_dump($res->lengths);
$res->free_result();
var_dump($res->lengths);
try {
$res->lengths;
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
$mysqli->close();
print "done!";
?>
@@ -35,7 +39,7 @@ require_once('skipifconnectfailure.inc');
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
--EXPECT--
NULL
array(2) {
[0]=>
@@ -44,7 +48,5 @@ array(2) {
int(1)
}
NULL
Warning: main(): Property access is not allowed yet in %s on line %d
bool(false)
Property access is not allowed yet
done!

View File

@@ -86,7 +86,11 @@ require_once('skipifconnectfailure.inc');
}
mysqli_free_result($res);
var_dump(mysqli_fetch_object($res));
try {
mysqli_fetch_object($res);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!$res = mysqli_query($link, "SELECT id AS ID, label FROM test AS TEST ORDER BY id LIMIT 5"))
printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -140,8 +144,7 @@ Exception: Too few arguments to function mysqli_fetch_object_construct::__constr
Exception: Too few arguments to function mysqli_fetch_object_construct::__construct(), 1 passed and exactly 2 expected
NULL
NULL
[E_WARNING] mysqli_fetch_object(): Couldn't fetch mysqli_result in %s on line %d
bool(false)
mysqli_result object is already closed
[0] mysqli_fetch_object() expects parameter 3 to be array, string given in %s on line %d
Fatal error: Class 'this_class_does_not_exist' not found in %s on line %d

View File

@@ -12,9 +12,11 @@ require_once('skipifconnectfailure.inc');
set_error_handler('handle_catchable_fatal');
$mysqli = new mysqli();
$res = @new mysqli_result($mysqli);
if (false !== ($tmp = @$res->fetch_object()))
printf("[001] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
new mysqli_result($mysqli);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
require('table.inc');
if (!$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))
@@ -110,7 +112,11 @@ require_once('skipifconnectfailure.inc');
mysqli_free_result($res);
var_dump(mysqli_fetch_object($res));
try {
mysqli_fetch_object($res);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
// Fatal error, script execution will end
var_dump($res->fetch_object('this_class_does_not_exist'));
@@ -123,16 +129,13 @@ require_once('skipifconnectfailure.inc');
require_once("clean_table.inc");
?>
--EXPECTF--
[E_WARNING] mysqli_result::__construct(): invalid object or resource mysqli
in %s on line %d
[E_WARNING] mysqli_result::fetch_object(): Couldn't fetch mysqli_result in %s on line %d
mysqli object is not fully initialized
[0] mysqli_result::fetch_object() expects parameter 1 to be string, object given in %s on line %d
[0] mysqli_result::fetch_object() expects at most 2 parameters, 3 given in %s on line %d
[0] mysqli_result::fetch_object() expects parameter 2 to be array, null given in %s on line %d
Exception: Too few arguments to function mysqli_fetch_object_construct::__construct(), 1 passed and exactly 2 expected
NULL
NULL
[E_WARNING] mysqli_fetch_object(): Couldn't fetch mysqli_result in %s on line %d
bool(false)
mysqli_result object is already closed
Fatal error: Class 'this_class_does_not_exist' not found in %s on line %d

View File

@@ -23,7 +23,11 @@ require_once('skipifconnectfailure.inc');
mysqli_free_result($res);
var_dump(mysqli_fetch_row($res));
try {
mysqli_fetch_row($res);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
print "done!";
@@ -32,7 +36,7 @@ require_once('skipifconnectfailure.inc');
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
--EXPECT--
[004]
array(3) {
[0]=>
@@ -44,7 +48,5 @@ array(3) {
}
[005]
NULL
Warning: mysqli_fetch_row(): Couldn't fetch mysqli_result in %s on line %d
bool(false)
mysqli_result object is already closed
done!

View File

@@ -34,21 +34,22 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
var_dump(mysqli_field_count($link));
try {
mysqli_field_count($link);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--CLEAN--
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
--EXPECT--
int(0)
int(2)
int(0)
int(0)
int(3)
Warning: mysqli_field_count(): Couldn't fetch mysqli in %s on line %d
bool(false)
mysqli object is already closed
done!

View File

@@ -101,7 +101,11 @@ require_once('skipifconnectfailure.inc');
mysqli_free_result($res);
var_dump(mysqli_field_seek($res, 0));
try {
mysqli_field_seek($res, 0);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
print "done!";
@@ -233,7 +237,5 @@ object(stdClass)#%d (13) {
["decimals"]=>
int(0)
}
Warning: mysqli_field_seek(): Couldn't fetch mysqli_result in %s on line %d
bool(false)
mysqli_result object is already closed
done!

View File

@@ -34,7 +34,11 @@ require_once('skipifconnectfailure.inc');
mysqli_free_result($res);
var_dump(mysqli_field_tell($res));
try {
mysqli_field_tell($res);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
@@ -87,7 +91,5 @@ bool(false)
int(1)
bool(true)
int(0)
Warning: mysqli_field_tell(): Couldn't fetch mysqli_result in %s on line %d
bool(false)
mysqli_result object is already closed
done!

View File

@@ -16,18 +16,25 @@ require_once('skipifconnectfailure.inc');
}
print "a\n";
var_dump(mysqli_free_result($res));
print "b\n";
var_dump(mysqli_free_result($res));
var_dump(mysqli_free_result($res));
print "b\n";
try {
mysqli_free_result($res);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!$res = mysqli_query($link, "SELECT id FROM test ORDER BY id LIMIT 1")) {
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (!$res = mysqli_query($link, "SELECT id FROM test ORDER BY id LIMIT 1")) {
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
print "c\n";
var_dump(mysqli_store_result($link));
var_dump(mysqli_error($link));
print "[005]\n";
var_dump(mysqli_free_result($res));
mysqli_free_result($res);
if (!$res = mysqli_query($link, "SELECT id FROM test ORDER BY id LIMIT 1")) {
printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -49,14 +56,11 @@ require_once('skipifconnectfailure.inc');
a
NULL
b
Warning: mysqli_free_result(): Couldn't fetch mysqli_result in %s on line %d
bool(false)
mysqli_result object is already closed
c
bool(false)
string(0) ""
[005]
NULL
d
bool(false)
string(0) ""

View File

@@ -89,8 +89,11 @@ if (!function_exists('mysqli_get_charset'))
mysqli_close($link);
if (false !== ($tmp = mysqli_get_charset($link)))
printf("[023] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_get_charset($link);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -98,6 +101,6 @@ if (!function_exists('mysqli_get_charset'))
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_get_charset(): Couldn't fetch mysqli in %s on line %d
--EXPECT--
mysqli object is already closed
done!

View File

@@ -117,7 +117,11 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
var_dump(mysqli_insert_id($link));
try {
mysqli_insert_id($link);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -125,7 +129,6 @@ require_once('skipifconnectfailure.inc');
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_insert_id(): Couldn't fetch mysqli in %s on line %d
bool(false)
--EXPECT--
mysqli object is already closed
done!

View File

@@ -50,7 +50,11 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
var_dump(mysqli_more_results($link));
try {
mysqli_more_results($link);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -67,7 +71,5 @@ bool(false)
[010]
1
2
Warning: mysqli_more_results(): Couldn't fetch mysqli in %s on line %d
bool(false)
mysqli object is already closed
done!

View File

@@ -102,7 +102,11 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
var_dump(mysqli_multi_query($link, "SELECT id, label FROM test"));
try {
mysqli_multi_query($link, "SELECT id, label FROM test");
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -115,7 +119,5 @@ require_once('skipifconnectfailure.inc');
[008] 0
[009] [2014] Commands out of sync; you can't run this command now
[010] 7
Warning: mysqli_multi_query(): Couldn't fetch mysqli in %s on line %d
bool(false)
mysqli object is already closed
done!

View File

@@ -55,7 +55,11 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
var_dump(mysqli_next_result($link));
try {
mysqli_next_result($link);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -64,7 +68,5 @@ require_once('skipifconnectfailure.inc');
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_next_result(): Couldn't fetch mysqli in %s on line %d
bool(false)
mysqli object is already closed
done!

View File

@@ -26,8 +26,11 @@ require_once('skipifconnectfailure.inc');
mysqli_free_result($res);
if ($test_free && (false !== ($tmp = mysqli_num_fields($res))))
printf("[%03d] Expecting false, got %s/%s\n", $offset + 2, gettype($tmp), $tmp);
try {
mysqli_num_fields($res);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
}
func_test_mysqli_num_fields($link, "SELECT 1 AS a", 1, 5);
@@ -43,6 +46,9 @@ require_once('skipifconnectfailure.inc');
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_num_fields(): Couldn't fetch mysqli_result in %s on line %d
--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
done!

View File

@@ -27,8 +27,11 @@ require_once('skipifconnectfailure.inc');
mysqli_free_result($res);
if ($test_free && (false !== ($tmp = mysqli_num_rows($res))))
printf("[%03d] Expecting false, got %s/%s\n", $offset + 2, gettype($tmp), $tmp);
try {
mysqli_num_rows($res);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
}
}
@@ -57,7 +60,6 @@ require_once('skipifconnectfailure.inc');
printf("[031] Expecting int/0, got %s/%d\n", gettype($tmp), $tmp);
mysqli_free_result($res);
} else {
printf("[032] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
@@ -70,7 +72,10 @@ require_once('skipifconnectfailure.inc');
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_num_rows(): Couldn't fetch mysqli_result in %s on line %d
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

View File

@@ -88,8 +88,13 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
echo "Link closed";
var_dump("MYSQLI_INIT_COMMAND", mysqli_options($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=1'));
echo "Link closed\n";
try {
mysqli_options($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=1');
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECTF--
@@ -118,7 +123,5 @@ bool(true)
%s(17) "MYSQLI_CLIENT_SSL"
bool(false)
Link closed
Warning: mysqli_options(): Couldn't fetch mysqli in %s line %d
%s(19) "MYSQLI_INIT_COMMAND"
bool(false)
mysqli object is already closed
done!

View File

@@ -62,7 +62,11 @@ mysqli.max_persistent=2
printf("[009] Thread of the regular connection should be still there, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
// On PHP side this should do nothing. PHP should not try to close the connection or something.
@mysqli_close($plink);
try {
mysqli_close($plink);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!$plink = @my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[011] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
@@ -92,4 +96,5 @@ mysqli.max_persistent=2
require_once("clean_table.inc");
?>
--EXPECT--
mysqli object is already closed
done!

View File

@@ -25,14 +25,16 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
if (false !== ($tmp = mysqli_ping($link)))
printf("[005] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_ping($link);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECTF--
--EXPECT--
bool(true)
bool(true)
Warning: mysqli_ping(): Couldn't fetch mysqli in %s on line %d
mysqli object is already closed
done!

View File

@@ -90,8 +90,11 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
if (false !== ($tmp = mysqli_query($link, "SELECT id FROM test")))
printf("[011] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_query($link, "SELECT id FROM test");
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -109,7 +112,7 @@ if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
mysqli_close($link);
?>
--EXPECTF--
--EXPECT--
array(1) {
["valid"]=>
string(30) "this is sql but with semicolon"
@@ -119,6 +122,5 @@ array(1) {
string(1) "a"
}
string(1) "a"
Warning: mysqli_query(): Couldn't fetch mysqli in %s on line %d
mysqli object is already closed
done!

View File

@@ -23,13 +23,18 @@ require_once('skipifconnectfailure.inc');
var_dump($row);
}
echo "======\n";
foreach ($res as $row) {
var_dump($row);
}
mysqli_free_result($res);
foreach ($res as $row) {
var_dump($row);
}
try {
foreach ($res as $row) {
$row;
}
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
}
echo "--- Testing USE_RESULT ---\n";
if (!is_object($res = mysqli_query($link, "SELECT id FROM test ORDER BY id", MYSQLI_USE_RESULT)))
@@ -118,8 +123,7 @@ array(1) {
["id"]=>
string(1) "6"
}
Warning: main(): Couldn't fetch mysqli_result in %s on line %d
mysqli_result object is already closed
--- Testing USE_RESULT ---
array(1) {
["id"]=>

View File

@@ -75,8 +75,11 @@ mysqli_close($link);
mysqli_close($link);
if (false !== ($tmp = mysqli_query($link, "SELECT id FROM test")))
printf("[014] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_query($link, "SELECT id FROM test");
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -85,6 +88,5 @@ array(1) {
["правилен"]=>
string(%d) "това ескюел, но с точка и запетая"
}
Warning: mysqli_query(): Couldn't fetch mysqli in %s on line %d
mysqli object is already closed
done!

View File

@@ -140,8 +140,11 @@ mysqli.allow_local_infile=1
@mysqli_close($link);
}
if (false !== ($tmp = mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)))
printf("[026] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -159,6 +162,5 @@ object(mysqli)#%d (%d) {
["connect_error"]=>
NULL
}
Warning: mysqli_real_connect(): Couldn't fetch mysqli in %s on line %d
mysqli object is already closed
done!

View File

@@ -32,11 +32,14 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
if (false !== ($tmp = mysqli_real_escape_string($link, 'foo')))
printf("[010] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_real_escape_string($link, 'foo');
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECTF--
Warning: mysqli_real_escape_string(): Couldn't fetch mysqli in %s on line %d
--EXPECT--
mysqli object is already closed
done!

View File

@@ -62,8 +62,11 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
if (false !== ($tmp = mysqli_real_escape_string($link, 'foo')))
printf("[018] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_real_escape_string($link, 'foo');
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -71,6 +74,6 @@ require_once('skipifconnectfailure.inc');
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_real_escape_string(): Couldn't fetch mysqli in %s on line %d
--EXPECT--
mysqli object is already closed
done!

View File

@@ -72,8 +72,11 @@ ver_param;')) {
mysqli_close($link);
if (false !== ($tmp = mysqli_real_query($link, "SELECT id FROM test")))
printf("[011] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_real_query($link, "SELECT id FROM test");
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -91,11 +94,10 @@ if (!mysqli_query($link, "DROP TABLE IF EXISTS test"))
mysqli_close($link);
?>
--EXPECTF--
--EXPECT--
array(1) {
["valid"]=>
string(30) "this is sql but with semicolon"
}
Warning: mysqli_real_query(): Couldn't fetch mysqli in %s on line %d
mysqli object is already closed
done!

View File

@@ -59,6 +59,7 @@ require_once('skipifconnectfailure.inc');
$references[$idx++] = &$res;
mysqli_free_result($res);
debug_zval_dump($references);
if (!(mysqli_real_query($link, "SELECT id, label FROM test ORDER BY id ASC LIMIT 1")) ||

View File

@@ -49,8 +49,11 @@ mysqli_rollback()
mysqli_close($link);
if (false !== ($tmp = mysqli_rollback($link)))
printf("[014] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_rollback($link);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!\n";
?>
@@ -58,6 +61,6 @@ mysqli_rollback()
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_rollback(): Couldn't fetch mysqli in %s on line %d
--EXPECT--
mysqli object is already closed
done!

View File

@@ -88,13 +88,16 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
if (false !== ($tmp = mysqli_select_db($link, $db)))
printf("[019] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_select_db($link, $db);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!\n";
?>
--CLEAN--
<?php require_once("clean_table.inc"); ?>
--EXPECTF--
Warning: mysqli_select_db(): Couldn't fetch mysqli in %s on line %d
--EXPECT--
mysqli object is already closed
done!

View File

@@ -40,11 +40,13 @@ if (!$TEST_EXPERIMENTAL)
mysqli_close($link);
if (NULL !== ($tmp = mysqli_send_query($link, 'SELECT 1')))
printf("[006] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_send_query($link, 'SELECT 1');
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECTF--
Warning: mysqli_send_query(): Couldn't fetch mysqli in %s on line %d
mysqli object is already closed
done!

View File

@@ -104,8 +104,11 @@ if ((($res = mysqli_query($link, 'SHOW CHARACTER SET LIKE "latin1"', MYSQLI_STOR
mysqli_close($link);
if (false !== ($tmp = mysqli_set_charset($link, $new_charset)))
printf("[019] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_set_charset($link, $new_charset);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -113,6 +116,6 @@ if ((($res = mysqli_query($link, 'SHOW CHARACTER SET LIKE "latin1"', MYSQLI_STOR
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_set_charset(): Couldn't fetch mysqli in %s on line %d
--EXPECT--
mysqli object is already closed
done!

View File

@@ -28,11 +28,15 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
var_dump(mysqli_set_opt($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=1'));
try {
mysqli_set_opt($link, MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT=1');
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECTF--
--EXPECT--
bool(true)
bool(true)
bool(true)
@@ -45,7 +49,5 @@ bool(true)
bool(true)
bool(true)
bool(false)
Warning: mysqli_set_opt(): Couldn't fetch mysqli in %s on line %d
bool(false)
mysqli object is already closed
done!

View File

@@ -20,7 +20,11 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
var_dump(mysqli_sqlstate($link));
try {
mysqli_sqlstate($link);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -32,7 +36,5 @@ require_once('skipifconnectfailure.inc');
%s(5) "00000"
%s(5) "42S22"
%s(5) "00000"
Warning: mysqli_sqlstate(): Couldn't fetch mysqli in %s on line %d
bool(false)
mysqli object is already closed
done!

View File

@@ -18,11 +18,14 @@ require_once('skipifconnectfailure.inc');
mysqli_close($link);
if (false !== ($tmp = mysqli_stat($link)))
printf("[005] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stat($link);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
--EXPECTF--
Warning: mysqli_stat(): Couldn't fetch mysqli in %s on line %d
--EXPECT--
mysqli object is already closed
done!

View File

@@ -225,8 +225,11 @@ require_once('skipifconnectfailure.inc');
mysqli_stmt_close($stmt);
if (false !== ($tmp = mysqli_stmt_affected_rows($stmt)))
printf("[047] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_affected_rows($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
@@ -238,6 +241,5 @@ require_once('skipifconnectfailure.inc');
?>
--EXPECTF--
[009] [%d] (error message varies with the MySQL Server version, check the error code)
Warning: mysqli_stmt_affected_rows(): Couldn't fetch mysqli_stmt in %s on line %d
mysqli_stmt object is already closed
done!

View File

@@ -25,8 +25,12 @@ require_once('skipifconnectfailure.inc');
$stmt = mysqli_stmt_init($link);
mysqli_stmt_prepare($stmt, 'SELECT * FROM test');
if (false !== ($tmp = @mysqli_stmt_attr_get($stmt, $invalid_attr)))
printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_attr_get($stmt, $invalid_attr);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
foreach ($valid_attr as $k => $attr) {
if (false === ($tmp = mysqli_stmt_attr_get($stmt, $attr))) {
@@ -38,10 +42,11 @@ require_once('skipifconnectfailure.inc');
$stmt->close();
foreach ($valid_attr as $k => $attr) {
if (false !== ($tmp = @mysqli_stmt_attr_get($stmt, $attr))) {
printf("[007] Expecting false, got %s/%s for attribute %s/%s\n",
gettype($tmp), $tmp, $k, $attr);
}
try {
mysqli_stmt_attr_get($stmt, $attr);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
}
mysqli_close($link);
@@ -52,4 +57,7 @@ require_once('skipifconnectfailure.inc');
require_once("clean_table.inc");
?>
--EXPECT--
mysqli_stmt object is already closed
mysqli_stmt object is already closed
mysqli_stmt object is already closed
done!

View File

@@ -26,8 +26,11 @@ require_once("connect.inc");
$stmt = mysqli_stmt_init($link);
if (false !== ($tmp = @mysqli_stmt_attr_set($stmt, 0, 0)))
printf("[005] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_attr_set($stmt, 0, 0);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
$stmt->prepare("SELECT * FROM test");
@@ -259,4 +262,5 @@ require_once("connect.inc");
require_once("clean_table.inc");
?>
--EXPECT--
mysqli_stmt object is not fully initialized
done!

View File

@@ -22,8 +22,11 @@ require_once('skipifconnectfailure.inc');
$label = null;
$foo = null;
if (false !== ($tmp = mysqli_stmt_bind_result($stmt, $id)))
printf("[003] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_bind_result($stmt, $id);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
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));
@@ -300,8 +303,7 @@ require_once('skipifconnectfailure.inc');
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_bind_result(): invalid object or resource mysqli_stmt
in %s on line %d
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

View File

@@ -16,8 +16,11 @@ require_once('skipifconnectfailure.inc');
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
// Yes, amazing, eh? AFAIK a work around of a constructor bug...
if (false !== ($tmp = mysqli_stmt_close($stmt)))
printf("[004] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_close($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test"))
printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
@@ -25,8 +28,11 @@ require_once('skipifconnectfailure.inc');
if (true !== ($tmp = mysqli_stmt_close($stmt)))
printf("[006] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
if (false !== ($tmp = mysqli_stmt_close($stmt)))
printf("[007] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_close($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!$stmt = mysqli_stmt_init($link))
printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -74,9 +80,7 @@ require_once('skipifconnectfailure.inc');
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_close(): invalid object or resource mysqli_stmt
in %s on line %d
Warning: mysqli_stmt_close(): Couldn't fetch mysqli_stmt in %s on line %d
--EXPECT--
mysqli_stmt object is not fully initialized
mysqli_stmt object is already closed
done!

View File

@@ -15,8 +15,11 @@ require_once('skipifconnectfailure.inc');
if (!$stmt = mysqli_stmt_init($link))
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (false !== ($tmp = mysqli_stmt_data_seek($stmt, 1)))
printf("[004] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_data_seek($stmt, 1);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id"))
printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
@@ -66,8 +69,11 @@ require_once('skipifconnectfailure.inc');
mysqli_stmt_close($stmt);
if (false !== ($tmp = mysqli_stmt_data_seek($stmt, 0)))
printf("[017] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_data_seek($stmt, 0);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
print "done!";
@@ -77,14 +83,12 @@ require_once('skipifconnectfailure.inc');
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_data_seek(): invalid object or resource mysqli_stmt
in %s on line %d
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
int(1)
Warning: mysqli_stmt_data_seek(): Couldn't fetch mysqli_stmt in %s on line %d
mysqli_stmt object is already closed
done!

View File

@@ -44,8 +44,11 @@ require_once('skipifconnectfailure.inc');
mysqli_stmt_close($stmt);
if (false !== ($tmp = mysqli_stmt_errno($stmt)))
printf("[011] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_errno($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
print "done!";
@@ -54,6 +57,6 @@ require_once('skipifconnectfailure.inc');
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_errno(): Couldn't fetch mysqli_stmt in %s on line %d
--EXPECT--
mysqli_stmt object is already closed
done!

View File

@@ -44,8 +44,11 @@ require_once('skipifconnectfailure.inc');
mysqli_stmt_close($stmt);
if (false !== ($tmp = mysqli_stmt_error($stmt)))
printf("[011] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_error($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
print "done!";
@@ -54,6 +57,6 @@ require_once('skipifconnectfailure.inc');
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_error(): Couldn't fetch mysqli_stmt in %s on line %d
--EXPECT--
mysqli_stmt object is already closed
done!

View File

@@ -22,15 +22,21 @@ if (mysqli_get_server_version($link) <= 40100) {
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
// stmt object status test
if (false !== ($tmp = mysqli_stmt_execute($stmt)))
printf("[004] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_execute($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (mysqli_stmt_prepare($stmt, "SELECT i_do_not_exist_believe_me FROM test ORDER BY id"))
printf("[005] Statement should have failed!\n");
// stmt object status test
if (false !== ($tmp = mysqli_stmt_execute($stmt)))
printf("[006] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_execute($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!mysqli_stmt_prepare($stmt, "SELECT id FROM test ORDER BY id LIMIT 1"))
printf("[007] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
@@ -117,8 +123,11 @@ if (mysqli_get_server_version($link) <= 40100) {
mysqli_stmt_close($stmt);
if (false !== ($tmp = mysqli_stmt_execute($stmt)))
printf("[028] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_execute($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
print "done!";
@@ -127,15 +136,11 @@ if (mysqli_get_server_version($link) <= 40100) {
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_execute(): invalid object or resource mysqli_stmt
in %s on line %d
Warning: mysqli_stmt_execute(): invalid object or resource mysqli_stmt
in %s on line %d
--EXPECT--
mysqli_stmt object is not fully initialized
mysqli_stmt object is not fully initialized
bool(true)
bool(true)
[027] Expecting boolean/false, got boolean/1
Warning: mysqli_stmt_execute(): Couldn't fetch mysqli_stmt in %s on line %d
mysqli_stmt object is already closed
done!

View File

@@ -21,8 +21,11 @@ require_once('skipifconnectfailure.inc');
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
// stmt object status test
if (false !== ($tmp = mysqli_stmt_fetch($stmt)))
printf("[004] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_fetch($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2"))
printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
@@ -64,8 +67,11 @@ require_once('skipifconnectfailure.inc');
mysqli_stmt_close($stmt);
if (false !== ($tmp = mysqli_stmt_fetch($stmt)))
printf("[016] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_fetch($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
@@ -76,9 +82,7 @@ require_once('skipifconnectfailure.inc');
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_fetch(): invalid object or resource mysqli_stmt
in %s on line %d
mysqli_stmt object is not fully initialized
[014] [%d] Commands out of sync; you can't run this command now
Warning: mysqli_stmt_fetch(): Couldn't fetch mysqli_stmt in %s on line %d
mysqli_stmt object is already closed
done!

View File

@@ -13,14 +13,21 @@ require_once('skipifconnectfailure.inc');
require('table.inc');
$stmt = mysqli_stmt_init($link);
if (false !== ($tmp = mysqli_stmt_field_count($stmt)))
printf("[003] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_field_count($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (mysqli_stmt_prepare($stmt, ''))
printf("[004] Prepare should fail for an empty statement\n");
if (false !== ($tmp = mysqli_stmt_field_count($stmt)))
printf("[005] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_field_count($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!mysqli_stmt_prepare($stmt, 'SELECT 1'))
printf("[006] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
@@ -64,11 +71,17 @@ require_once('skipifconnectfailure.inc');
mysqli_stmt_close($stmt);
if (mysqli_stmt_prepare($stmt, 'SELECT id FROM test'))
printf("[020] Prepare should fail, statement has been closed\n");
try {
mysqli_stmt_prepare($stmt, 'SELECT id FROM test');
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (false !== ($tmp = mysqli_stmt_field_count($stmt)))
printf("[021] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_field_count($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
@@ -79,15 +92,10 @@ require_once('skipifconnectfailure.inc');
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_field_count(): invalid object or resource mysqli_stmt
in %s on line %d
Warning: mysqli_stmt_field_count(): invalid object or resource mysqli_stmt
in %s on line %d
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
Warning: mysqli_stmt_prepare(): Couldn't fetch mysqli_stmt in %s on line %d
Warning: mysqli_stmt_field_count(): Couldn't fetch mysqli_stmt in %s on line %d
mysqli_stmt object is already closed
mysqli_stmt object is already closed
done!

View File

@@ -21,8 +21,11 @@ require_once('skipifconnectfailure.inc');
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
// stmt object status test
if (false !== ($tmp = mysqli_stmt_free_result($stmt)))
printf("[004] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_free_result($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id"))
printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
@@ -58,8 +61,11 @@ require_once('skipifconnectfailure.inc');
mysqli_stmt_close($stmt);
if (false !== ($tmp = mysqli_stmt_free_result($stmt)))
printf("[015] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_free_result($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
@@ -69,9 +75,7 @@ require_once('skipifconnectfailure.inc');
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_free_result(): invalid object or resource mysqli_stmt
in %s on line %d
Warning: mysqli_stmt_free_result(): Couldn't fetch mysqli_stmt in %s on line %d
--EXPECT--
mysqli_stmt object is not fully initialized
mysqli_stmt object is already closed
done!

View File

@@ -24,8 +24,11 @@ if (!function_exists('mysqli_stmt_get_result'))
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
// stmt object status test
if (false !== ($tmp = mysqli_stmt_fetch($stmt)))
printf("[004] Expecting false, got %s/%s\n", gettype($tmp), var_export($tmp, 1));
try {
mysqli_stmt_fetch($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2"))
printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
@@ -49,8 +52,11 @@ if (!function_exists('mysqli_stmt_get_result'))
printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
// stmt object status test
if (false !== ($tmp = mysqli_stmt_fetch($stmt)))
printf("[011] Expecting false, got %s/%s\n", gettype($tmp), var_export($tmp, 1));
try {
mysqli_stmt_fetch($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2"))
printf("[012] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
@@ -72,8 +78,11 @@ if (!function_exists('mysqli_stmt_get_result'))
printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
// stmt object status test
if (false !== ($tmp = mysqli_stmt_get_result($stmt)))
printf("[018] Expecting false, got %s/%s\n", gettype($tmp), var_export($tmp, 1));
try {
mysqli_stmt_get_result($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!mysqli_stmt_prepare($stmt, "SELECT id, label FROM test ORDER BY id LIMIT 2"))
printf("[019] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
@@ -139,8 +148,11 @@ if (!function_exists('mysqli_stmt_get_result'))
mysqli_stmt_close($stmt);
if (false !== ($tmp = mysqli_stmt_fetch($stmt)))
printf("[042] Expecting false, got %s/%s\n", gettype($tmp), var_export($tmp, 1));
try {
mysqli_stmt_fetch($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
@@ -151,14 +163,9 @@ if (!function_exists('mysqli_stmt_get_result'))
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_fetch(): invalid object or resource mysqli_stmt
in %s on line %d
Warning: mysqli_stmt_fetch(): invalid object or resource mysqli_stmt
in %s on line %d
Warning: mysqli_stmt_get_result(): invalid object or resource mysqli_stmt
in %s on line %d
mysqli_stmt object is not fully initialized
mysqli_stmt object is not fully initialized
mysqli_stmt object is not fully initialized
[038] [2014] [Commands out of sync; you can't run this command now]
[039] [0] []
array(2) {
@@ -173,6 +180,5 @@ array(2) {
["label"]=>
%s(1) "b"
}
Warning: mysqli_stmt_fetch(): Couldn't fetch mysqli_stmt in %s on line %d
mysqli_stmt object is already closed
done!

View File

@@ -132,18 +132,19 @@ if (!function_exists('mysqli_stmt_get_result'))
mysqli_stmt_close($stmt);
mysqli_close($link);
if (false !== ($res = mysqli_stmt_get_result($stmt))) {
printf("[026] Expecting false got %s/%s\n",
gettype($res), $res);
}
try {
mysqli_stmt_get_result($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
print "done!";
?>
--CLEAN--
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
--EXPECT--
array(2) {
["id"]=>
int(1)
@@ -159,6 +160,5 @@ array(2) {
}
NULL
[017] [2014] Commands out of sync; you can't run this command now
Warning: mysqli_stmt_get_result(): Couldn't fetch mysqli_stmt in %s on line %d
mysqli_stmt object is already closed
done!

View File

@@ -193,15 +193,27 @@ if (!function_exists('mysqli_stmt_get_result'))
$res->free_result();
mysqli_free_result($res_meta);
var_dump(mysqli_fetch_field($res));
try {
mysqli_fetch_field($res);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_stmt_close($stmt);
var_dump(mysqli_fetch_field($res));
try {
mysqli_fetch_field($res);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
var_dump(mysqli_fetch_field($res));
try {
mysqli_fetch_field($res);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -225,13 +237,7 @@ _id
_label
_null
_label_concat
Warning: mysqli_fetch_field(): Couldn't fetch mysqli_result in %s on line %d
bool(false)
Warning: mysqli_fetch_field(): Couldn't fetch mysqli_result in %s on line %d
bool(false)
Warning: mysqli_fetch_field(): Couldn't fetch mysqli_result in %s on line %d
bool(false)
mysqli_result object is already closed
mysqli_result object is already closed
mysqli_result object is already closed
done!

View File

@@ -94,19 +94,31 @@ if (!function_exists('mysqli_stmt_get_result'))
mysqli_free_result($res);
if (false !== ($tmp = mysqli_data_seek($res, 0)))
printf("[017] Expecting false got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_data_seek($res, 0);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (false !== ($row = $res->fetch_array(MYSQLI_NUM)))
printf("[018] Expecting false got %s/%s\n", gettype($tmp), $tmp);
try {
$res->fetch_array(MYSQLI_NUM);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
if (false !== ($tmp = mysqli_data_seek($res, 0)))
printf("[019] Expecting false got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_data_seek($res, 0);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (false !== ($row = $res->fetch_array(MYSQLI_NUM)))
printf("[020] Expecting false got %s/%s\n", gettype($tmp), $tmp);
try {
$res->fetch_array(MYSQLI_NUM);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
print "done!";
?>
@@ -114,12 +126,9 @@ if (!function_exists('mysqli_stmt_get_result'))
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_data_seek(): Couldn't fetch mysqli_result in %s on line %d
Warning: mysqli_result::fetch_array(): Couldn't fetch mysqli_result in %s on line %d
Warning: mysqli_data_seek(): Couldn't fetch mysqli_result in %s on line %d
Warning: mysqli_result::fetch_array(): Couldn't fetch mysqli_result in %s on line %d
--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
done!

View File

@@ -31,8 +31,11 @@ mysqli_query($link, "DROP TABLE IF EXISTS test");
if (!$stmt = mysqli_stmt_init($link))
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (false !== ($tmp = mysqli_stmt_get_warnings($stmt)))
printf("[004] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_get_warnings($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
if (!mysqli_stmt_prepare($stmt, "SET sql_mode=''") || !mysqli_stmt_execute($stmt))
printf("[005] [%d] %s\n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
@@ -83,8 +86,11 @@ mysqli_query($link, "DROP TABLE IF EXISTS test");
mysqli_stmt_close($stmt);
if (false !== ($tmp = mysqli_stmt_get_warnings($stmt)))
printf("[018] Expecting false, got %s/%s\n", gettype($tmp), $tmp);
try {
mysqli_stmt_get_warnings($stmt);
} catch (Error $exception) {
echo $exception->getMessage() . "\n";
}
mysqli_close($link);
print "done!";
@@ -93,9 +99,7 @@ mysqli_query($link, "DROP TABLE IF EXISTS test");
<?php
require_once("clean_table.inc");
?>
--EXPECTF--
Warning: mysqli_stmt_get_warnings(): invalid object or resource mysqli_stmt
in %s on line %d
Warning: mysqli_stmt_get_warnings(): Couldn't fetch mysqli_stmt in %s on line %d
--EXPECT--
mysqli_stmt object is not fully initialized
mysqli_stmt object is already closed
done!

Some files were not shown because too many files have changed in this diff Show More