Skip to content

Commit c34b523

Browse files
committed
sync PHP-8.1, PHP-8.2,PHP-8.3 curl
1 parent 5306476 commit c34b523

File tree

9 files changed

+1249
-934
lines changed

9 files changed

+1249
-934
lines changed

ext-src/swoole_curl_interface.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,8 @@ PHP_FUNCTION(swoole_native_curl_multi_setopt);
5252
PHP_FUNCTION(swoole_native_curl_multi_getcontent);
5353
PHP_FUNCTION(swoole_native_curl_multi_info_read);
5454
PHP_FUNCTION(swoole_native_curl_multi_init);
55-
56-
#if PHP_VERSION_ID >= 80400
55+
#if LIBCURL_VERSION_NUM >= 0x073E00 && PHP_VERSION_ID >= 80200
5756
PHP_FUNCTION(swoole_native_curl_upkeep);
58-
PHP_FUNCTION(swoole_native_curl_version);
59-
PHP_FUNCTION(swoole_native_curl_strerror);
60-
PHP_FUNCTION(swoole_native_curl_multi_strerror);
6157
#endif
6258

6359
SW_EXTERN_C_END

thirdparty/php/curl/curl_arginfo.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_swoole_native_curl_init, 0,
4747
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, url, IS_STRING, 1, "null")
4848
ZEND_END_ARG_INFO()
4949

