From 629eeb047ceeb36066298f25dc496eb7bc481b18 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 9 Jul 2024 15:27:02 +0200 Subject: add patch for PHP 8.4 from https://github.com/php/pecl-web_services-oauth/pull/30 --- oauth-php84.patch | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++ php-pecl-oauth.spec | 43 +++++++------------------------- 2 files changed, 81 insertions(+), 34 deletions(-) create mode 100644 oauth-php84.patch diff --git a/oauth-php84.patch b/oauth-php84.patch new file mode 100644 index 0000000..6b7f163 --- /dev/null +++ b/oauth-php84.patch @@ -0,0 +1,72 @@ +From 5b2b573d2bc7d894fe247978b7b42644218aad0b Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Tue, 9 Jul 2024 15:09:40 +0200 +Subject: [PATCH] fix for PHP 8.4 + +--- + oauth.c | 2 +- + php_oauth.h | 6 +++++- + provider.c | 4 +++- + 3 files changed, 9 insertions(+), 3 deletions(-) + +diff --git a/oauth.c b/oauth.c +index 46fe08b..9bd8d2a 100644 +--- a/oauth.c ++++ b/oauth.c +@@ -1330,7 +1330,7 @@ static void make_standard_query(HashTable *ht, php_so_object *soo) /* {{{ */ + gettimeofday((struct timeval *) &tv, (struct timezone *) NULL); + sec = (int) tv.tv_sec; + usec = (int) (tv.tv_usec % 0x100000); +- spprintf(&nonce, 0, "%ld%08x%05x%.8f", php_rand(), sec, usec, php_combined_lcg() * 10); ++ spprintf(&nonce, 0, "%d%08x%05x%.8f", php_mt_rand(), sec, usec, php_combined_lcg() * 10); + } + + add_arg_for_req(ht, OAUTH_PARAM_CONSUMER_KEY, Z_STRVAL_P(soo_get_property(soo, OAUTH_ATTR_CONSUMER_KEY))); +diff --git a/php_oauth.h b/php_oauth.h +index e5a1225..63a29ec 100644 +--- a/php_oauth.h ++++ b/php_oauth.h +@@ -29,7 +29,12 @@ + #include "php_main.h" + #include "php_ini.h" + #include "ext/standard/php_string.h" ++#if PHP_VERSION_ID < 80400 + #include "ext/standard/php_rand.h" ++#include "ext/standard/php_lcg.h" ++#else ++#include "ext/random/php_random.h" ++#endif + #include "ext/standard/php_smart_string.h" + #include "ext/standard/info.h" + #include "ext/standard/php_string.h" +@@ -41,7 +46,6 @@ + #include "php_globals.h" + #include "ext/standard/file.h" + #include "ext/standard/base64.h" +-#include "ext/standard/php_lcg.h" + #include "ext/pcre/php_pcre.h" + #include "php_network.h" + +diff --git a/provider.c b/provider.c +index cd853f0..5247441 100644 +--- a/provider.c ++++ b/provider.c +@@ -236,7 +236,9 @@ static int oauth_provider_parse_auth_header(php_oauth_provider *sop, char *auth_ + &return_value, + &subpats, + 1, /* global */ ++#if PHP_VERSION_ID < 80400 + 1, /* use flags */ ++#endif + 2, /* PREG_SET_ORDER */ + 0 + ); +@@ -956,7 +958,7 @@ SOP_METHOD(generateToken) + php_error_docref(NULL, E_WARNING, "Could not gather enough random data, falling back on rand()"); + } + while (reaped < size) { +- iv[reaped++] = (char) (255.0 * php_rand() / RAND_MAX); ++ iv[reaped++] = (char)php_mt_rand_range(0, 255); + } + } + diff --git a/php-pecl-oauth.spec b/php-pecl-oauth.spec index 9462e2c..8eeef4a 100644 --- a/php-pecl-oauth.spec +++ b/php-pecl-oauth.spec @@ -21,7 +21,7 @@ Name: %{?scl_prefix}php-pecl-oauth Version: 2.0.7 -Release: 9%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} +Release: 10%{?dist}%{!?scl:%{!?nophptag:%(%{__php} -r 'echo ".".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')}} Summary: PHP OAuth consumer extension License: BSD-3-Clause URL: https://pecl.php.net/package/oauth @@ -29,6 +29,7 @@ Source0: https://pecl.php.net/get/%{pecl_name}-%{version}.tgz Patch0: %{pecl_name}-pcre.patch Patch1: %{pecl_name}-php82.patch +Patch2: %{pecl_name}-php84.patch BuildRequires: make BuildRequires: %{?dtsprefix}gcc @@ -46,17 +47,6 @@ Provides: %{?scl_prefix}php-%{pecl_name}%{?_isa} = %{version} Provides: %{?scl_prefix}php-pecl(%{pecl_name}) = %{version} Provides: %{?scl_prefix}php-pecl(%{pecl_name})%{?_isa} = %{version} -%if "%{?packager}" == "Remi Collet" && 0%{!?scl:1} && 0%{?rhel} == 7 -# Other third party repo stuff -Obsoletes: php56u-pecl-%{pecl_name} <= %{version} -%if "%{php_version}" > "7.1" -Obsoletes: php71u-pecl-%{pecl_name} <= %{version} -%endif -%if "%{php_version}" > "7.2" -Obsoletes: php72u-pecl-%{pecl_name} <= %{version} -%endif -%endif - %description OAuth is an authorization protocol built on top of HTTP which allows @@ -73,12 +63,13 @@ Package built for PHP %(%{__php} -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSIO # Don't install/register tests sed -e 's/role="test"/role="src"/' \ - %{?_licensedir:-e '/LICENSE/s/role="doc"/role="src"/' } \ + -e '/LICENSE/s/role="doc"/role="src"/' \ -i package.xml cd %{sources} %patch -P0 -p1 -b .up %patch -P1 -p1 -b .pr24 +%patch -P2 -p1 -b .pr30 #sed -e '/PHP_OAUTH_VERSION/s/2.0.3-dev/2.0.3/' -i php_oauth.h # Sanity check, really often broken @@ -140,26 +131,6 @@ do install -Dpm 644 $i %{buildroot}%{pecl_docdir}/%{pecl_name}/$i done -%if 0%{?fedora} < 24 && 0%{?rhel} < 8 -# when pear installed alone, after us -%triggerin -- %{?scl_prefix}php-pear -if [ -x %{__pecl} ] ; then - %{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || : -fi - -# posttrans as pear can be installed after us -%posttrans -if [ -x %{__pecl} ] ; then - %{pecl_install} %{pecl_xmldir}/%{name}.xml >/dev/null || : -fi - -%postun -if [ $1 -eq 0 -a -x %{__pecl} ] ; then - %{pecl_uninstall} %{pecl_name} >/dev/null || : -fi -%endif - - %check cd %{sources} @@ -186,7 +157,7 @@ REPORT_EXIT_STATUS=1 \ %files -%{?_licensedir:%license %{sources}/LICENSE} +%license %{sources}/LICENSE %doc %{pecl_docdir}/%{pecl_name} %{pecl_xmldir}/%{name}.xml @@ -200,6 +171,10 @@ REPORT_EXIT_STATUS=1 \ %changelog +* Tue Jul 9 2024 Remi Collet - 2.0.7-10 +- add patch for PHP 8.4 from + https://github.com/php/pecl-web_services-oauth/pull/30 + * Wed Aug 30 2023 Remi Collet - 2.0.7-9 - rebuild for PHP 8.3.0RC1 -- cgit