Bug #69569 [NEW]: cpu usage
| From: | wowkise at gmail dot com | Date: | Mon, 04 May 2015 12:00:29 +0000 |
| Subject: | Bug #69569 [NEW]: cpu usage | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-192475@lists.php.net to get a copy of this message | ||
From: wowkise at gmail dot com
Operating system: Centos
PHP version: 5.5.24
Package: PDO MySQL
Bug Type: Bug
Bug description:cpu usage
Description:
------------
infinite results and huge CPU usage
Test script:
---------------
<?php
$pdo = new \PDO('mysql:host=localhost;dbname=test', 'test', 'test');
$db = new db( $pdo );
class db
{
public function __construct(\PDO &$pdo = null, array $options = [])
{ $this->pdo = $pdo; }
public function query( $sql, array $bind = [], array $options = [])
{
$stmt = $this->pdo->prepare($sql);
$stmt->execute($bind);
return $stmt;
}
}
$sql = "SELECT change_id as id FROM ac_changelog LIMIT 10";
while( $row = $db->query( $sql )->fetch() )
{
echo $row['id'] . PHP_EOL;
}
?>
Expected result:
----------------
10 results returned.
Actual result:
--------------
infinite results and huge CPU usage and until the process is killed.
changing code to
$stmt = $db->query( $sql );
while( $row = $stmt->fetch() )
{
echo $row['id'] . PHP_EOL;
}
fixes the problem.
--
Edit bug report at https://bugs.php.net/bug.php?id=69569&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69569&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69569&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69569&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69569&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69569&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69569&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69569&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69569&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69569&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69569&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69569&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69569&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69569&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69569&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69569&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69569&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69569&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69569&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69569&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69569&r=mysqlcfg