summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-01-06 15:19:34 +0100
committerChristoph M. Becker <cmbecker69@gmx.de>2020-01-06 15:31:49 +0100
commit06e78cad8353d0ff2b8b76fbf93fbc4860debf56 (patch)
treeb72b2dcc5426031a46ff91b68dd5b22c0896f740
parentae2150692a9a2e0878314385d03826f160e6a76a (diff)
downloadphp-git-06e78cad8353d0ff2b8b76fbf93fbc4860debf56.tar.gz
Revert "Extend CURLFile to support streams"
This reverts commit 17a9f1401aeb35fe1e3657b38102a410d151d42f, because this commit would break ABI, and also due to bug #79013. We keep the commit for PHP 7.4+, though.
-rw-r--r--NEWS1
-rw-r--r--ext/curl/interface.c48
-rw-r--r--ext/curl/php_curl.h1
-rw-r--r--ext/curl/tests/bug77711.phpt32
-rw-r--r--ext/curl/tests/curl_copy_handle_variation3.phpt38
-rw-r--r--ext/curl/tests/curl_file_upload_stream.phpt28
6 files changed, 1 insertions, 147 deletions
diff --git a/NEWS b/NEWS
index acecfa4037..1f0544934c 100644
--- a/NEWS
+++ b/NEWS
@@ -7,7 +7,6 @@ PHP NEWS
(Dmitry)
- CURL:
- . Implemented FR #77711 (CURLFile should support UNICODE filenames). (cmb)
. Fixed bug #79033 (Curl timeout error with specific url and post). (cmb)
- Date:
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index 0772b3a522..c45763a967 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -1852,14 +1852,6 @@ static void curl_free_post(void **post)
}
/* }}} */
-/* {{{ curl_free_stream
- */
-static void curl_free_stream(void **post)
-{
- php_stream_close((php_stream *)*post);
-}
-/* }}} */
-
/* {{{ curl_free_slist
*/
static void curl_free_slist(zval *el)
@@ -1951,7 +1943,6 @@ php_curl *alloc_curl_handle()
zend_llist_init(&ch->to_free->str, sizeof(char *), (llist_dtor_func_t)curl_free_string, 0);
zend_llist_init(&ch->to_free->post, sizeof(struct HttpPost *), (llist_dtor_func_t)curl_free_post, 0);
- zend_llist_init(&ch->to_free->stream, sizeof(php_stream *), (llist_dtor_func_t)curl_free_stream, 0);
ch->to_free->slist = emalloc(sizeof(HashTable));
zend_hash_init(ch->to_free->slist, 4, NULL, curl_free_slist, 0);
@@ -2179,32 +2170,6 @@ PHP_FUNCTION(curl_copy_handle)
}
/* }}} */
-#if LIBCURL_VERSION_NUM >= 0x073800
-static size_t read_cb(char *buffer, size_t size, size_t nitems, void *arg) /* {{{ */
-{
- php_stream *stream = (php_stream *) arg;
- size_t numread = php_stream_read(stream, buffer, nitems * size);
-
- if (numread == (size_t)-1) {
- return CURL_READFUNC_ABORT;
- }
- return numread;
-}
-/* }}} */
-
-static int seek_cb(void *arg, curl_off_t offset, int origin) /* {{{ */
-{
- php_stream *stream = (php_stream *) arg;
- int res = php_stream_seek(stream, offset, origin);
-
- if (res) {
- return CURL_SEEKFUNC_CANTSEEK;
- }
- return CURL_SEEKFUNC_OK;
-}
-/* }}} */
-#endif
-
static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{ */
{
CURLcode error = CURLE_OK;
@@ -2842,9 +2807,6 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
/* new-style file upload */
zval *prop, rv;
char *type = NULL, *filename = NULL;
-#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
- php_stream *stream;
-#endif
prop = zend_read_property(curl_CURLFile_class, current, "name", sizeof("name")-1, 0, &rv);
if (Z_TYPE_P(prop) != IS_STRING) {
@@ -2866,24 +2828,17 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
}
#if LIBCURL_VERSION_NUM >= 0x073800 /* 7.56.0 */
- if (!(stream = php_stream_open_wrapper(ZSTR_VAL(postval), "rb", IGNORE_PATH, NULL))) {
- zend_string_release_ex(string_key, 0);
- return FAILURE;
- }
part = curl_mime_addpart(mime);
if (part == NULL) {
- php_stream_close(stream);
zend_string_release_ex(string_key, 0);
return FAILURE;
}
if ((form_error = curl_mime_name(part, ZSTR_VAL(string_key))) != CURLE_OK
- || (form_error = curl_mime_data_cb(part, -1, read_cb, seek_cb, NULL, stream)) != CURLE_OK
+ || (form_error = curl_mime_filedata(part, ZSTR_VAL(postval))) != CURLE_OK
|| (form_error = curl_mime_filename(part, filename ? filename : ZSTR_VAL(postval))) != CURLE_OK
|| (form_error = curl_mime_type(part, type ? type : "application/octet-stream")) != CURLE_OK) {
- php_stream_close(stream);
error = form_error;
}
- zend_llist_add_element(&ch->to_free->stream, &stream);
#else
form_error = curl_formadd(&first, &last,
CURLFORM_COPYNAME, ZSTR_VAL(string_key),
@@ -3613,7 +3568,6 @@ static void _php_curl_close_ex(php_curl *ch)
if (--(*ch->clone) == 0) {
zend_llist_clean(&ch->to_free->str);
zend_llist_clean(&ch->to_free->post);
- zend_llist_clean(&ch->to_free->stream);
zend_hash_destroy(ch->to_free->slist);
efree(ch->to_free->slist);
efree(ch->to_free);
diff --git a/ext/curl/php_curl.h b/ext/curl/php_curl.h
index 24803e1ccf..0a0da5aa02 100644
--- a/ext/curl/php_curl.h
+++ b/ext/curl/php_curl.h
@@ -169,7 +169,6 @@ struct _php_curl_send_headers {
struct _php_curl_free {
zend_llist str;
zend_llist post;
- zend_llist stream;
HashTable *slist;
};
diff --git a/ext/curl/tests/bug77711.phpt b/ext/curl/tests/bug77711.phpt
deleted file mode 100644
index 148c26322a..0000000000
--- a/ext/curl/tests/bug77711.phpt
+++ /dev/null
@@ -1,32 +0,0 @@
---TEST--
-FR #77711 (CURLFile should support UNICODE filenames)
---SKIPIF--
-<?php include 'skipif.inc'; ?>
---FILE--
-<?php
-include 'server.inc';
-$host = curl_cli_server_start();
-
-$ch = curl_init();
-curl_setopt($ch, CURLOPT_SAFE_UPLOAD, 1);
-curl_setopt($ch, CURLOPT_URL, "{$host}/get.php?test=file");
-curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
-
-$filename = __DIR__ . '/АБВ.txt';
-file_put_contents($filename, "Test.");
-$file = curl_file_create($filename);
-$params = array('file' => $file);
-var_dump(curl_setopt($ch, CURLOPT_POSTFIELDS, $params));
-
-var_dump(curl_exec($ch));
-curl_close($ch);
-?>
-===DONE===
---EXPECTF--
-bool(true)
-string(%d) "АБВ.txt|application/octet-stream"
-===DONE===
---CLEAN--
-<?php
-@unlink(__DIR__ . '/АБВ.txt');
-?>
diff --git a/ext/curl/tests/curl_copy_handle_variation3.phpt b/ext/curl/tests/curl_copy_handle_variation3.phpt
deleted file mode 100644
index 18f35f71b1..0000000000
--- a/ext/curl/tests/curl_copy_handle_variation3.phpt
+++ /dev/null
@@ -1,38 +0,0 @@
---TEST--
-curl_copy_handle() allows to post CURLFile multiple times
---SKIPIF--
-<?php include 'skipif.inc'; ?>
---FILE--
-<?php
-include 'server.inc';
-$host = curl_cli_server_start();
-
-$ch1 = curl_init();
-curl_setopt($ch1, CURLOPT_SAFE_UPLOAD, 1);
-curl_setopt($ch1, CURLOPT_URL, "{$host}/get.php?test=file");
-curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
-
-$filename = __DIR__ . '/АБВ.txt';
-file_put_contents($filename, "Test.");
-$file = curl_file_create($filename);
-$params = array('file' => $file);
-var_dump(curl_setopt($ch1, CURLOPT_POSTFIELDS, $params));
-
-$ch2 = curl_copy_handle($ch1);
-
-var_dump(curl_exec($ch1));
-curl_close($ch1);
-
-var_dump(curl_exec($ch2));
-curl_close($ch2);
-?>
-===DONE===
---EXPECTF--
-bool(true)
-string(%d) "АБВ.txt|application/octet-stream"
-string(%d) "АБВ.txt|application/octet-stream"
-===DONE===
---CLEAN--
-<?php
-@unlink(__DIR__ . '/АБВ.txt');
-?>
diff --git a/ext/curl/tests/curl_file_upload_stream.phpt b/ext/curl/tests/curl_file_upload_stream.phpt
deleted file mode 100644
index 03c85b4b82..0000000000
--- a/ext/curl/tests/curl_file_upload_stream.phpt
+++ /dev/null
@@ -1,28 +0,0 @@
---TEST--
-CURL file uploading from stream
---SKIPIF--
-<?php include 'skipif.inc'; ?>
-<?php
-if (curl_version()['version_number'] < 0x73800) die('skip requires curl >= 7.56.0');
---FILE--
-<?php
-include 'server.inc';
-$host = curl_cli_server_start();
-
-$ch = curl_init();
-curl_setopt($ch, CURLOPT_SAFE_UPLOAD, 1);
-curl_setopt($ch, CURLOPT_URL, "{$host}/get.inc?test=file");
-curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
-
-$file = curl_file_create('data://text/plain;base64,SSBsb3ZlIFBIUAo=', 'text/plain', 'i-love-php');
-$params = array('file' => $file);
-var_dump(curl_setopt($ch, CURLOPT_POSTFIELDS, $params));
-
-var_dump(curl_exec($ch));
-curl_close($ch);
-?>
-===DONE===
---EXPECT--
-bool(true)
-string(21) "i-love-php|text/plain"
-===DONE===