Doc #62101 [NEW]: Example coding error

From: Date: Mon, 21 May 2012 23:33:20 +0000
Subject: Doc #62101 [NEW]: Example coding error
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-8388@lists.php.net to get a copy of this message
From:             
Operating system: Windows 7
PHP version:      5.3.13
Package:          Documentation problem
Bug Type:         Documentation Problem
Bug description:Example coding error

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



-- 
Edit bug report at https://bugs.php.net/bug.php?id=62101&edit=1
-- 
Try a snapshot (PHP 5.4):            https://bugs.php.net/fix.php?id=62101&r=trysnapshot54
Try a snapshot (PHP 5.3):            https://bugs.php.net/fix.php?id=62101&r=trysnapshot53
Try a snapshot (trunk):              https://bugs.php.net/fix.php?id=62101&r=trysnapshottrunk
Fixed in SVN:                        https://bugs.php.net/fix.php?id=62101&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=62101&r=needdocs
Fixed in release:                    https://bugs.php.net/fix.php?id=62101&r=alreadyfixed
Need backtrace:                      https://bugs.php.net/fix.php?id=62101&r=needtrace
Need Reproduce Script:               https://bugs.php.net/fix.php?id=62101&r=needscript
Try newer version:                   https://bugs.php.net/fix.php?id=62101&r=oldversion
Not developer issue:                 https://bugs.php.net/fix.php?id=62101&r=support
Expected behavior:                   https://bugs.php.net/fix.php?id=62101&r=notwrong
Not enough info:                     https://bugs.php.net/fix.php?id=62101&r=notenoughinfo
Submitted twice:                     https://bugs.php.net/fix.php?id=62101&r=submittedtwice
register_globals:                    https://bugs.php.net/fix.php?id=62101&r=globals
PHP 4 support discontinued:          https://bugs.php.net/fix.php?id=62101&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=62101&r=dst
IIS Stability:                       https://bugs.php.net/fix.php?id=62101&r=isapi
Install GNU Sed:                     https://bugs.php.net/fix.php?id=62101&r=gnused
Floating point limitations:          https://bugs.php.net/fix.php?id=62101&r=float
No Zend Extensions:                  https://bugs.php.net/fix.php?id=62101&r=nozend
MySQL Configuration Error:           https://bugs.php.net/fix.php?id=62101&r=mysqlcfg



Thread (2 messages)

« previous php.doc.bugs (#8388) next »