From: pcdinh at gmail dot com Operating system: Windows XP PHP version: 5.2.11 PHP Bug Type: cURL related Bug description: curl_close() does not delete cURL handle as expected
Description: ------------ As stated at http://php.net/manual/en/function.curl-close.php an invocation to curl_close($ch) will "Closes a cURL session and frees all resources. The cURL handle, ch , is also deleted. " However, it does not. Curl seems to work differently than other functions that produce a resource as well. Curl does not pass by reference implicitly For example: // create an image resource $image = imagecreate(100, 100); $im = new stdClass(); $im->res = $image; // pass by reference var_dump($image); var_dump($im->res); imagedestroy($image); var_dump($image); // will print resource(4) of type (Unknown) var_dump($im->res); // will print resource(4) of type (Unknown) After calling imagedestroy($image), $image and $im->res are deleted Reproduce code: --------------- $s = curl_init(); $im = new stdClass(); $im->res = $s; // resource is passed by reference var_dump($s); // will print: resource(5) of type (curl) var_dump($im->res); // will print: resource(5) of type (curl) curl_close($s); var_dump($s); var_dump($im->res); Expected result: ---------------- $s = curl_init(); $im = new stdClass(); $im->res = $s; // resource is passed by reference var_dump($s); // will print: resource(5) of type (curl) var_dump($im->res); // will print: resource(5) of type (curl) curl_close($s); var_dump($s); // (expected): resource(5) of type (Unknown) var_dump($im->res); // (expected): resource(5) of type (Unknown) Actual result: -------------- $s = curl_init(); $im = new stdClass(); $im->res = $s; // resource is actually passed by value var_dump($s); // will print: resource(5) of type (curl) var_dump($im->res); // will print: resource(5) of type (curl) curl_close($s); var_dump($s); // (actual): resource(5) of type (curl) var_dump($im->res); // (actual): resource(5) of type (curl) $s becomes invalid but $im->res is still valid for subsequent operations. -- Edit bug report at http://bugs.php.net/?id=50477&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50477&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50477&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50477&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=50477&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50477&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=50477&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=50477&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=50477&r=needscript Try newer version: http://bugs.php.net/fix.php?id=50477&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=50477&r=support Expected behavior: http://bugs.php.net/fix.php?id=50477&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=50477&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=50477&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=50477&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50477&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=50477&r=dst IIS Stability: http://bugs.php.net/fix.php?id=50477&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=50477&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=50477&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=50477&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=50477&r=mysqlcfg