php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80837 Calling stmt_store_result after fetch doesn't throw an error
Submitted: 2021-03-05 21:35 UTC Modified: -
From: dharman@php.net Assigned:
Status: Closed Package: MySQLi related
PHP Version: master-Git-2021-03-05 (Git) OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dharman@php.net
New email:
PHP Version: OS:

 

 [2021-03-05 21:35 UTC] dharman@php.net
Description:
------------
Calling stmt_store_result when in the middle of manual fetch cycle should throw an OOS error. However, mysqlnd sets the error in conn property which means mysqli will not throw it. 

Test script:
---------------
<?php

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$mysqli = new mysqli('localhost', 'user', 'password', 'test');
$mysqli->set_charset('utf8mb4'); // always set the charset

$statement = $mysqli->prepare("SELECT b FROM a");
$statement->execute();
$statement->bind_result($name);
$statement->fetch();
$statement->store_result();
var_dump($mysqli->error, $statement->error);
echo $statement->num_rows();

Expected result:
----------------
Fatal error: Uncaught mysqli_sql_exception: Commands out of sync; you can't run this command now

Actual result:
--------------
string(52) "Commands out of sync; you can't run this command now"
string(0) ""
0

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-03-05 22:01 UTC] dharman@php.net
The following pull request has been associated:

Patch Name: Fix bug #80837
On GitHub:  https://github.com/php/php-src/pull/6755
Patch:      https://github.com/php/php-src/pull/6755.patch
 [2021-03-15 13:39 UTC] nikic@php.net
Automatic comment on behalf of tekiela246@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=c93b461ad70e341f1b01f5910f3cfc3055a3941e
Log: Fix bug #80837
 [2021-03-15 13:39 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Sep 24 13:03:38 2021 UTC