Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.6.0

Bug #15617 HTTP_Request2 unusable if phpversion <= 5.2.6 and curlversion >= 7.18.0
Submitted: 2009-01-12 14:12 UTC
From: kase Assigned: avb
Status: Closed Package: HTTP_Request2 (version 0.2.0)
PHP Version: 5.2.6 OS:
Roadmaps: 0.3.0    
Subscription  


 [2009-01-12 14:12 UTC] kase (Timo Gmell)
Description: ------------ Hi, there is a bug (http://bugs.php.net/45220) in php <= 5.2.6 that triggers the following exception if request-method = POST and post data added to the request: Error sending request: #26 Failed to open/read local data from file/application in pear/HTTP/Request2.php on line 792 The related C-Code in ext/curl/interface.c (line 783++): [START] ... int length = -1; ... switch (t->method) { case PHP_CURL_DIRECT: // file length = fread(... break; case PHP_CURL_USER: ... error = zend_call_function(&fci, &t->fci_cache TSRMLS_CC); if (error == FAILURE) { ... } else if (retval_ptr) { if (Z_TYPE_P(retval_ptr) == IS_STRING) { length = MIN(size * nmemb, Z_STRLEN_P(retval_ptr)); ... } } ... return length; [END] length = -1 is not valid since curl >= 7.18.0, which is fixed in php 5.2.7 (length = 0). But some linux distributions use this combination of versions (e.g. ubuntu hardy = php 5.2.4, curl 7.18.0), so HTTP_Request2 does not work. There is a way to fix this bug without building a new php binary. If retval_ptr != false and retval_ptr == IS_STRING (see C-Code above), then length = strlen(retval_ptr). You can add the following fix to Adapter/Curl.php line 290: before: return false; after: $curlVersion = curl_version(); $curlVersion = $curlVersion['version']; $phpVersion = phpversion(); if (version_compare($phpVersion, '5.2.6', '<=') && version_compare($curlVersion, '7.18.0', '>=')) { return ''; // empty string } else { return false; } Expected result: ---------------- The post request is executed Actual result: -------------- Error sending request: #26 Failed to open/read local data from file/application in pear/HTTP/Request2.php on line 792

Comments

 [2009-01-12 21:25 UTC] avb (Alexey Borzov)
Can you clarify: is this version check really needed? From the description of the PHP bug and my understanding of curl_read() source and [1] we can just return an empty string instead of false in either case and it will be processed correctly?.. [1] http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTREADFUNCTION
 [2009-01-14 10:46 UTC] kase (Timo Gmell)
Hi, i think, returning an empty string SHOULD always work. I can not test this with: php >= 5.2.7 + curl >= 7.18.0 and php <= 5.2.6 + curl < 7.18.0 so i decided to add the version check to be sure. Thanks for the fast response and your great packages :)
 [2009-01-16 21:53 UTC] avb (Alexey Borzov)
Tested here with PHP 5.2.5 and cURL 7.16.0, works OK, so probably will work OK anywhere. Fixed in CVS.