php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #62101 Example coding error
Submitted: 2012-05-21 23:33 UTC Modified: 2012-11-15 13:34 UTC
From: Jack dot Toering at LeadingEdgeITA dot com Assigned: krakjoe (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3.13 OS: Windows 7
Private report: No CVE-ID: None
 [2012-05-21 23:33 UTC] Jack dot Toering at LeadingEdgeITA dot com
Description:
------------
---
From manual page: http://www.php.net/mysqli.poll#refsect1-mysqli.poll-examples
---
This script below is a copy and paste from the example with comments added.  If reap_async_query() fails, $processed will not be incremented, which means it will always remain less than the number of rows in $all_links, meaning "while ($processed < count($all_links))" will remain true, thereby creating and endless loop.

The easiest way to duplicate is to misspell one of the field names in the query string.  However, time there is a query problem, this behavior will occur.


Test script:
---------------
$link1 = mysqli_connect();
$link1->query("SELECT 'test'", MYSQLI_ASYNC);
$all_links = array($link1);
$processed = 0;
do {
    $links = $errors = $reject = array();
    foreach ($all_links as $link) {
        $links[] = $errors[] = $reject[] = $link;
    }
    if (!mysqli_poll($links, $errors, $reject, 1)) {
        continue;
    }
    foreach ($links as $link) {	
        if ($result = $link->reap_async_query()) {   // if reap fails
            print_r($result->fetch_row()); 
            mysqli_free_result($result); 
            $processed++;                            // this not incremented
        }
    }
} while ($processed < count($all_links));	     // this always true



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-15 13:34 UTC] krakjoe@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2012-11-15 13:34 UTC] krakjoe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: krakjoe
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 14:01:29 2024 UTC