php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68997 var_dump(mysqli) doesn't work with MYSQLI_ASYNC queries
Submitted: 2015-02-06 16:16 UTC Modified: 2023-01-10 16:14 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:1 (50.0%)
From: maxm at corp dot badoo dot com Assigned: dharman (profile)
Status: Closed Package: MySQLi related
PHP Version: 5.5.21 OS: Linux
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: maxm at corp dot badoo dot com
New email:
PHP Version: OS:

 

 [2015-02-06 16:16 UTC] maxm at corp dot badoo dot com
Description:
------------
If I take code from http://php.net/manual/en/mysqli.poll.php and add 2 var_dump's/print_r's (see my code), that code starts to generate "Commands out of sync; you can't run this command now"

So as I understand we can't use var_dump() for the connection at this stage. It would be great to describe it in the documentation.

Test script:
---------------
<?php
$link1 = mysqli_init();
mysqli_real_connect($link1, 'dbm1.d4','developer','developerovich');
mysqli_query($link1, "SELECT version() as ver", MYSQLI_ASYNC);

$all_links = array($link1);
$processed = 0;
do {
    $links = $errors = $reject = array();
    foreach ($all_links as $link) {
        $links[] = $errors[] = $reject[] = $link;
    }

var_dump($links); // !!! this var_dump cause the problem
    if (!mysqli_poll($links, $errors, $reject, 1)) {
        continue;
    }
print_r($links); // it shows us that we have text in the$mysqli->error object
    foreach ($links as $link) {
        if ($result = $link->reap_async_query()) {
            print_r($result->fetch_assoc());
            if (is_object($result))
                mysqli_free_result($result);
        } else die(sprintf("MySQLi Error: %s", mysqli_error($link)));
        $processed++;
    }
} while ($processed < count($all_links));


Expected result:
----------------
So, as I understand, we can't call var_dump()/ print_r between:
mysqli_query(...., MYSQLI_ASYNC) and mysqli_poll(...)
It would be great to cover this nuance  in the documentation. Or as a better option, fix var_dump/print_r() to work correctly with mysqli connections with async requests.

Actual result:
--------------
last print_r shows this:

Array
(
    [0] => mysqli Object
        (
            [affected_rows] => -1
            [client_info] => mysqlnd 5.0.11-dev - 20120503 - $Id: 7f4b7f0657d4ab15d8fdac13f23f696de5283a89 $
            [client_version] => 50011
            [connect_errno] => 0
            [connect_error] => 
            [errno] => 2014
            [error] => Commands out of sync; you can't run this command now
            [error_list] => Array
                (
                    [0] => Array
                        (
                            [errno] => 2014
                            [sqlstate] => HY000
                            [error] => Commands out of sync; you can't run this command now
                        )

                )

            [field_count] => 0
            [host_info] => XXXXX via TCP/IP
            [info] => 
            [insert_id] => 0
            [server_info] => 5.5.28-log
            [server_version] => 50528
            [stat] => 
            [sqlstate] => HY000
            [protocol_version] => 10
            [thread_id] => 268564296
            [warning_count] => 0
        )

)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-02-16 14:08 UTC] tony2001@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: andrey
 [2017-10-24 07:21 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: andrey +Assigned To:
 [2023-01-10 16:14 UTC] dharman@php.net
-Status: Open +Status: Closed -Type: Documentation Problem +Type: Bug -Assigned To: +Assigned To: dharman
 [2023-01-10 16:14 UTC] dharman@php.net
I am going to change this to a bug. If I understand correctly this has been fixed a few years ago. If not, please reopen this bug on https://github.com/php/php-src/issues.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 17:01:34 2025 UTC