Backport v4 updates
authorMichael Wallner <mike@php.net>
Wed, 8 Jun 2022 15:22:34 +0000 (17:22 +0200)
committerMichael Wallner <mike@php.net>
Wed, 8 Jun 2022 15:28:58 +0000 (17:28 +0200)
15 files changed:
1  2 
.gitignore
config9.m4
package.xml
php_http.h
src/php_http_client.c
src/php_http_cookie.c
src/php_http_env.c
src/php_http_header.c
src/php_http_message.c
src/php_http_params.c
src/php_http_querystring.c
src/php_http_url.c
tests/client002.phpt
tests/client012.phpt
tests/client024.phpt

diff --cc .gitignore
Simple merge
diff --cc config9.m4
Simple merge
diff --cc package.xml
index e0c0916051d6a97feeaa3b520e368886c57612fd,2c8b432165fe2a2d9f41f3537424cb1633ac4c60..0576cf2b4c09afbcfab1ff5d2d23325f24c0ce81
@@@ -31,10 -31,10 +31,10 @@@ https://mdref.m6w6.name/htt
    <email>mike@php.net</email>
    <active>yes</active>
   </lead>
-- <date>2022-02-25</date>
++ <date>2022-06-10</date>
   <version>
-   <release>3.2.5</release>
-   <api>3.2.0</api>
 -  <release>4.2.2</release>
 -  <api>4.2.0</api>
++  <release>3.3.0</release>
++  <api>3.3.0</api>
   </version>
   <stability>
    <release>stable</release>
@@@ -42,7 -42,7 +42,7 @@@
   </stability>
   <license uri="http://copyfree.org/content/standard/licenses/2bsd/license.txt">BSD-2-Clause</license>
   <notes><![CDATA[
--  * Fixed gh-issue #123: Segfault with libcurl 7.81
++  * Backport features and bug fixes from v4.
  ]]></notes>
   <contents>
    <dir name="/">
diff --cc php_http.h
index c2a5b95247d41b322658b1772742b748f64cc425,f4b4b33eb38cdeb4bc0179f8157d8d27d87456ee..d57f6e4b75c067e823b7472d7518846c90acf3be
@@@ -13,7 -13,7 +13,7 @@@
  #ifndef PHP_EXT_HTTP_H
  #define PHP_EXT_HTTP_H
  
- #define PHP_PECL_HTTP_VERSION "3.2.5"
 -#define PHP_PECL_HTTP_VERSION "4.2.2"
++#define PHP_PECL_HTTP_VERSION "3.3.0dev"
  
  extern zend_module_entry http_module_entry;
  #define phpext_http_ptr &http_module_entry
index 9551dd0bbe775f252a8893f090a17f06ddb5d36f,a272fa45d0a4f6c2658b20273b828b57f7c0097f..d2f620490a045313d9f7c55664e946d4be662af8
@@@ -633,11 -646,10 +647,10 @@@ static PHP_METHOD(HttpClient, reset
        RETVAL_ZVAL(getThis(), 1, 0);
  }
  
