diff options
author | Remi Collet <remi@remirepo.net> | 2020-09-10 12:31:17 +0200 |
---|---|---|
committer | Remi Collet <remi@remirepo.net> | 2020-09-10 12:31:17 +0200 |
commit | b4d461710eff7fdb89cb5a1dd848f26e691b1f3c (patch) | |
tree | 99a6013aa7d8de28b24b97556a01585663c3a41c | |
parent | d53f15d196a5c37775a94a349965453efcf36d26 (diff) |
add fix for PHP 8 from
https://github.com/php/pecl-web_services-oauth/pull/16
enable test suite
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | 16.patch | 545 | ||||
-rw-r--r-- | php-pecl-oauth.spec | 25 |
3 files changed, 571 insertions, 1 deletions
@@ -1,5 +1,7 @@ +clog package-*.xml *.tgz +*.tar.bz2 *.tar.gz *.tar.xz *.tar.xz.asc diff --git a/16.patch b/16.patch new file mode 100644 index 0000000..77b15e8 --- /dev/null +++ b/16.patch @@ -0,0 +1,545 @@ +From 696702c57c3ca47ebe139284d7140f21dd335be3 Mon Sep 17 00:00:00 2001 +From: Remi Collet <remi@php.net> +Date: Thu, 10 Sep 2020 11:35:13 +0200 +Subject: [PATCH] work for PHP 8 + +--- + oauth.c | 87 +++++++++++++++++++++++++-------------- + php_oauth.h | 20 +++++---- + provider.c | 44 ++++++++++---------- + provider.h | 4 +- + tests/oauth_sbs.phpt | 10 +++-- + tests/oauth_standard.phpt | 6 +-- + tests/sbs.phpt | 10 +++-- + 7 files changed, 109 insertions(+), 72 deletions(-) + +diff --git a/oauth.c b/oauth.c +index b731216..5f92194 100644 +--- a/oauth.c ++++ b/oauth.c +@@ -33,9 +33,15 @@ static zend_object* php_so_object_new(zend_class_entry *ce) /* {{{ */ + } + /* }}} */ + ++#if PHP_VERSION_ID < 80000 + static zend_object *oauth_clone_obj(zval *this_ptr) /* {{{ */ + { + php_so_object *old_obj = Z_SOO_P(this_ptr); ++#else ++static zend_object *oauth_clone_obj(zend_object *this_ptr) /* {{{ */ ++{ ++ php_so_object *old_obj = so_object_from_obj(this_ptr); ++#endif + php_so_object *new_obj = so_object_from_obj(php_so_object_new(old_obj->zo.ce)); + + zend_objects_clone_members(&new_obj->zo, &old_obj->zo); +@@ -176,20 +182,20 @@ void soo_handle_error(php_so_object *soo, long errorCode, char *msg, char *respo + if (!errorCode) { + php_error(E_WARNING, "caller did not pass an errorcode!"); + } else { +- zend_update_property_long(dex, &ex, "code", sizeof("code")-1, errorCode); ++ zend_update_property_long(dex, OBJ_FOR_PROP(&ex), "code", sizeof("code")-1, errorCode); + } + if (response) { +- zend_update_property_string(dex, &ex, "lastResponse", sizeof("lastResponse")-1, response); ++ zend_update_property_string(dex, OBJ_FOR_PROP(&ex), "lastResponse", sizeof("lastResponse")-1, response); + } + if(soo && soo->debug && Z_TYPE(soo->debugArr) != IS_UNDEF) { +- zend_update_property(dex, &ex, "debugInfo", sizeof("debugInfo") - 1, &soo->debugArr); ++ zend_update_property(dex, OBJ_FOR_PROP(&ex), "debugInfo", sizeof("debugInfo") - 1, &soo->debugArr); + } + + if(additional_info) { +- zend_update_property_string(dex, &ex, "additionalInfo", sizeof("additionalInfo")-1, additional_info); ++ zend_update_property_string(dex, OBJ_FOR_PROP(&ex), "additionalInfo", sizeof("additionalInfo")-1, additional_info); + } + +- zend_update_property_string(dex, &ex, "message", sizeof("message")-1, msg); ++ zend_update_property_string(dex, OBJ_FOR_PROP(&ex), "message", sizeof("message")-1, msg); + zend_throw_exception_object(&ex); + } + /* }}} */ +@@ -249,7 +255,7 @@ zend_string *soo_sign_rsa(php_so_object *soo, char *message, const oauth_sig_con + ZVAL_NULL(&args[1]); + ZVAL_DUP(&args[2], &ctx->privatekey); + +- call_user_function_ex(EG(function_table), NULL, &func, &retval, 3, args, 0, NULL); ++ call_user_function(EG(function_table), NULL, &func, &retval, 3, args); + + if (Z_TYPE(retval) == IS_TRUE || Z_TYPE(retval) == IS_FALSE) { + result = php_base64_encode((unsigned char *) Z_STRVAL_P(Z_REFVAL(args[1])), Z_STRLEN_P(Z_REFVAL(args[1]))); +@@ -373,23 +379,31 @@ static int oauth_strcmp(zval *first, zval *second) /* {{{ */ + } + /* }}} */ + ++#if PHP_VERSION_ID < 80000 + static int oauth_compare_value(const void *a, const void *b) /* {{{ */ + { + Bucket *f, *s; + f = (Bucket *)a; + s = (Bucket *)b; + ++#else ++static int oauth_compare_value(Bucket *f, Bucket *s) /* {{{ */ ++{ ++#endif + return oauth_strcmp(&f->val, &s->val); + } + /* }}} */ + ++#if PHP_VERSION_ID < 80000 + static int oauth_compare_key(const void *a, const void *b) /* {{{ */ + { ++ Bucket *f = (Bucket *)a, *s = (Bucket *)b; ++#else ++static int oauth_compare_key(Bucket *f, Bucket *s) /* {{{ */ ++{ ++#endif + zval first, second; + int result; +- Bucket *f, *s; +- f = (Bucket *) a; +- s = (Bucket *) b; + + if (f->key == NULL) { + ZVAL_LONG(&first, f->h); +@@ -691,7 +705,7 @@ static void oauth_set_debug_info(php_so_object *soo) /* {{{ */ + ADD_DEBUG_INFO(debugInfo, "body_recv", soo->debug_info->body_in, 0); + ADD_DEBUG_INFO(debugInfo, "info", soo->debug_info->curl_info, 0); + +- zend_update_property(soo_class_entry, soo->this_ptr, "debugInfo", sizeof("debugInfo") - 1, debugInfo); ++ zend_update_property(soo_class_entry, OBJ_FOR_PROP(soo->this_ptr), "debugInfo", sizeof("debugInfo") - 1, debugInfo); + } else { + ZVAL_UNDEF(&soo->debugArr); + } +@@ -815,7 +829,7 @@ static long make_req_streams(php_so_object *soo, const char *url, const smart_st + zend_hash_move_forward_ex(request_headers, &pos)) { + /* check if a string based key is used */ + smart_string sheaderline = {0}; +- switch (zend_hash_get_current_key_ex(request_headers, &cur_key, &num_key, &pos)) { ++ switch ((int)zend_hash_get_current_key_ex(request_headers, &cur_key, &num_key, &pos)) { + case HASH_KEY_IS_STRING: + smart_string_appendl(&sheaderline, ZSTR_VAL(cur_key), ZSTR_LEN(cur_key)); + break; +@@ -1061,7 +1075,7 @@ long make_req_curl(php_so_object *soo, const char *url, const smart_string *payl + (cur_val = zend_hash_get_current_data_ex(request_headers, &pos)) != NULL; + zend_hash_move_forward_ex(request_headers, &pos)) { + /* check if a string based key is used */ +- switch (zend_hash_get_current_key_ex(request_headers, &cur_key, &num_key, &pos)) { ++ switch ((int)zend_hash_get_current_key_ex(request_headers, &cur_key, &num_key, &pos)) { + case HASH_KEY_IS_STRING: + smart_string_appendl(&sheader, ZSTR_VAL(cur_key), ZSTR_LEN(cur_key)); + break; +@@ -1797,11 +1811,13 @@ SO_METHOD(__construct) + INIT_smart_string(soo->headers_in); + + /* set default class members */ +- zend_update_property_null(soo_class_entry, obj, "debugInfo", sizeof("debugInfo") - 1); +- zend_update_property_bool(soo_class_entry, obj, "debug", sizeof("debug") - 1, soo->debug); +- zend_update_property_long(soo_class_entry, obj, "sslChecks", sizeof("sslChecks") - 1, soo->sslcheck); ++ zend_update_property_null(soo_class_entry, OBJ_FOR_PROP(obj), "debugInfo", sizeof("debugInfo") - 1); ++ zend_update_property_bool(soo_class_entry, OBJ_FOR_PROP(obj), "debug", sizeof("debug") - 1, soo->debug); ++ zend_update_property_long(soo_class_entry, OBJ_FOR_PROP(obj), "sslChecks", sizeof("sslChecks") - 1, soo->sslcheck); + ++#if PHP_VERSION_ID < 80000 + TSRMLS_SET_CTX(soo->thread_ctx); ++#endif + + if (!sig_method_len) { + sig_method = OAUTH_SIG_METHOD_HMACSHA1; +@@ -2046,7 +2062,7 @@ SO_METHOD(disableDebug) + } + + soo->debug = 0; +- zend_update_property_bool(soo_class_entry, obj, "debug", sizeof("debug") - 1, 0); ++ zend_update_property_bool(soo_class_entry, OBJ_FOR_PROP(obj), "debug", sizeof("debug") - 1, 0); + + RETURN_TRUE; + } +@@ -2067,7 +2083,7 @@ SO_METHOD(enableDebug) + } + + soo->debug = 1; +- zend_update_property_bool(soo_class_entry, obj, "debug", sizeof("debug") - 1, 1); ++ zend_update_property_bool(soo_class_entry, OBJ_FOR_PROP(obj), "debug", sizeof("debug") - 1, 1); + + RETURN_TRUE; + } +@@ -2088,7 +2104,7 @@ SO_METHOD(enableSSLChecks) + } + + soo->sslcheck = OAUTH_SSLCHECK_BOTH; +- zend_update_property_long(soo_class_entry, obj, "sslChecks", sizeof("sslChecks") - 1, 1); ++ zend_update_property_long(soo_class_entry, OBJ_FOR_PROP(obj), "sslChecks", sizeof("sslChecks") - 1, 1); + + RETURN_TRUE; + } +@@ -2109,7 +2125,7 @@ SO_METHOD(disableSSLChecks) + } + + soo->sslcheck = OAUTH_SSLCHECK_NONE; +- zend_update_property_long(soo_class_entry, obj, "sslChecks", sizeof("sslChecks") - 1, 0); ++ zend_update_property_long(soo_class_entry, OBJ_FOR_PROP(obj), "sslChecks", sizeof("sslChecks") - 1, 0); + + RETURN_TRUE; + } +@@ -2132,7 +2148,7 @@ SO_METHOD(setSSLChecks) + + soo->sslcheck = sslcheck & OAUTH_SSLCHECK_BOTH; + +- zend_update_property_long(soo_class_entry, obj, "sslChecks", sizeof("sslChecks") - 1, ++ zend_update_property_long(soo_class_entry, OBJ_FOR_PROP(obj), "sslChecks", sizeof("sslChecks") - 1, + soo->sslcheck); + + RETURN_TRUE; +@@ -2671,24 +2687,32 @@ static zend_function_entry so_functions[] = { /* {{{ */ + /* }}} */ + + ++#if PHP_VERSION_ID < 80000 + zval *oauth_read_member(zval *obj, zval *mem, int type, void **cache_slot, zval *rv) /* {{{ */ + { ++ php_so_object *soo = Z_SOO_P(obj); ++ char *name = Z_STRVAL_P(mem); ++#else ++zval *oauth_read_member(zend_object *obj, zend_string *mem, int type, void **cache_slot, zval *rv) /* {{{ */ ++{ ++ php_so_object *soo = so_object_from_obj(obj); ++ char *name = ZSTR_VAL(mem); ++#endif + zval *return_value = NULL; +- php_so_object *soo; +- +- soo = Z_SOO_P(obj); + + return_value = std_object_handlers.read_property(obj, mem, type, cache_slot, rv); + +- if(!strcasecmp(Z_STRVAL_P(mem),"debug")) { ++ if(!strcasecmp(name, "debug")) { + convert_to_boolean(return_value); + ZVAL_BOOL(return_value, soo->debug); +- } else if(!strcasecmp(Z_STRVAL_P(mem),"sslChecks")) { ++ } else if(!strcasecmp(name, "sslChecks")) { + ZVAL_LONG(return_value, soo->sslcheck); + } + return return_value; + } /* }}} */ + ++ ++#if PHP_VERSION_ID < 80000 + static + #if PHP_VERSION_ID >= 70400 + zval * +@@ -2697,11 +2721,14 @@ void + #endif + oauth_write_member(zval *obj, zval *mem, zval *value, void **cache_slot) /* {{{ */ + { +- char *property; +- php_so_object *soo; +- +- property = Z_STRVAL_P(mem); +- soo = Z_SOO_P(obj); ++ php_so_object *soo = Z_SOO_P(obj); ++ char *property = Z_STRVAL_P(mem); ++#else ++static zval *oauth_write_member(zend_object *obj, zend_string *mem, zval *value, void **cache_slot) /* {{{ */ ++{ ++ php_so_object *soo = so_object_from_obj(obj); ++ char *property = ZSTR_VAL(mem); ++#endif + + if(!strcmp(property,"debug")) { + soo->debug = Z_TYPE_P(value) == IS_TRUE ? 1 : 0; +diff --git a/php_oauth.h b/php_oauth.h +index d5614c4..e472a26 100644 +--- a/php_oauth.h ++++ b/php_oauth.h +@@ -251,11 +251,11 @@ static inline php_so_object *Z_SOO_P(zval *zv) /* {{{ */ { + + #ifndef zend_parse_parameters_none + #define zend_parse_parameters_none() \ +- zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") ++ zend_parse_parameters(ZEND_NUM_ARGS(), "") + #endif + +-void soo_handle_error(php_so_object *soo, long errorCode, char *msg, char *response, char *additional_info TSRMLS_DC); +-zend_string *oauth_generate_sig_base(php_so_object *soo, const char *http_method, const char *uri, HashTable *post_args, HashTable *extra_args TSRMLS_DC); ++void soo_handle_error(php_so_object *soo, long errorCode, char *msg, char *response, char *additional_info); ++zend_string *oauth_generate_sig_base(php_so_object *soo, const char *http_method, const char *uri, HashTable *post_args, HashTable *extra_args); + + #ifndef zend_hash_quick_del + #define HASH_DEL_KEY_QUICK 2 +@@ -318,15 +318,15 @@ zend_string *oauth_generate_sig_base(php_so_object *soo, const char *http_method + #define OAUTH_OK SUCCESS + + #if OAUTH_USE_CURL +-long make_req_curl(php_so_object *soo, const char *url, const smart_string *payload, const char *http_method, HashTable *request_headers TSRMLS_DC); ++long make_req_curl(php_so_object *soo, const char *url, const smart_string *payload, const char *http_method, HashTable *request_headers); + #if LIBCURL_VERSION_NUM >= 0x071304 + #define OAUTH_PROTOCOLS_ALLOWED CURLPROTO_HTTP | CURLPROTO_HTTPS + #endif + #endif + + +-void oauth_free_privatekey(zval *privatekey TSRMLS_DC); +-zend_string *soo_sign(php_so_object *soo, char *message, zval *cs, zval *ts, const oauth_sig_context *ctx TSRMLS_DC); ++void oauth_free_privatekey(zval *privatekey); ++zend_string *soo_sign(php_so_object *soo, char *message, zval *cs, zval *ts, const oauth_sig_context *ctx); + oauth_sig_context *oauth_create_sig_context(const char *sigmethod); + zend_string *oauth_url_encode(char *url, int url_len); + +@@ -340,6 +340,12 @@ zend_string *oauth_url_encode(char *url, int url_len); + #define OAUTH_URL_LEN(a) ZSTR_LEN(a) + #endif + ++#if PHP_VERSION_ID < 80000 ++#define OBJ_FOR_PROP(zv) (zv) ++#else ++#define OBJ_FOR_PROP(zv) Z_OBJ_P(zv) ++#endif ++ + #endif + + /** +@@ -350,4 +356,4 @@ zend_string *oauth_url_encode(char *url, int url_len); + * End: + * vim600: fdm=marker + * vim: noet sw=4 ts=4 noexpandtab +- */ +\ No newline at end of file ++ */ +diff --git a/provider.c b/provider.c +index 5e88f5c..e870bae 100644 +--- a/provider.c ++++ b/provider.c +@@ -24,7 +24,7 @@ static zend_class_entry *oauthprovider; + + static inline void oauth_provider_set_param_member(zval *provider_obj, char *prop_name, zval *prop) /* {{{ */ + { +- zend_update_property(Z_OBJCE_P(provider_obj), provider_obj, prop_name, strlen(prop_name), prop); ++ zend_update_property(Z_OBJCE_P(provider_obj), OBJ_FOR_PROP(provider_obj), prop_name, strlen(prop_name), prop); + } + /* }}} */ + +@@ -117,7 +117,7 @@ static int oauth_provider_token_required(zval *provider_obj, char* uri) + { + zval *is_req_token_api, rv; + +- is_req_token_api = zend_read_property(Z_OBJCE_P(provider_obj), provider_obj, "request_token_endpoint", sizeof("request_token_endpoint") - 1, 1, &rv); ++ is_req_token_api = zend_read_property(Z_OBJCE_P(provider_obj), OBJ_FOR_PROP(provider_obj), "request_token_endpoint", sizeof("request_token_endpoint") - 1, 1, &rv); + + if (Z_TYPE_P(is_req_token_api) == IS_FALSE) { + php_oauth_provider *sop; +@@ -374,7 +374,7 @@ static zval *oauth_provider_call_cb(INTERNAL_FUNCTION_PARAMETERS, int type) /* { + } + + if (zend_fcall_info_call(cb->fcall_info, &cb->fcall_info_cache, return_value, &args)!=SUCCESS) { +- php_error_docref(NULL TSRMLS_CC, E_ERROR, "Failed calling callback %s", Z_STRVAL(cb->fcall_info->function_name)); ++ php_error_docref(NULL, E_ERROR, "Failed calling callback %s", Z_STRVAL(cb->fcall_info->function_name)); + } + + zval_ptr_dtor(&args); +@@ -490,17 +490,17 @@ SOP_METHOD(__construct) + + oauth_provider_set_default_required_params(sop->required_params); + +- zend_update_property_null(Z_OBJCE_P(pthis), pthis, OAUTH_PROVIDER_CONSUMER_KEY, sizeof(OAUTH_PROVIDER_CONSUMER_KEY)-1); +- zend_update_property_null(Z_OBJCE_P(pthis), pthis, OAUTH_PROVIDER_CONSUMER_SECRET, sizeof(OAUTH_PROVIDER_CONSUMER_SECRET)-1); +- zend_update_property_null(Z_OBJCE_P(pthis), pthis, OAUTH_PROVIDER_NONCE, sizeof(OAUTH_PROVIDER_NONCE)-1); +- zend_update_property_null(Z_OBJCE_P(pthis), pthis, OAUTH_PROVIDER_TOKEN, sizeof(OAUTH_PROVIDER_TOKEN)-1); +- zend_update_property_null(Z_OBJCE_P(pthis), pthis, OAUTH_PROVIDER_TOKEN_SECRET, sizeof(OAUTH_PROVIDER_TOKEN_SECRET)-1); +- zend_update_property_null(Z_OBJCE_P(pthis), pthis, OAUTH_PROVIDER_TIMESTAMP, sizeof(OAUTH_PROVIDER_TIMESTAMP)-1); +- zend_update_property_null(Z_OBJCE_P(pthis), pthis, OAUTH_PROVIDER_VERSION, sizeof(OAUTH_PROVIDER_VERSION)-1); +- zend_update_property_null(Z_OBJCE_P(pthis), pthis, OAUTH_PROVIDER_SIGNATURE_METHOD, sizeof(OAUTH_PROVIDER_SIGNATURE_METHOD)-1); +- zend_update_property_null(Z_OBJCE_P(pthis), pthis, OAUTH_PROVIDER_CALLBACK, sizeof(OAUTH_PROVIDER_CALLBACK)-1); ++ zend_update_property_null(Z_OBJCE_P(pthis), OBJ_FOR_PROP(pthis), OAUTH_PROVIDER_CONSUMER_KEY, sizeof(OAUTH_PROVIDER_CONSUMER_KEY)-1); ++ zend_update_property_null(Z_OBJCE_P(pthis), OBJ_FOR_PROP(pthis), OAUTH_PROVIDER_CONSUMER_SECRET, sizeof(OAUTH_PROVIDER_CONSUMER_SECRET)-1); ++ zend_update_property_null(Z_OBJCE_P(pthis), OBJ_FOR_PROP(pthis), OAUTH_PROVIDER_NONCE, sizeof(OAUTH_PROVIDER_NONCE)-1); ++ zend_update_property_null(Z_OBJCE_P(pthis), OBJ_FOR_PROP(pthis), OAUTH_PROVIDER_TOKEN, sizeof(OAUTH_PROVIDER_TOKEN)-1); ++ zend_update_property_null(Z_OBJCE_P(pthis), OBJ_FOR_PROP(pthis), OAUTH_PROVIDER_TOKEN_SECRET, sizeof(OAUTH_PROVIDER_TOKEN_SECRET)-1); ++ zend_update_property_null(Z_OBJCE_P(pthis), OBJ_FOR_PROP(pthis), OAUTH_PROVIDER_TIMESTAMP, sizeof(OAUTH_PROVIDER_TIMESTAMP)-1); ++ zend_update_property_null(Z_OBJCE_P(pthis), OBJ_FOR_PROP(pthis), OAUTH_PROVIDER_VERSION, sizeof(OAUTH_PROVIDER_VERSION)-1); ++ zend_update_property_null(Z_OBJCE_P(pthis), OBJ_FOR_PROP(pthis), OAUTH_PROVIDER_SIGNATURE_METHOD, sizeof(OAUTH_PROVIDER_SIGNATURE_METHOD)-1); ++ zend_update_property_null(Z_OBJCE_P(pthis), OBJ_FOR_PROP(pthis), OAUTH_PROVIDER_CALLBACK, sizeof(OAUTH_PROVIDER_CALLBACK)-1); + +- zend_update_property_bool(Z_OBJCE_P(pthis), pthis, "request_token_endpoint", sizeof("request_token_endpoint")-1, 0); ++ zend_update_property_bool(Z_OBJCE_P(pthis), OBJ_FOR_PROP(pthis), "request_token_endpoint", sizeof("request_token_endpoint")-1, 0); + + if(!param_count) { + /* TODO: support NSAPI */ +@@ -632,7 +632,7 @@ SOP_METHOD(isRequestTokenEndpoint) + return; + } + +- zend_update_property_bool(Z_OBJCE_P(pthis), pthis, "request_token_endpoint", sizeof("request_token_endpoint") - 1, req_api); ++ zend_update_property_bool(Z_OBJCE_P(pthis), OBJ_FOR_PROP(pthis), "request_token_endpoint", sizeof("request_token_endpoint") - 1, req_api); + } + /* }}} */ + +@@ -734,7 +734,7 @@ SOP_METHOD(checkOAuthRequest) + return; + } + +- sig_method = zend_read_property(Z_OBJCE_P(pthis), pthis, OAUTH_PROVIDER_SIGNATURE_METHOD, sizeof(OAUTH_PROVIDER_SIGNATURE_METHOD) - 1, 1, &rv); ++ sig_method = zend_read_property(Z_OBJCE_P(pthis), OBJ_FOR_PROP(pthis), OAUTH_PROVIDER_SIGNATURE_METHOD, sizeof(OAUTH_PROVIDER_SIGNATURE_METHOD) - 1, 1, &rv); + do { + if (sig_method && (Z_TYPE_P(sig_method) == IS_STRING) && Z_STRLEN_P(sig_method)) { + sig_ctx = oauth_create_sig_context(Z_STRVAL_P(sig_method)); +@@ -803,16 +803,16 @@ SOP_METHOD(checkOAuthRequest) + sbs = oauth_generate_sig_base(NULL, http_verb, uri, sbs_vars, NULL); + + if (sbs) { +- consumer_secret = zend_read_property(Z_OBJCE_P(pthis), pthis, OAUTH_PROVIDER_CONSUMER_SECRET, sizeof(OAUTH_PROVIDER_CONSUMER_SECRET) - 1, 1, &rv); ++ consumer_secret = zend_read_property(Z_OBJCE_P(pthis), OBJ_FOR_PROP(pthis), OAUTH_PROVIDER_CONSUMER_SECRET, sizeof(OAUTH_PROVIDER_CONSUMER_SECRET) - 1, 1, &rv); + convert_to_string_ex(consumer_secret); + if (is_token_required) { +- token_secret = zend_read_property(Z_OBJCE_P(pthis), pthis, OAUTH_PROVIDER_TOKEN_SECRET, sizeof(OAUTH_PROVIDER_TOKEN_SECRET) - 1, 1, &rv); ++ token_secret = zend_read_property(Z_OBJCE_P(pthis), OBJ_FOR_PROP(pthis), OAUTH_PROVIDER_TOKEN_SECRET, sizeof(OAUTH_PROVIDER_TOKEN_SECRET) - 1, 1, &rv); + convert_to_string_ex(token_secret); + } + signature = soo_sign(NULL, ZSTR_VAL(sbs), consumer_secret, token_secret, sig_ctx); + } + +- req_signature = zend_read_property(Z_OBJCE_P(pthis), pthis, OAUTH_PROVIDER_SIGNATURE, sizeof(OAUTH_PROVIDER_SIGNATURE) - 1, 1, &rv); ++ req_signature = zend_read_property(Z_OBJCE_P(pthis), OBJ_FOR_PROP(pthis), OAUTH_PROVIDER_SIGNATURE, sizeof(OAUTH_PROVIDER_SIGNATURE) - 1, 1, &rv); + if (!signature || !Z_STRLEN_P(req_signature) || strcmp(ZSTR_VAL(signature), Z_STRVAL_P(req_signature))) { + soo_handle_error(NULL, OAUTH_INVALID_SIGNATURE, "Signatures do not match", NULL, sbs ? ZSTR_VAL(sbs) : NULL); + } +@@ -984,7 +984,7 @@ SOP_METHOD(reportProblem) + } + + /* XXX good candidate for refactoring */ +- code = zend_read_property(Z_OBJCE_P(exception), exception, "code", sizeof("code") - 1, 1, &rv); ++ code = zend_read_property(Z_OBJCE_P(exception), OBJ_FOR_PROP(exception), "code", sizeof("code") - 1, 1, &rv); + lcode = Z_LVAL_P(code); + + switch(lcode) { +@@ -1018,7 +1018,7 @@ SOP_METHOD(reportProblem) + case OAUTH_INVALID_SIGNATURE: + http_code = OAUTH_ERR_BAD_AUTH; + out = "oauth_problem=signature_invalid"; +- sbs = zend_read_property(Z_OBJCE_P(exception), exception, "additionalInfo", sizeof("additionalInfo") - 1, 1, &rv); ++ sbs = zend_read_property(Z_OBJCE_P(exception), OBJ_FOR_PROP(exception), "additionalInfo", sizeof("additionalInfo") - 1, 1, &rv); + if (sbs && IS_NULL!=Z_TYPE_P(sbs)) { + convert_to_string_ex(sbs); + if(Z_STRLEN_P(sbs)) { +@@ -1037,7 +1037,7 @@ SOP_METHOD(reportProblem) + case OAUTH_PARAMETER_ABSENT: + http_code = OAUTH_ERR_BAD_REQUEST; + out = "oauth_problem=parameter_absent"; +- missing_params = zend_read_property(Z_OBJCE_P(exception), exception, "additionalInfo", sizeof("additionalInfo") - 1, 1, &rv); ++ missing_params = zend_read_property(Z_OBJCE_P(exception), OBJ_FOR_PROP(exception), "additionalInfo", sizeof("additionalInfo") - 1, 1, &rv); + if(missing_params) { + convert_to_string_ex(missing_params); + if(Z_STRLEN_P(missing_params)) { +@@ -1176,7 +1176,7 @@ static zend_function_entry oauth_provider_methods[] = { /* {{{ */ + {NULL, NULL, NULL} + }; + +-extern int oauth_provider_register_class() /* {{{ */ ++extern int oauth_provider_register_class(void) /* {{{ */ + { + zend_class_entry osce; + +diff --git a/provider.h b/provider.h +index aa9d61b..90ec01a 100644 +--- a/provider.h ++++ b/provider.h +@@ -47,7 +47,7 @@ + } \ + + #define OAUTH_PROVIDER_CHECK_PARAMS(s, r) \ +- if(oauth_provider_check_sapi(s, TRUE TSRMLS_CC)) { \ ++ if(oauth_provider_check_sapi(s, TRUE)) { \ + if(r) {\ + RETURN_FALSE\ + } \ +@@ -110,7 +110,7 @@ static inline php_oauth_provider *sop_object_from_obj(zend_object *obj) /* {{{ * + #define Z_SOP_P(zv) sop_object_from_obj(Z_OBJ_P((zv))) + + +-extern int oauth_provider_register_class(TSRMLS_D); ++extern int oauth_provider_register_class(void); + + #define SOP_METHOD(func) PHP_METHOD(oauthprovider, func) + #define SOP_ME(func, arg_info, flags) PHP_ME(oauthprovider, func, arg_info, flags) +diff --git a/tests/oauth_sbs.phpt b/tests/oauth_sbs.phpt +index 4e9269e..6d9bb4c 100644 +--- a/tests/oauth_sbs.phpt ++++ b/tests/oauth_sbs.phpt +@@ -8,7 +8,11 @@ echo oauth_get_sbs('GET', 'http://127.0.0.1:12342/'),"\n"; + echo "-- using empty array --\n"; + echo oauth_get_sbs('GET', 'http://127.0.0.1:12342/', array()),"\n"; + echo "-- using string instead of array --\n"; +-echo oauth_get_sbs('GET', 'http://127.0.0.1:12342/',''),"\n"; ++try { ++ echo oauth_get_sbs('GET', 'http://127.0.0.1:12342/',''),"\n"; ++} catch (TypeError $e) { ++ echo $e->getMessage()."\n"; ++} + echo "-- using numeric keys masked as a string --\n"; + echo oauth_get_sbs('GET', 'http://127.0.0.1:12342/',array('1'=>'hello')),"\n"; + echo "-- using string keys --\n"; +@@ -31,9 +35,7 @@ GET&http%3A%2F%2F127.0.0.1%3A12342%2F& + -- using empty array -- + GET&http%3A%2F%2F127.0.0.1%3A12342%2F& + -- using string instead of array -- +- +-Warning: oauth_get_sbs() expects parameter 3 to be array, string given in %s +- ++%Astring given%A + -- using numeric keys masked as a string -- + GET&http%3A%2F%2F127.0.0.1%3A12342%2F&1%3Dhello + -- using string keys -- +diff --git a/tests/oauth_standard.phpt b/tests/oauth_standard.phpt +index 0342f8a..5eb2d57 100644 +--- a/tests/oauth_standard.phpt ++++ b/tests/oauth_standard.phpt +@@ -61,6 +61,8 @@ try { + var_dump($x->setVersion()); + } catch (Exception $e) { + echo "EXCEPTION {$e->getCode()}: {$e->getMessage()}\n"; ++} catch (ArgumentCountError $e) { ++ echo "EXCEPTION {$e->getCode()}: {$e->getMessage()}\n"; + } + try { + echo "-- set version with boolean --\n"; +@@ -115,9 +117,7 @@ OAuth[debug=1,sslChecks=3,debugInfo=] + -- disable debug -- + OAuth[debug=0,sslChecks=3,debugInfo=] + -- set version without parameters -- +- +-Warning: OAuth::setVersion() expects exactly 1 parameter, 0 given %s +-NULL ++%A expects exactly 1 parameter, %A + -- set version with boolean -- + bool(true) + -- set version with empty string -- +diff --git a/tests/sbs.phpt b/tests/sbs.phpt +index 1333607..2e8e13b 100644 +--- a/tests/sbs.phpt ++++ b/tests/sbs.phpt +@@ -8,7 +8,11 @@ echo oauth_get_sbs('GET', 'http://127.0.0.1:12342/'),"\n"; + echo "-- using empty array --\n"; + echo oauth_get_sbs('GET', 'http://127.0.0.1:12342/', array()),"\n"; + echo "-- using string instead of array --\n"; +-echo oauth_get_sbs('GET', 'http://127.0.0.1:12342/',''),"\n"; ++try { ++ echo oauth_get_sbs('GET', 'http://127.0.0.1:12342/',''),"\n"; ++} catch (TypeError $e) { ++ echo $e->getMessage()."\n"; ++} + echo "-- using numeric keys masked as a string --\n"; + echo oauth_get_sbs('GET', 'http://127.0.0.1:12342/',array('1'=>'hello')),"\n"; + echo "-- using string keys --\n"; +@@ -29,9 +33,7 @@ GET&http%3A%2F%2F127.0.0.1%3A12342%2F& + -- using empty array -- + GET&http%3A%2F%2F127.0.0.1%3A12342%2F& + -- using string instead of array -- +- +-Warning: oauth_get_sbs() expects parameter 3 to be array,%sstring given in %s +- ++%Astring given%A + -- using numeric keys masked as a string -- + GET&http%3A%2F%2F127.0.0.1%3A12342%2F&1%3Dhello + -- using string keys -- diff --git a/php-pecl-oauth.spec b/php-pecl-oauth.spec index 38177bc..9668831 100644 --- a/php-pecl-oauth.spec +++ b/php-pecl-oauth.spec @@ -8,6 +8,9 @@ # # Please, preserve the changelog entries # + +%bcond_without tests + %if 0%{?scl:1} %global sub_prefix %{scl_prefix} %scl_package php-pecl-oauth @@ -19,12 +22,14 @@ Name: %{?sub_prefix}php-pecl-oauth Version: 2.0.6 -Release: 1%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +Release: 2%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} Summary: PHP OAuth consumer extension License: BSD URL: https://pecl.php.net/package/oauth Source0: https://pecl.php.net/get/%{pecl_name}-%{version}.tgz +Patch0: https://patch-diff.githubusercontent.com/raw/php/pecl-web_services-oauth/pull/16.patch + BuildRequires: %{?dtsprefix}gcc BuildRequires: %{?scl_prefix}php-devel >= 7 BuildRequires: %{?scl_prefix}php-pear @@ -92,6 +97,8 @@ sed -e 's/role="test"/role="src"/' \ -i package.xml cd NTS +%patch0 -p1 -b .pr + #sed -e '/PHP_OAUTH_VERSION/s/2.0.3-dev/2.0.3/' -i php_oauth.h # Sanity check, really often broken extver=$(sed -n '/#define PHP_OAUTH_VERSION/{s/.* //;s/".*$//;p}' php_oauth.h) @@ -177,11 +184,22 @@ fi -d extension=%{buildroot}%{php_extdir}/%{pecl_name}.so \ --modules | grep OAuth +%if %{with tests} +cd NTS +: Upstream test suite for NTS extension +TEST_PHP_EXECUTABLE=%{__php} \ +TEST_PHP_ARGS="-n -d extension=%{buildroot}%{php_extdir}/%{pecl_name}.so" \ +NO_INTERACTION=1 \ +REPORT_EXIT_STATUS=1 \ +%{__php} -n run-tests.php --show-diff +%endif + %if %{with_zts} : Minimal load test for ZTS extension %{__ztsphp} -n \ -d extension=%{buildroot}%{php_ztsextdir}/%{pecl_name}.so \ --modules | grep OAuth + %endif @@ -200,6 +218,11 @@ fi %changelog +* Thu Sep 10 2020 Remi Collet <remi@remirepo.net> - 2.0.6-2 +- add fix for PHP 8 from + https://github.com/php/pecl-web_services-oauth/pull/16 +- enable test suite + * Wed Sep 9 2020 Remi Collet <remi@remirepo.net> - 2.0.6-1 - update to 2.0.6 |