50+
#if LIBCURL_VERSION_NUM >= 0x073E00 && PHP_VERSION_ID >= 80200 /* Available since 7.62.0 */
51+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_swoole_native_curl_upkeep, 0, 1, _IS_BOOL, 0)
52+
ZEND_ARG_OBJ_INFO(0, handle, CurlHandle, 0)
53+
ZEND_END_ARG_INFO()
54+
#endif
55+
5056
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_swoole_native_curl_multi_add_handle, 0, 2, IS_LONG, 0)
5157
ZEND_ARG_OBJ_INFO(0, multi_handle, CurlMultiHandle, 0)
5258
ZEND_ARG_OBJ_INFO(0, handle, CurlHandle, 0)
@@ -116,6 +122,9 @@ static const zend_function_entry swoole_native_curl_functions[] = {
116122
PHP_FE(swoole_native_curl_exec, arginfo_swoole_native_curl_exec)
117123
PHP_FE(swoole_native_curl_getinfo, arginfo_swoole_native_curl_getinfo)
118124
PHP_FE(swoole_native_curl_init, arginfo_swoole_native_curl_init)
125+
#if LIBCURL_VERSION_NUM >= 0x073E00 && PHP_VERSION_ID >= 80200
126+
PHP_FE(swoole_native_curl_upkeep, arginfo_swoole_native_curl_upkeep)
127+
#endif
119128
PHP_FE(swoole_native_curl_setopt, arginfo_swoole_native_curl_setopt)
120129
PHP_FE(swoole_native_curl_setopt_array, arginfo_swoole_native_curl_setopt_array)
121130
PHP_FE(swoole_native_curl_reset, arginfo_swoole_native_curl_reset)
@@ -132,7 +141,6 @@ static const zend_function_entry swoole_native_curl_functions[] = {
132141
PHP_FE(swoole_native_curl_multi_info_read, arginfo_swoole_native_curl_multi_info_read)
133142
PHP_FE(swoole_native_curl_multi_init, arginfo_swoole_native_curl_multi_init)
134143
PHP_FE(swoole_native_curl_multi_remove_handle, arginfo_swoole_native_curl_multi_remove_handle)
135-
136144
PHP_FE_END
137145
};
138146
#endif

thirdparty/php/curl/curl_private.h

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
| This source file is subject to version 3.01 of the PHP license, |
66
| that is bundled with this package in the file LICENSE, and is |
77
| available through the world-wide-web at the following url: |
8-
| http://www.php.net/license/3_01.txt |
8+
| https://www.php.net/license/3_01.txt |
99
| If you did not receive a copy of the PHP license and are unable to |
1010
| obtain it through the world-wide-web, please send a note to |
1111
| license@php.net so we can mail you a copy immediately. |
@@ -15,8 +15,6 @@
1515
+----------------------------------------------------------------------+
1616
*/
1717

18-
/* Copied from PHP-4f68662f5b61aecf90f6d8005976f5f91d4ce8d3 */
19-
2018
#if defined(SW_USE_CURL) && PHP_VERSION_ID < 80400
2119

2220
#ifndef _PHP_CURL_PRIVATE_H
@@ -67,21 +65,20 @@ typedef struct {
6765
typedef struct {
6866
zval func_name;
6967
zend_fcall_info_cache fci_cache;
70-
int method;
71-
} php_curl_progress, php_curl_fnmatch, php_curlm_server_push, php_curl_fnxferinfo, php_curl_sshhostkey;
68+
} php_curl_callback;
7269

7370
typedef struct {
7471
php_curl_write *write;
7572
php_curl_write *write_header;
7673
php_curl_read *read;
7774
zval std_err;
78-
php_curl_progress *progress;
79-
#if LIBCURL_VERSION_NUM >= 0x072000 && PHP_VERSION_ID >= 80200
80-
php_curl_fnxferinfo *xferinfo;
75+
php_curl_callback *progress;
76+
#if PHP_VERSION_ID >= 80200
77+
php_curl_callback *xferinfo;
8178
#endif
82-
php_curl_fnmatch *fnmatch;
79+
php_curl_callback *fnmatch;
8380
#if LIBCURL_VERSION_NUM >= 0x075400 && PHP_VERSION_ID >= 80300
84-
php_curl_sshhostkey *sshhostkey;
81+
php_curl_callback *sshhostkey;
8582
#endif
8683
} php_curl_handlers;
8784

@@ -94,30 +91,22 @@ struct _php_curl_send_headers {
9491
zend_string *str;
9592
};
9693

97-
#if PHP_VERSION_ID >= 80100
98-
struct _php_curl_free {
99-
zend_llist post;
100-
zend_llist stream;
101-
HashTable *slist;
102-
};
103-
#else
10494
struct _php_curl_free {
105-
zend_llist str;
10695
zend_llist post;
10796
zend_llist stream;
10897
HashTable *slist;
10998
};
110-
#endif
11199

112100
typedef struct {
113101
CURL *cp;
114102
php_curl_handlers handlers;
115103
struct _php_curl_free *to_free;
116104
struct _php_curl_send_headers header;
117105
struct _php_curl_error err;
118-
zend_bool in_callback;
106+
bool in_callback;
119107
uint32_t *clone;
120108
zval postfields;
109+
/* For CURLOPT_PRIVATE */
121110
zval private_data;
122111
/* CurlShareHandle object set using CURLOPT_SHARE. */
123112
struct _php_curlsh *share;
@@ -127,7 +116,7 @@ typedef struct {
127116
#define CURLOPT_SAFE_UPLOAD -1
128117

129118
typedef struct {
130-
php_curlm_server_push *server_push;
119+
php_curl_callback *server_push;
131120
} php_curlm_handlers;
132121

133122
namespace swoole {
@@ -160,23 +149,16 @@ php_curl *swoole_curl_init_handle_into_zval(zval *curl);
160149
void swoole_curl_init_handle(php_curl *ch);
161150
void swoole_curl_cleanup_handle(php_curl *);
162151
void swoole_curl_multi_cleanup_list(void *data);
163-
void swoole_curl_verify_handlers(php_curl *ch, int reporterror);
152+
void swoole_curl_verify_handlers(php_curl *ch, bool reporterror);
164153
void swoole_setup_easy_copy_handlers(php_curl *ch, php_curl *source);
165154

166-
#if PHP_VERSION_ID >= 80100
167155
static inline php_curl_handlers *curl_handlers(php_curl *ch) {
168156
return &ch->handlers;
169157
}
170-
#else
171-
static inline php_curl_handlers *curl_handlers(php_curl *ch) {
172-
return ch->handlers;
173-
}
174-
#endif
175158

176-
#if PHP_VERSION_ID >= 80200
177-
typedef zend_result curl_result_t;
178-
#else
179-
typedef int curl_result_t;
159+
#if PHP_VERSION_ID >= 80300
160+
/* Consumes `zv` */
161+
zend_long php_curl_get_long(zval *zv);
180162
#endif
181163

182164
static inline php_curl *curl_from_obj(zend_object *obj) {
@@ -191,7 +173,12 @@ static inline php_curlsh *curl_share_from_obj(zend_object *obj) {
191173

192174
#define Z_CURL_SHARE_P(zv) curl_share_from_obj(Z_OBJ_P(zv))
193175
void curl_multi_register_class(const zend_function_entry *method_entries);
194-
curl_result_t swoole_curl_cast_object(zend_object *obj, zval *result, int type);
176+
177+
#if PHP_VERSION_ID >= 80200
178+
zend_result swoole_curl_cast_object(zend_object *obj, zval *result, int type);
179+
#else
180+
int swoole_curl_cast_object(zend_object *obj, zval *result, int type);
181+
#endif
195182

196183
#endif /* _PHP_CURL_PRIVATE_H */
197184
#endif

0 commit comments

Comments
 (0)