- static HashTable *combined_options(zval *client, zval *request)
+ static HashTable *combined_options(HashTable *options, zval *client, zval *request)
  {
-       HashTable *options;
        unsigned num_options = 0;
 -      zval z_roptions, z_options_tmp, *z_coptions = zend_read_property(php_http_client_class_entry, Z_OBJ_P(client), ZEND_STRL("options"), 0, &z_options_tmp);
 +      zval z_roptions, z_options_tmp, *z_coptions = zend_read_property(php_http_client_class_entry, client, ZEND_STRL("options"), 0, &z_options_tmp);
  
        if (Z_TYPE_P(z_coptions) == IS_ARRAY) {
                num_options = zend_hash_num_elements(Z_ARRVAL_P(z_coptions));
Simple merge
Simple merge
index 4c9a7025684051ade431db1f730cff99083bbd11,c475a8186a8249714698333df1dd624cacfda29e..7044c2101fdc2d26b14ec5dfb26c7efa0c00f359
@@@ -327,13 -362,13 +327,13 @@@ ZEND_END_ARG_INFO()
  PHP_METHOD(HttpHeader, getParams)
  {
        zval value_tmp, zctor, zparams_obj, *zargs = NULL;
-       
        ZVAL_STRINGL(&zctor, "__construct", lenof("__construct"));
-       
        object_init_ex(&zparams_obj, php_http_params_get_class_entry());
-       
        zargs = (zval *) ecalloc(ZEND_NUM_ARGS()+1, sizeof(zval));
 -      ZVAL_COPY_VALUE(&zargs[0], zend_read_property(php_http_header_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("value"), 0, &value_tmp));
 +      ZVAL_COPY_VALUE(&zargs[0], zend_read_property(php_http_header_class_entry, getThis(), ZEND_STRL("value"), 0, &value_tmp));
        if (ZEND_NUM_ARGS()) {
                zend_get_parameters_array(ZEND_NUM_ARGS(), ZEND_NUM_ARGS(), &zargs[1]);
        }
index 371ecb7067d021785caa7677de75f135b6b45fdd,cd01757b4f83d5261014b10dfa4e7d049231b84b..2014aac8f4087a4cb587127fdba5e42f30a2cb38
@@@ -956,9 -937,12 +958,11 @@@ static HashTable *php_http_message_obje
        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 { \
Simple merge
index 391bccf675f0534d36f079b2bb75b892a1434f9c,06d52c5a1c520cdf02c0f0af6e6f826a29f2ad69..b1c6a662d6ec6888ca61185c56993911a6dacc8f
@@@ -505,11 -504,11 +505,11 @@@ PHP_METHOD(HttpQueryString, mod
        zend_error_handling zeh;
  
        php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "z", &params), invalid_arg, return);
-       
        zend_replace_error_handling(EH_THROW, php_http_get_exception_bad_querystring_class_entry(), &zeh);
 -      ZVAL_OBJ(return_value, Z_OBJ_HT_P(instance)->clone_obj(Z_OBJ_P(instance)));
 +      ZVAL_OBJ(return_value, Z_OBJ_HT_P(instance)->clone_obj(instance));
        /* make sure we do not inherit the reference to _GET */
 -      SEPARATE_ZVAL(zend_read_property(Z_OBJCE_P(return_value), Z_OBJ_P(return_value), ZEND_STRL("queryArray"), 0, &qa_tmp));
 +      SEPARATE_ZVAL(zend_read_property(Z_OBJCE_P(return_value), return_value, ZEND_STRL("queryArray"), 0, &qa_tmp));
        php_http_querystring_set(return_value, params, QS_MERGE);
        zend_restore_error_handling(&zeh);
  }
@@@ -606,8 -628,8 +606,8 @@@ PHP_METHOD(HttpQueryString, offsetGet
        if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "S", &offset)) {
                return;
        }
-       
 +      qa = zend_read_property(php_http_querystring_class_entry, getThis(), ZEND_STRL("queryArray"), 0, &qa_tmp);
 -      qa = zend_read_property(php_http_querystring_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("queryArray"), 0, &qa_tmp);
        ZVAL_DEREF(qa);
  
        if (Z_TYPE_P(qa) == IS_ARRAY) {
@@@ -653,8 -675,8 +653,8 @@@ PHP_METHOD(HttpQueryString, offsetExist
        if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "S", &offset)) {
                return;
        }
-       
 +      qa = zend_read_property(php_http_querystring_class_entry, getThis(), ZEND_STRL("queryArray"), 0, &qa_tmp);
 -      qa = zend_read_property(php_http_querystring_class_entry, Z_OBJ_P(ZEND_THIS), ZEND_STRL("queryArray"), 0, &qa_tmp);
        ZVAL_DEREF(qa);
  
        if (Z_TYPE_P(qa) == IS_ARRAY) {
Simple merge
index 6f01a444e97a20d72e95bb6edf1a84c26b659e5d,d020f16e22ff4d5916b2ba4830ae1083c48c321a..5b0b2aadc4033e3ad2e611cb4fbc7f75e7401777
@@@ -14,10 -14,13 +14,12 @@@ 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) {
-                       var_dump($progress);
+               /* fence against buggy infof() calls in some curl versions */
+               $compare = $client->getProgressInfo($request);
+               if ($progress->info !== "prepare" && $compare && $compare != $progress) {
+                       var_dump($progress, $compare);
                }
        }
  }
Simple merge
index 27a68b4f32dfc2ee01bdaa480de23f6b028643ba,4e8fe2f9bf8d695e810ca41fa859c8b321d22b01..39949b038f16444ac71931397610837b23fa14c2
@@@ -19,7 -21,7 +21,7 @@@ $client->enablePipelining(false)
  --EXPECTF--
  Test
  
- Deprecated: Function http\Client::enableEvents() is deprecated in %sclient024.php on line %d
 -Deprecated: Method http\Client::enableEvents() is deprecated in %sclient024.php on line %d
++Deprecated: %s http\Client::enableEvents() is deprecated in %sclient024.php on line %d
  
- Deprecated: Function http\Client::enablePipelining() is deprecated in %sclient024.php on line %d
 -Deprecated: Method http\Client::enablePipelining() is deprecated in %sclient024.php on line %d
++Deprecated: %s http\Client::enablePipelining() is deprecated in %sclient024.php on line %d
  ===DONE===