From 8cfb36920a0d73d833b9e653d49daacf56b3eeb5 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 4 Aug 2021 16:18:11 +0200 Subject: add fix for 8.1.0beta2 from upstream and from https://github.com/m6w6/ext-http/pull/118 --- pecl_http-php81.patch | 846 ++++++++++++++++++++++++++++++++++++++++++++++++++ php-pecl-http.spec | 11 +- 2 files changed, 856 insertions(+), 1 deletion(-) create mode 100644 pecl_http-php81.patch diff --git a/pecl_http-php81.patch b/pecl_http-php81.patch new file mode 100644 index 0000000..a651733 --- /dev/null +++ b/pecl_http-php81.patch @@ -0,0 +1,846 @@ +From a4f66fb42bb5203e9d1897a6cf554aa702ce0380 Mon Sep 17 00:00:00 2001 +From: Thomas Deutschmann +Date: Tue, 18 May 2021 19:55:47 +0200 +Subject: [PATCH 01/11] tests: use getenv() to access environment variable + +Fixes + + Warning: Undefined array key "PATH" in pecl-http-4.1.0/work/php8.0/tests/skipif.inc on line 56 +--- + tests/skipif.inc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/skipif.inc b/tests/skipif.inc +index 51272fb..76c3bd7 100644 +--- a/tests/skipif.inc ++++ b/tests/skipif.inc +@@ -53,7 +53,7 @@ function skip_http2_test($message = "skip need http2 support") { + if (!(http\Client\Curl\FEATURES & http\Client\Curl\Features\HTTP2)) { + die("$message (FEATURES & HTTP2)\n"); + } +- foreach (explode(":", $_ENV["PATH"]) as $path) { ++ foreach (explode(":", getenv("PATH")) as $path) { + if (is_executable($path . "/nghttpd")) { + return; + } +-- +2.31.1 + +From b63ba83de3d26c61062b72a8d5675225297302db Mon Sep 17 00:00:00 2001 +From: Michael Wallner +Date: Mon, 2 Aug 2021 16:15:09 +0200 +Subject: [PATCH 02/11] PHP-8.1 compat + +--- + src/php_http_client.c | 2 +- + src/php_http_header.c | 39 ++++++++++++++++- + src/php_http_message.c | 85 ++++++++++++++++++++++++++++++------- + src/php_http_message_body.c | 46 ++++++++++++++++++++ + src/php_http_params.c | 8 ++-- + src/php_http_querystring.c | 43 +++++++++++++++---- + 6 files changed, 193 insertions(+), 30 deletions(-) + +diff --git a/src/php_http_client.c b/src/php_http_client.c +index 4e1ed37..f1ef55d 100644 +--- a/src/php_http_client.c ++++ b/src/php_http_client.c +@@ -804,7 +804,7 @@ static PHP_METHOD(HttpClient, requeue) + RETVAL_ZVAL(getThis(), 1, 0); + } + +-ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_count, 0, 0, 0) ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpClient_count, 0, 0, IS_LONG, 0) + ZEND_END_ARG_INFO(); + static PHP_METHOD(HttpClient, count) + { +diff --git a/src/php_http_header.c b/src/php_http_header.c +index 76b2f68..c9b1e0d 100644 +--- a/src/php_http_header.c ++++ b/src/php_http_header.c +@@ -191,6 +191,41 @@ PHP_METHOD(HttpHeader, __construct) + } + } + ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpHeader___serialize, 0, 0, IS_ARRAY, 0) ++ZEND_END_ARG_INFO(); ++PHP_METHOD(HttpHeader, __serialize) ++{ ++ zval name, value, *ptr; ++ ++ zend_parse_parameters_none(); ++ ++ array_init(return_value); ++ ptr = zend_read_property(php_http_header_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("name"), 0, &name); ++ Z_TRY_ADDREF_P(ptr); ++ add_next_index_zval(return_value, ptr); ++ ptr = zend_read_property(php_http_header_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("value"), 0, &value); ++ Z_TRY_ADDREF_P(ptr); ++ add_next_index_zval(return_value, ptr); ++} ++ ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpHeader___unserialize, 0, 1, IS_VOID, 0) ++ ZEND_ARG_TYPE_INFO(0, data, IS_ARRAY, 0) ++ZEND_END_ARG_INFO(); ++PHP_METHOD(HttpHeader, __unserialize) ++{ ++ HashTable *ha; ++ zval *name, *value; ++ ++ php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "h", &ha), invalid_arg, return); ++ name = zend_hash_index_find(ha, 0); ++ value = zend_hash_index_find(ha, 1); ++ ++ if (name && value) { ++ zend_update_property(php_http_header_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("name"), name); ++ zend_update_property(php_http_header_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("value"), value); ++ } ++} ++ + ZEND_BEGIN_ARG_INFO_EX(ai_HttpHeader_serialize, 0, 0, 0) + ZEND_END_ARG_INFO(); + PHP_METHOD(HttpHeader, serialize) +@@ -399,10 +434,12 @@ PHP_METHOD(HttpHeader, parse) + + static zend_function_entry php_http_header_methods[] = { + PHP_ME(HttpHeader, __construct, ai_HttpHeader___construct, ZEND_ACC_PUBLIC) ++ PHP_ME(HttpHeader, __unserialize, ai_HttpHeader___unserialize, ZEND_ACC_PUBLIC) ++ PHP_ME(HttpHeader, __serialize, ai_HttpHeader___serialize, ZEND_ACC_PUBLIC) ++ PHP_ME(HttpHeader, unserialize, ai_HttpHeader_unserialize, ZEND_ACC_PUBLIC) + PHP_ME(HttpHeader, serialize, ai_HttpHeader_serialize, ZEND_ACC_PUBLIC) + ZEND_MALIAS(HttpHeader, __toString, serialize, ai_HttpHeader_serialize, ZEND_ACC_PUBLIC) + ZEND_MALIAS(HttpHeader, toString, serialize, ai_HttpHeader_serialize, ZEND_ACC_PUBLIC) +- PHP_ME(HttpHeader, unserialize, ai_HttpHeader_unserialize, ZEND_ACC_PUBLIC) + PHP_ME(HttpHeader, match, ai_HttpHeader_match, ZEND_ACC_PUBLIC) + PHP_ME(HttpHeader, negotiate, ai_HttpHeader_negotiate, ZEND_ACC_PUBLIC) + PHP_ME(HttpHeader, getParams, ai_HttpHeader_getParams, ZEND_ACC_PUBLIC) +diff --git a/src/php_http_message.c b/src/php_http_message.c +index 1b8ecd2..d09b0b4 100644 +--- a/src/php_http_message.c ++++ b/src/php_http_message.c +@@ -647,15 +647,15 @@ static void php_http_message_object_prophandler_set_headers(php_http_message_obj + } + } + static void php_http_message_object_prophandler_get_body(php_http_message_object_t *obj, zval *return_value) { +- if (obj->body) { +- zval tmp; ++ zval tmp; + +- ZVAL_COPY_VALUE(&tmp, return_value); +- RETVAL_OBJECT(&obj->body->zo, 1); +- zval_ptr_dtor(&tmp); +- } else { +- RETVAL_NULL(); ++ if (!obj->body) { ++ RETURN_NULL(); + } ++ ++ ZVAL_COPY_VALUE(&tmp, return_value); ++ RETVAL_OBJECT(&obj->body->zo, 1); ++ zval_ptr_dtor(&tmp); + } + static void php_http_message_object_prophandler_set_body(php_http_message_object_t *obj, zval *value) { + php_http_message_object_set_body(obj, value); +@@ -931,14 +931,16 @@ static zval *php_http_message_object_write_prop(zend_object *object, zend_string + + static HashTable *php_http_message_object_get_debug_info(zend_object *object, int *is_temp) + { +- zval tmp; + php_http_message_object_t *obj = PHP_HTTP_OBJ(object, NULL); + HashTable *props = zend_get_std_object_handlers()->get_properties(object); + char *ver_str, *url_str = NULL; + size_t ver_len, url_len = 0; ++ zval tmp; + + PHP_HTTP_MESSAGE_OBJECT_INIT(obj); +- *is_temp = 0; ++ if (is_temp) { ++ *is_temp = 0; ++ } + + #define UPDATE_PROP(name_str, action_with_tmp) \ + do { \ +@@ -1762,6 +1764,57 @@ static PHP_METHOD(HttpMessage, toCallback) + } + } + ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpMessage___serialize, 0, 0, IS_ARRAY, 0) ++ZEND_END_ARG_INFO(); ++static PHP_METHOD(HttpMessage, __serialize) ++{ ++ zend_ulong num_index; ++ zend_string *str_index; ++ zend_property_info *pi; ++ php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis()); ++ HashTable *props = php_http_message_object_get_debug_info(&obj->zo, NULL); ++ ++ zend_parse_parameters_none(); ++ ++ array_init(return_value); ++ ++ ZEND_HASH_FOREACH_KEY_PTR(&obj->zo.ce->properties_info, num_index, str_index, pi) ++ { ++ zval *val; ++ if (str_index && (val = zend_hash_find_ind(props, pi->name))) { ++ Z_TRY_ADDREF_P(val); ++ zend_hash_update(Z_ARRVAL_P(return_value), str_index, val); ++ } ++ } ++ ZEND_HASH_FOREACH_END(); ++} ++ ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpMessage___unserialize, 0, 1, IS_VOID, 0) ++ ZEND_ARG_TYPE_INFO(0, data, IS_ARRAY, 0) ++ZEND_END_ARG_INFO(); ++static PHP_METHOD(HttpMessage, __unserialize) ++{ ++ HashTable *arr; ++ zend_string *key; ++ zval *val; ++ php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis()); ++ ++ php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "h", &arr), invalid_arg, return); ++ ++ PHP_HTTP_MESSAGE_OBJECT_INIT(obj); ++ ++ ZEND_HASH_FOREACH_STR_KEY_VAL(arr, key, val) ++ { ++ php_http_message_object_prophandler_t *ph = php_http_message_object_get_prophandler(key); ++ if (ph) { ++ ph->write(obj, val); ++ } else { ++ zend_update_property_ex(php_http_message_class_entry, &obj->zo, key, val); ++ } ++ } ++ ZEND_HASH_FOREACH_END(); ++} ++ + ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_serialize, 0, 0, 0) + ZEND_END_ARG_INFO(); + static PHP_METHOD(HttpMessage, serialize) +@@ -1916,7 +1969,7 @@ static PHP_METHOD(HttpMessage, splitMultipartBody) + RETURN_OBJ(&php_http_message_object_new_ex(obj->zo.ce, msg)->zo); + } + +-ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_count, 0, 0, 0) ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpMessage_count, 0, 0, IS_LONG, 0) + ZEND_END_ARG_INFO(); + static PHP_METHOD(HttpMessage, count) + { +@@ -1931,7 +1984,7 @@ static PHP_METHOD(HttpMessage, count) + } + } + +-ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_rewind, 0, 0, 0) ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpMessage_rewind, 0, 0, IS_VOID, 0) + ZEND_END_ARG_INFO(); + static PHP_METHOD(HttpMessage, rewind) + { +@@ -1946,7 +1999,7 @@ static PHP_METHOD(HttpMessage, rewind) + } + } + +-ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_valid, 0, 0, 0) ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpMessage_valid, 0, 0, _IS_BOOL, 0) + ZEND_END_ARG_INFO(); + static PHP_METHOD(HttpMessage, valid) + { +@@ -1957,7 +2010,7 @@ static PHP_METHOD(HttpMessage, valid) + } + } + +-ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_next, 0, 0, 0) ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpMessage_next, 0, 0, IS_VOID, 0) + ZEND_END_ARG_INFO(); + static PHP_METHOD(HttpMessage, next) + { +@@ -1981,7 +2034,7 @@ static PHP_METHOD(HttpMessage, next) + } + } + +-ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_key, 0, 0, 0) ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpMessage_key, 0, 0, IS_LONG, 0) + ZEND_END_ARG_INFO(); + static PHP_METHOD(HttpMessage, key) + { +@@ -1992,7 +2045,7 @@ static PHP_METHOD(HttpMessage, key) + } + } + +-ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessage_current, 0, 0, 0) ++ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(ai_HttpMessage_current, 0, 0, http\\Message, 0) + ZEND_END_ARG_INFO(); + static PHP_METHOD(HttpMessage, current) + { +@@ -2041,6 +2094,8 @@ static zend_function_entry php_http_message_methods[] = { + /* implements Serializable */ + PHP_ME(HttpMessage, serialize, ai_HttpMessage_serialize, ZEND_ACC_PUBLIC) + PHP_ME(HttpMessage, unserialize, ai_HttpMessage_unserialize, ZEND_ACC_PUBLIC) ++ PHP_ME(HttpMessage, __serialize, ai_HttpMessage___serialize, ZEND_ACC_PUBLIC) ++ PHP_ME(HttpMessage, __unserialize, ai_HttpMessage___unserialize, ZEND_ACC_PUBLIC) + + /* implements Iterator */ + PHP_ME(HttpMessage, rewind, ai_HttpMessage_rewind, ZEND_ACC_PUBLIC) +diff --git a/src/php_http_message_body.c b/src/php_http_message_body.c +index 70fd587..72cfa4a 100644 +--- a/src/php_http_message_body.c ++++ b/src/php_http_message_body.c +@@ -704,6 +704,50 @@ PHP_METHOD(HttpMessageBody, unserialize) + } + } + ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpMessageBody___unserialize, 0, 1, IS_VOID, 0) ++ ZEND_ARG_TYPE_INFO(0, data, IS_ARRAY, 0) ++ZEND_END_ARG_INFO(); ++PHP_METHOD(HttpMessageBody, __unserialize) ++{ ++ HashTable *arr; ++ ++ if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "h", &arr)) { ++ zval *zv = zend_hash_index_find(arr, 0); ++ ++ if (0 && zv) { ++ zend_string *zs = zval_get_string(zv); ++ php_stream *s = php_http_mem_stream_open(0, zs); ++ php_http_message_body_object_t *obj = PHP_HTTP_OBJ(NULL, getThis()); ++ ++ obj->body = php_http_message_body_init(NULL, s); ++ php_stream_to_zval(s, obj->gc); ++ zend_string_release(zs); ++ } ++ } ++} ++ ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpMessageBody___serialize, 0, 0, IS_ARRAY, 0) ++ZEND_END_ARG_INFO(); ++PHP_METHOD(HttpMessageBody, __serialize) ++{ ++ ++ php_http_message_body_object_t *obj = PHP_HTTP_OBJ(NULL, getThis()); ++ zend_string *zs; ++ ++ zend_parse_parameters_none(); ++ ++ PHP_HTTP_MESSAGE_BODY_OBJECT_INIT(obj); ++ ++ array_init(return_value); ++ zs = php_http_message_body_to_string(obj->body, 0, 0); ++ if (zs) { ++ add_index_str(return_value, 0, zs); ++ zend_string_release(zs); ++ } ++} ++ ++ ++ + ZEND_BEGIN_ARG_INFO_EX(ai_HttpMessageBody_toStream, 0, 0, 1) + ZEND_ARG_INFO(0, stream) + ZEND_ARG_INFO(0, offset) +@@ -914,6 +958,8 @@ static zend_function_entry php_http_message_body_methods[] = { + PHP_MALIAS(HttpMessageBody, toString, __toString, ai_HttpMessageBody___toString, ZEND_ACC_PUBLIC) + PHP_MALIAS(HttpMessageBody, serialize, __toString, ai_HttpMessageBody___toString, ZEND_ACC_PUBLIC) + PHP_ME(HttpMessageBody, unserialize, ai_HttpMessageBody_unserialize, ZEND_ACC_PUBLIC) ++ PHP_ME(HttpMessageBody, __serialize, ai_HttpMessageBody___serialize, ZEND_ACC_PUBLIC) ++ PHP_ME(HttpMessageBody, __unserialize,ai_HttpMessageBody___unserialize,ZEND_ACC_PUBLIC) + PHP_ME(HttpMessageBody, toStream, ai_HttpMessageBody_toStream, ZEND_ACC_PUBLIC) + PHP_ME(HttpMessageBody, toCallback, ai_HttpMessageBody_toCallback, ZEND_ACC_PUBLIC) + PHP_ME(HttpMessageBody, getResource, ai_HttpMessageBody_getResource, ZEND_ACC_PUBLIC) +diff --git a/src/php_http_params.c b/src/php_http_params.c +index 8ac4f8f..4a523cc 100644 +--- a/src/php_http_params.c ++++ b/src/php_http_params.c +@@ -1181,7 +1181,7 @@ PHP_METHOD(HttpParams, toString) + RETVAL_STR(php_http_cs2zs(buf.data, buf.used)); + } + +-ZEND_BEGIN_ARG_INFO_EX(ai_HttpParams_offsetExists, 0, 0, 1) ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpParams_offsetExists, 0, 1, _IS_BOOL, 0) + ZEND_ARG_INFO(0, name) + ZEND_END_ARG_INFO(); + PHP_METHOD(HttpParams, offsetExists) +@@ -1202,7 +1202,7 @@ PHP_METHOD(HttpParams, offsetExists) + } + } + +-ZEND_BEGIN_ARG_INFO_EX(ai_HttpParams_offsetGet, 0, 0, 1) ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpParams_offsetGet, 0, 1, IS_MIXED, 1) + ZEND_ARG_INFO(0, name) + ZEND_END_ARG_INFO(); + PHP_METHOD(HttpParams, offsetGet) +@@ -1221,7 +1221,7 @@ PHP_METHOD(HttpParams, offsetGet) + } + } + +-ZEND_BEGIN_ARG_INFO_EX(ai_HttpParams_offsetUnset, 0, 0, 1) ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpParams_offsetUnset, 0, 1, IS_VOID, 0) + ZEND_ARG_INFO(0, name) + ZEND_END_ARG_INFO(); + PHP_METHOD(HttpParams, offsetUnset) +@@ -1240,7 +1240,7 @@ PHP_METHOD(HttpParams, offsetUnset) + } + } + +-ZEND_BEGIN_ARG_INFO_EX(ai_HttpParams_offsetSet, 0, 0, 2) ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpParams_offsetSet, 0, 2, IS_VOID, 0) + ZEND_ARG_INFO(0, name) + ZEND_ARG_INFO(0, value) + ZEND_END_ARG_INFO(); +diff --git a/src/php_http_querystring.c b/src/php_http_querystring.c +index f2d73a4..541937e 100644 +--- a/src/php_http_querystring.c ++++ b/src/php_http_querystring.c +@@ -395,7 +395,7 @@ PHP_METHOD(HttpQueryString, getGlobalInstance) + + } + +-ZEND_BEGIN_ARG_INFO_EX(ai_HttpQueryString_getIterator, 0, 0, 0) ++ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(ai_HttpQueryString_getIterator, 0, 0, Traversable, 0) + ZEND_END_ARG_INFO(); + PHP_METHOD(HttpQueryString, getIterator) + { +@@ -566,6 +566,29 @@ PHP_METHOD(HttpQueryString, xlate) + } + #endif /* HAVE_ICONV */ + ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpQueryString___serialize, 0, 0, IS_ARRAY, 0) ++ZEND_END_ARG_INFO(); ++PHP_METHOD(HttpQueryString, __serialize) ++{ ++ zval *zqa, zqa_tmp; ++ ++ zend_parse_parameters_none(); ++ ++ zqa = zend_read_property(php_http_querystring_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("queryArray"), 0, &zqa_tmp); ++ RETURN_ZVAL(zqa, 1, 0); ++} ++ ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpQueryString___unserialize, 0, 1, IS_VOID, 0) ++ ZEND_ARG_TYPE_INFO(0, data, IS_ARRAY, 0) ++ZEND_END_ARG_INFO(); ++PHP_METHOD(HttpQueryString, __unserialize) ++{ ++ zval *qa; ++ ++ php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "a", &qa), invalid_arg, return); ++ php_http_querystring_set(getThis(), qa, 0); ++} ++ + ZEND_BEGIN_ARG_INFO_EX(ai_HttpQueryString_serialize, 0, 0, 0) + ZEND_END_ARG_INFO(); + PHP_METHOD(HttpQueryString, serialize) +@@ -594,8 +617,8 @@ PHP_METHOD(HttpQueryString, unserialize) + } + } + +-ZEND_BEGIN_ARG_INFO_EX(ai_HttpQueryString_offsetGet, 0, 0, 1) +- ZEND_ARG_INFO(0, offset) ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpQueryString_offsetGet, 0, 1, IS_MIXED, 1) ++ ZEND_ARG_INFO(0, name) + ZEND_END_ARG_INFO(); + PHP_METHOD(HttpQueryString, offsetGet) + { +@@ -616,8 +639,8 @@ PHP_METHOD(HttpQueryString, offsetGet) + } + } + +-ZEND_BEGIN_ARG_INFO_EX(ai_HttpQueryString_offsetSet, 0, 0, 2) +- ZEND_ARG_INFO(0, offset) ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpQueryString_offsetSet, 0, 2, IS_VOID, 0) ++ ZEND_ARG_INFO(0, name) + ZEND_ARG_INFO(0, value) + ZEND_END_ARG_INFO(); + PHP_METHOD(HttpQueryString, offsetSet) +@@ -641,8 +664,8 @@ PHP_METHOD(HttpQueryString, offsetSet) + zval_ptr_dtor(¶m); + } + +-ZEND_BEGIN_ARG_INFO_EX(ai_HttpQueryString_offsetExists, 0, 0, 1) +- ZEND_ARG_INFO(0, offset) ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpQueryString_offsetExists, 0, 1, _IS_BOOL, 0) ++ ZEND_ARG_INFO(0, name) + ZEND_END_ARG_INFO(); + PHP_METHOD(HttpQueryString, offsetExists) + { +@@ -664,8 +687,8 @@ PHP_METHOD(HttpQueryString, offsetExists) + RETURN_FALSE; + } + +-ZEND_BEGIN_ARG_INFO_EX(ai_HttpQueryString_offsetUnset, 0, 0, 1) +- ZEND_ARG_INFO(0, offset) ++ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(ai_HttpQueryString_offsetUnset, 0, 1, IS_VOID, 0) ++ ZEND_ARG_INFO(0, name) + ZEND_END_ARG_INFO(); + PHP_METHOD(HttpQueryString, offsetUnset) + { +@@ -711,6 +734,8 @@ static zend_function_entry php_http_querystring_methods[] = { + /* Implements Serializable */ + PHP_ME(HttpQueryString, serialize, ai_HttpQueryString_serialize, ZEND_ACC_PUBLIC) + PHP_ME(HttpQueryString, unserialize, ai_HttpQueryString_unserialize, ZEND_ACC_PUBLIC) ++ PHP_ME(HttpQueryString, __serialize, ai_HttpQueryString___serialize, ZEND_ACC_PUBLIC) ++ PHP_ME(HttpQueryString, __unserialize, ai_HttpQueryString___unserialize, ZEND_ACC_PUBLIC) + + /* Implements ArrayAccess */ + PHP_ME(HttpQueryString, offsetGet, ai_HttpQueryString_offsetGet, ZEND_ACC_PUBLIC) +-- +2.31.1 + +From 22c2da5a45dfeefc3c32fbb5ff1b1129341a2001 Mon Sep 17 00:00:00 2001 +From: Michael Wallner +Date: Mon, 2 Aug 2021 16:42:23 +0200 +Subject: [PATCH 04/11] curl: ssl/falsestart: ignore rc + +--- + src/php_http_client_curl.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/src/php_http_client_curl.c b/src/php_http_client_curl.c +index 915b8fc..89ae5e0 100644 +--- a/src/php_http_client_curl.c ++++ b/src/php_http_client_curl.c +@@ -812,6 +812,7 @@ static php_http_options_t php_http_curle_options, php_http_curlm_options; + #define PHP_HTTP_CURLE_OPTION_CHECK_STRLEN 0x0001 + #define PHP_HTTP_CURLE_OPTION_CHECK_BASEDIR 0x0002 + #define PHP_HTTP_CURLE_OPTION_TRANSFORM_MS 0x0004 ++#define PHP_HTTP_CURLE_OPTION_IGNORE_RC 0x0008 + + static ZEND_RESULT_CODE php_http_curle_option_set_ssl_verifyhost(php_http_option_t *opt, zval *val, void *userdata) + { +@@ -1582,7 +1583,9 @@ static void php_http_curle_options_init(php_http_options_t *registry) + } + #endif + #if PHP_HTTP_CURL_VERSION(7,42,0) && (PHP_HTTP_HAVE_LIBCURL_NSS || PHP_HTTP_HAVE_LIBCURL_SECURETRANSPORT) +- php_http_option_register(ssl_registry, ZEND_STRL("falsestart"), CURLOPT_SSL_FALSESTART, _IS_BOOL); ++ if ((opt = php_http_option_register(ssl_registry, ZEND_STRL("falsestart"), CURLOPT_SSL_FALSESTART, _IS_BOOL))) { ++ opt->flags |= PHP_HTTP_CURLE_OPTION_IGNORE_RC; ++ } + #endif + #if PHP_HTTP_CURL_VERSION(7,61,0) + if ((opt = php_http_option_register(ssl_registry, ZEND_STRL("tls13_ciphers"), CURLOPT_TLS13_CIPHERS, IS_STRING))) { +@@ -1805,7 +1808,11 @@ static ZEND_RESULT_CODE php_http_curle_set_option(php_http_option_t *opt, zval * + break; + } + if (rv != SUCCESS) { +- php_error_docref(NULL, E_NOTICE, "Could not set option %s (%s)", opt->name->val, curl_easy_strerror(rc)); ++ if (opt->flags & PHP_HTTP_CURLE_OPTION_IGNORE_RC) { ++ rv = SUCCESS; ++ } else { ++ php_error_docref(NULL, E_NOTICE, "Could not set option %s (%s)", opt->name->val, curl_easy_strerror(rc)); ++ } + } + return rv; + } +-- +2.31.1 + +From e49f2f1ff5f4aa5f3a96444e8a677f64a45f0d6f Mon Sep 17 00:00:00 2001 +From: Michael Wallner +Date: Mon, 2 Aug 2021 16:42:58 +0200 +Subject: [PATCH 05/11] tests: skip ~E_DEPRECATED + +--- + tests/client024.phpt | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/tests/client024.phpt b/tests/client024.phpt +index ac29865..4e8fe2f 100644 +--- a/tests/client024.phpt ++++ b/tests/client024.phpt +@@ -4,6 +4,8 @@ client deprecated methods + + --FILE-- + +Date: Mon, 2 Aug 2021 16:43:55 +0200 +Subject: [PATCH 06/11] tests: skip SecureTransport + +--- + tests/client012.phpt | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/tests/client012.phpt b/tests/client012.phpt +index bb599db..0e72628 100644 +--- a/tests/client012.phpt ++++ b/tests/client012.phpt +@@ -6,6 +6,8 @@ include "skipif.inc"; + skip_online_test(); + skip_client_test(); + skip_curl_test("7.34.0"); ++if (strpos(http\Client\Curl\Versions\SSL, "SecureTransport") !== false) ++ die("skip SecureTransport\n"); + ?> + --FILE-- + getTransferInfo($req)->tls_session["backend"]) { + case "openssl": + case "gnutls": + if (count($observer->data) < 1) { +- die("failed count(ssl.internals) >= 1\n"); ++ printf("%s: failed count(ssl.internals) >= 1\n", $client->getTransferInfo($req)->tls_session["backend"]); ++ var_dump($observer); ++ exit; + } + break; + default: +-- +2.31.1 + +From c941e27c8f668f5dc8d7f6a8a5ec3986534d1a29 Mon Sep 17 00:00:00 2001 +From: Michael Wallner +Date: Mon, 2 Aug 2021 16:57:20 +0200 +Subject: [PATCH 07/11] tests: skip Darwin + +--- + tests/urlparser010.phpt | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/tests/urlparser010.phpt b/tests/urlparser010.phpt +index e2e36db..c7f800a 100644 +--- a/tests/urlparser010.phpt ++++ b/tests/urlparser010.phpt +@@ -7,7 +7,9 @@ if (!defined("http\\Url::PARSE_MBLOC") or + !utf8locale()) { + die("skip need http\\Url::PARSE_MBLOC support and LC_CTYPE=*.UTF-8"); + } +- ++if (PHP_OS == "Darwin") { ++ die("skip Darwin\n"); ++} + ?> + --FILE-- + +Date: Mon, 2 Aug 2021 16:58:59 +0200 +Subject: [PATCH 08/11] fix #116: cookies fail with libcurl >= 7.77 + +--- + src/php_http_client_curl.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/php_http_client_curl.c b/src/php_http_client_curl.c +index 89ae5e0..0e79f19 100644 +--- a/src/php_http_client_curl.c ++++ b/src/php_http_client_curl.c +@@ -856,7 +856,7 @@ static ZEND_RESULT_CODE php_http_curle_option_set_cookiestore(php_http_option_t + } else { + storage->cookiestore = NULL; + } +- if ( CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIEFILE, storage->cookiestore) ++ if ( CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIEFILE, storage->cookiestore ? storage->cookiestore : "") + || CURLE_OK != curl_easy_setopt(ch, CURLOPT_COOKIEJAR, storage->cookiestore) + ) { + return FAILURE; +-- +2.31.1 + +From 114dee054de7fd8b5921b406c5fb69e2cbade9d6 Mon Sep 17 00:00:00 2001 +From: Michael Wallner +Date: Wed, 4 Aug 2021 10:02:39 +0200 +Subject: [PATCH 09/11] fixup message/body serialization + +--- + src/php_http_message.c | 2 ++ + src/php_http_message_body.c | 3 +-- + tests/message002.phpt | 3 ++- + 3 files changed, 5 insertions(+), 3 deletions(-) + +diff --git a/src/php_http_message.c b/src/php_http_message.c +index d09b0b4..7287031 100644 +--- a/src/php_http_message.c ++++ b/src/php_http_message.c +@@ -688,6 +688,8 @@ static void php_http_message_object_prophandler_set_parent_message(php_http_mess + do { \ + if (!obj->message) { \ + obj->message = php_http_message_init(NULL, 0, NULL); \ ++ } else if (!obj->body && php_http_message_body_size(obj->message->body)) { \ ++ php_http_message_object_init_body_object(obj); \ + } \ + } while(0) + +diff --git a/src/php_http_message_body.c b/src/php_http_message_body.c +index 72cfa4a..90714d9 100644 +--- a/src/php_http_message_body.c ++++ b/src/php_http_message_body.c +@@ -714,7 +714,7 @@ PHP_METHOD(HttpMessageBody, __unserialize) + if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "h", &arr)) { + zval *zv = zend_hash_index_find(arr, 0); + +- if (0 && zv) { ++ if (zv) { + zend_string *zs = zval_get_string(zv); + php_stream *s = php_http_mem_stream_open(0, zs); + php_http_message_body_object_t *obj = PHP_HTTP_OBJ(NULL, getThis()); +@@ -742,7 +742,6 @@ PHP_METHOD(HttpMessageBody, __serialize) + zs = php_http_message_body_to_string(obj->body, 0, 0); + if (zs) { + add_index_str(return_value, 0, zs); +- zend_string_release(zs); + } + } + +diff --git a/tests/message002.phpt b/tests/message002.phpt +index 573fdbd..da0b799 100644 +--- a/tests/message002.phpt ++++ b/tests/message002.phpt +@@ -42,7 +42,8 @@ object(%s)#%d (13) { + ["type":protected]=> + int(1) + ["body":protected]=> +- NULL ++ object(http\Message\Body)#3 (0) { ++ } + ["requestMethod":protected]=> + string(4) "POST" + ["requestUrl":protected]=> +-- +2.31.1 + +From 4b0b09b0dae0c24296d4e51ea31863f228657f84 Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Wed, 4 Aug 2021 15:27:53 +0200 +Subject: [PATCH 10/11] fix proto for 8.1.0beta2 + +--- + src/php_http_client.c | 12 ++++++++++++ + tests/client002.phpt | 1 + + tests/client012.phpt | 1 + + tests/client013.phpt | 3 +++ + tests/client030.phpt | 3 ++- + tests/envresponse016.phpt | 1 + + 6 files changed, 20 insertions(+), 1 deletion(-) + +diff --git a/src/php_http_client.c b/src/php_http_client.c +index f1ef55d..0c06cd2 100644 +--- a/src/php_http_client.c ++++ b/src/php_http_client.c +@@ -984,7 +984,11 @@ static int notify(zend_object_iterator *iter, void *puser) + return ZEND_HASH_APPLY_STOP; + } + ++#if PHP_VERSION_ID < 80100 + ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_notify, 0, 0, 0) ++#else ++ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_HttpClient_notify, 0, 0, IS_VOID, 0) ++#endif + ZEND_ARG_OBJ_INFO(0, request, http\\Client\\Request, 1) + ZEND_ARG_INFO(0, progress) + ZEND_END_ARG_INFO(); +@@ -1032,7 +1036,11 @@ static PHP_METHOD(HttpClient, notify) + RETVAL_ZVAL(getThis(), 1, 0); + } + ++#if PHP_VERSION_ID < 80100 + ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_attach, 0, 0, 1) ++#else ++ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_HttpClient_attach, 0, 1, IS_VOID, 0) ++#endif + ZEND_ARG_OBJ_INFO(0, observer, SplObserver, 0) + ZEND_END_ARG_INFO(); + static PHP_METHOD(HttpClient, attach) +@@ -1061,7 +1069,11 @@ static PHP_METHOD(HttpClient, attach) + RETVAL_ZVAL(getThis(), 1, 0); + } + ++#if PHP_VERSION_ID < 80100 + ZEND_BEGIN_ARG_INFO_EX(ai_HttpClient_detach, 0, 0, 1) ++#else ++ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(ai_HttpClient_detach, 0, 1, IS_VOID, 0) ++#endif + ZEND_ARG_OBJ_INFO(0, observer, SplObserver, 0) + ZEND_END_ARG_INFO(); + static PHP_METHOD(HttpClient, detach) +diff --git a/tests/client002.phpt b/tests/client002.phpt +index 6f01a44..0da72d0 100644 +--- a/tests/client002.phpt ++++ b/tests/client002.phpt +@@ -14,6 +14,7 @@ echo "Test\n"; + + class Observer implements SplObserver + { ++ #[ReturnTypeWillChange] + function update(SplSubject $client, http\Client\Request $request = null, StdClass $progress = null) { + echo "P"; + if ($progress->info !== "prepare" && $client->getProgressInfo($request) != $progress) { +diff --git a/tests/client012.phpt b/tests/client012.phpt +index 0e72628..9b4dde7 100644 +--- a/tests/client012.phpt ++++ b/tests/client012.phpt +@@ -26,6 +26,7 @@ var_dump( + + $client->attach($observer = new class implements SplObserver { + public $data = []; ++ #[ReturnTypeWillChange] + function update(SplSubject $client, $req = null, $progress = null) { + $ti = $client->getTransferInfo($req); + if (isset($ti->tls_session["internals"])) { +diff --git a/tests/client013.phpt b/tests/client013.phpt +index 477edf7..962d448 100644 +--- a/tests/client013.phpt ++++ b/tests/client013.phpt +@@ -16,11 +16,13 @@ class Client extends http\Client { + public $pi; + } + class ProgressObserver1 implements SplObserver { ++ #[ReturnTypeWillChange] + function update(SplSubject $c, $r = null) { + if ($c->getProgressInfo($r)) $c->pi .= "-"; + } + } + class ProgressObserver2 implements SplObserver { ++ #[ReturnTypeWillChange] + function update(SplSubject $c, $r = null) { + if ($c->getProgressInfo($r)) $c->pi .= "."; + } +@@ -30,6 +32,7 @@ class CallbackObserver implements SplObserver { + function __construct($callback) { + $this->callback = $callback; + } ++ #[ReturnTypeWillChange] + function update(SplSubject $c, $r = null) { + call_user_func($this->callback, $c, $r); + } +diff --git a/tests/client030.phpt b/tests/client030.phpt +index 8514b4e..156469f 100644 +--- a/tests/client030.phpt ++++ b/tests/client030.phpt +@@ -12,6 +12,7 @@ echo "Test\n"; + include "helper/server.inc"; + + class test implements SplObserver { ++ #[ReturnTypeWillChange] + function update(SplSubject $client) { + $client->once(); + } +@@ -33,4 +34,4 @@ server("proxy.inc", function($port) { + --EXPECTF-- + Test + int(200) +-===DONE=== +\ No newline at end of file ++===DONE=== +diff --git a/tests/envresponse016.phpt b/tests/envresponse016.phpt +index 8d48c93..e8b7a61 100644 +--- a/tests/envresponse016.phpt ++++ b/tests/envresponse016.phpt +@@ -10,6 +10,7 @@ include "skipif.inc"; + echo "Test\n"; + + class closer extends php_user_filter { ++ #[ReturnTypeWillChange] + function filter ($in, $out, &$consumed, $closing) { + while ($bucket = stream_bucket_make_writeable($in)) { + stream_bucket_append($out, $bucket); +-- +2.31.1 + diff --git a/php-pecl-http.spec b/php-pecl-http.spec index a7e3788..7ecf562 100644 --- a/php-pecl-http.spec +++ b/php-pecl-http.spec @@ -46,7 +46,7 @@ Version: %{upstream_version}%{?upstream_prever:~%{upstream_lower}} Release: 0.8.%{gh_date}git%{gh_short}%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{pecl_name}-%{version}-%{gh_short}.tar.gz %else -Release: 4%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +Release: 5%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} Source0: https://pecl.php.net/get/%{proj_name}-%{upstream_version}%{?upstream_prever}.tgz %endif Summary: Extended HTTP support @@ -57,6 +57,8 @@ URL: https://pecl.php.net/package/pecl_http # From http://www.php.net/manual/en/http.configuration.php Source1: %{proj_name}.ini +Patch0: %{proj_name}-php81.patch + BuildRequires: make BuildRequires: %{?dtsprefix}gcc BuildRequires: %{?scl_prefix}php-devel >= 8 @@ -146,6 +148,9 @@ mv %{proj_name}-%{upstream_version}%{?upstream_prever} NTS %{?_licensedir:sed -e '/LICENSE/s/role="doc"/role="src"/' -i package.xml} cd NTS +%if "%{php_version}" > "8.1" +%patch0 -p1 +%endif extver=$(sed -n '/#define PHP_PECL_HTTP_VERSION/{s/.* "//;s/".*$//;p}' php_http.h) if test "x${extver}" != "x%{upstream_version}%{?upstream_prever}%{?gh_date:dev}"; then : Error: Upstream HTTP version is now ${extver}, expecting %{upstream_version}%{?upstream_prever}%{?gh_date:dev}. @@ -332,6 +337,10 @@ fi %changelog +* Wed Aug 4 2021 Remi Collet - 4.1.0-5 +- add fix for 8.1.0beta2 from upstream and from + https://github.com/m6w6/ext-http/pull/118 + * Mon Jul 23 2021 Remi Collet - 4.1.0-4 - ignore 2 more tests failing with libcurl 7.77 -- cgit