Skip to content

Commit 06e78ca

Browse files
committed
Revert "Extend CURLFile to support streams"
This reverts commit 17a9f14, because this commit would break ABI, and also due to bug #79013. We keep the commit for PHP 7.4+, though.
1 parent ae21506 commit 06e78ca

File tree

6 files changed

+1
-147
lines changed

6 files changed

+1
-147
lines changed

NEWS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ PHP NEWS
77
(Dmitry)
88

99
- CURL:
10-
. Implemented FR #77711 (CURLFile should support UNICODE filenames). (cmb)
1110
. Fixed bug #79033 (Curl timeout error with specific url and post). (cmb)
1211

1312
- Date:

ext/curl/interface.c

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,14 +1852,6 @@ static void curl_free_post(void **post)
18521852
}
18531853
/* }}} */
18541854

1855-
/* {{{ curl_free_stream
1856-
*/
1857-
static void curl_free_stream(void **post)
1858-
{
1859-
php_stream_close((php_stream *)*post);
1860-
}
1861-
/* }}} */
1862-
18631855
/* {{{ curl_free_slist
18641856
*/
18651857
static void curl_free_slist(zval *el)
@@ -1951,7 +1943,6 @@ php_curl *alloc_curl_handle()
19511943

19521944
zend_llist_init(&ch->to_free->str, sizeof(char *), (llist_dtor_func_t)curl_free_string, 0);
19531945
zend_llist_init(&ch->to_free->post, sizeof(struct HttpPost *), (llist_dtor_func_t)curl_free_post, 0);
1954-
zend_llist_init(&ch->to_free->stream, sizeof(php_stream *), (llist_dtor_func_t)curl_free_stream, 0);
19551946

19561947
ch->to_free->slist = emalloc(sizeof(HashTable));
19571948
zend_hash_init(ch->to_free->slist, 4, NULL, curl_free_slist, 0);
@@ -2179,32 +2170,6 @@ PHP_FUNCTION(curl_copy_handle)
21792170
}
21802171
/* }}} */
21812172

2182-
#if LIBCURL_VERSION_NUM >= 0x073800
2183-
static size_t read_cb(char *buffer, size_t size, size_t nitems, void *arg) /* {{{ */
2184-
{
2185-
php_stream *stream = (php_stream *) arg;
2186-
size_t numread = php_stream_read(stream, buffer, nitems * size);
2187-
2188-
if (numread == (size_t)-1) {
2189-
return CURL_READFUNC_ABORT;
2190-
}
2191-
return numread;
2192-
}
2193-
/* }}} */
2194-
2195-
static int seek_cb(void *arg, curl_off_t offset, int origin) /* {{{ */
2196-
{
2197-
php_stream *stream = (php_stream *) arg;
2198-
int res = php_stream_seek(stream, offset, origin);
2199-
2200-
if (res) {
2201-
return CURL_SEEKFUNC_CANTSEEK;
2202-
}
2203-
return CURL_SEEKFUNC_OK;
2204-
}
2205-
/* }}} */
2206-
#endif
2207-
22082173
static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ */
22092174
{
22102175
CURLcode error = CURLE_OK;
@@ -2842,9 +2807,6 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
28422807
/* new-style file upload */
28432808
zval *prop, rv;
28442809
char *type = NULL, *filename = NULL;
2845-
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
2846-
php_stream *stream;
2847-
#endif
28482810

28492811
prop = zend_read_property(curl_CURLFile_class, current, "name", sizeof("name")-1, 0, &rv);
28502812
if (Z_TYPE_P(prop) != IS_STRING) {
@@ -2866,24 +2828,17 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
28662828
}
28672829

28682830
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
2869-
if (!(stream = php_stream_open_wrapper(ZSTR_VAL(postval), "rb", IGNORE_PATH, NULL))) {
2870-
zend_string_release_ex(string_key, 0);
2871-
return FAILURE;
2872-
}
28732831
part = curl_mime_addpart(mime);
28742832
if (part == NULL) {
2875-
php_stream_close(stream);
28762833
zend_string_release_ex(string_key, 0);
28772834
return FAILURE;
28782835
}
28792836
if ((form_error = curl_mime_name(part, ZSTR_VAL(string_key))) != CURLE_OK
2880-
|| (form_error = curl_mime_data_cb(part, -1, read_cb, seek_cb, NULL, stream)) != CURLE_OK
2837+
|| (form_error = curl_mime_filedata(part, ZSTR_VAL(postval))) != CURLE_OK
28812838
|| (form_error = curl_mime_filename(part, filename ? filename : ZSTR_VAL(postval))) != CURLE_OK
28822839
|| (form_error = curl_mime_type(part, type ? type : "application/octet-stream")) != CURLE_OK) {
2883-
php_stream_close(stream);
28842840
error = form_error;
28852841
}
2886-
zend_llist_add_element(&ch->to_free->stream, &stream);
28872842
#else
28882843
form_error = curl_formadd(&first, &last,
28892844
CURLFORM_COPYNAME, ZSTR_VAL(string_key),
@@ -3613,7 +3568,6 @@ static void _php_curl_close_ex(php_curl *ch)
36133568
if (--(*ch->clone) == 0) {
36143569
zend_llist_clean(&ch->to_free->str);
36153570
zend_llist_clean(&ch->to_free->post);
3616-
zend_llist_clean(&ch->to_free->stream);
36173571
zend_hash_destroy(ch->to_free->slist);
36183572
efree(ch->to_free->slist);
36193573
efree(ch->to_free);

ext/curl/php_curl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ struct _php_curl_send_headers {
169169
struct _php_curl_free {
170170
zend_llist str;
171171
zend_llist post;
172-
zend_llist stream;
173172
HashTable *slist;
174173
};
175174

ext/curl/tests/bug77711.phpt

Lines changed: 0 additions & 32 deletions
This file was deleted.

ext/curl/tests/curl_copy_handle_variation3.phpt

Lines changed: 0 additions & 38 deletions
This file was deleted.

ext/curl/tests/curl_file_upload_stream.phpt

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)