summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-03-15 14:38:22 +0100
committerNikita Popov <nikita.ppv@gmail.com>2021-03-15 14:38:49 +0100
commit6493b516f9573f8a9368376b900eb9df758b1d40 (patch)
tree7febc635e57e31a84f842012bbc0625078dcafca /ext
parent3306baca50f7c28f5643fb6e5a2a24971e9d45b5 (diff)
parentc93b461ad70e341f1b01f5910f3cfc3055a3941e (diff)
downloadphp-git-6493b516f9573f8a9368376b900eb9df758b1d40.tar.gz
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix bug #80837
Diffstat (limited to 'ext')
-rw-r--r--ext/mysqli/tests/bug80837.phpt38
-rw-r--r--ext/mysqlnd/mysqlnd_ps.c2
2 files changed, 39 insertions, 1 deletions
diff --git a/ext/mysqli/tests/bug80837.phpt b/ext/mysqli/tests/bug80837.phpt
new file mode 100644
index 0000000000..71e31aa31b
--- /dev/null
+++ b/ext/mysqli/tests/bug80837.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Bug #80837 Calling stmt_store_result after fetch doesn't throw an error
+--SKIPIF--
+<?php
+require_once 'skipif.inc';
+require_once 'skipifconnectfailure.inc';
+if (!defined('MYSQLI_STORE_RESULT_COPY_DATA')) die('skip requires mysqlnd');
+?>
+--FILE--
+<?php
+require_once "connect.inc";
+
+mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
+$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
+
+$mysqli->query('DROP TABLE IF EXISTS test');
+$mysqli->query('CREATE TABLE test (b int)');
+$mysqli->query('INSERT INTO test VALUES (1),(2),(3)');
+
+$statement = $mysqli->prepare("SELECT b FROM test");
+$statement->execute();
+$statement->bind_result($name);
+$statement->fetch();
+try {
+ $statement->store_result();
+} catch (mysqli_sql_exception $e) {
+ echo $e->getMessage();
+}
+
+$mysqli->close();
+
+?>
+--CLEAN--
+<?php
+require_once "clean_table.inc";
+?>
+--EXPECTF--
+Commands out of sync; you can't run this command now
diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c
index deaf52de62..f3dee49d88 100644
--- a/ext/mysqlnd/mysqlnd_ps.c
+++ b/ext/mysqlnd/mysqlnd_ps.c
@@ -89,7 +89,7 @@ MYSQLND_METHOD(mysqlnd_stmt, store_result)(MYSQLND_STMT * const s)
/* Nothing to store for UPSERT/LOAD DATA*/
if (!mysqlnd_stmt_check_state(stmt)) {
- SET_CLIENT_ERROR(conn->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
+ SET_CLIENT_ERROR(stmt->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE, mysqlnd_out_of_sync);
DBG_RETURN(NULL);
}