summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2020-09-23 14:41:30 +0200
committerRemi Collet <remi@remirepo.net>2020-09-23 14:41:30 +0200
commitcc6ee5f4ee0f1cd632fd6f612c3df5205fd051e3 (patch)
treeaf669003a766617076b13554bfffdf53ae70721b
parent809c98531e98028fdc989e907ba0bb38d12d2a7e (diff)
add patch for PHP 8 from
https://github.com/laruence/yac/pull/115
-rw-r--r--.gitignore2
-rw-r--r--115.patch107
-rw-r--r--php-pecl-yac.spec30
3 files changed, 128 insertions, 11 deletions
diff --git a/.gitignore b/.gitignore
index 1ab5c4f..01f0400 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
+clog
package-*.xml
*.tgz
+*.tar.bz2
*.tar.gz
*.tar.xz
*.tar.xz.asc
diff --git a/115.patch b/115.patch
new file mode 100644
index 0000000..e83a27f
--- /dev/null
+++ b/115.patch
@@ -0,0 +1,107 @@
+From 619c2b4fb4839502c88317b3e39221647fd16d2a Mon Sep 17 00:00:00 2001
+From: Remi Collet <remi@remirepo.net>
+Date: Wed, 23 Sep 2020 14:26:16 +0200
+Subject: [PATCH] Fix compatibility with PHP 8
+
+---
+ tests/021.phpt | 8 ++++++--
+ tests/022.phpt | 2 +-
+ yac.c | 34 +++++++++++++++++++++++++++-------
+ 3 files changed, 34 insertions(+), 10 deletions(-)
+
+diff --git a/tests/021.phpt b/tests/021.phpt
+index f2f98cf..0f68258 100644
+--- a/tests/021.phpt
++++ b/tests/021.phpt
+@@ -13,8 +13,12 @@ $yac = new Yac("prefix");
+
+ $yac->value = "value";
+
+-/* can not used in writen context */
+-$yac->foo->bar = "bar";
++try {
++ /* can not used in writen context */
++ $yac->foo->bar = "bar";
++} catch (Error $e) {
++ /* expected exception on PHP 8 */
++}
+
+ var_dump($yac->get("value"));
+ var_dump($yac->value);
+diff --git a/tests/022.phpt b/tests/022.phpt
+index a34a4d2..487de28 100644
+--- a/tests/022.phpt
++++ b/tests/022.phpt
+@@ -17,5 +17,5 @@ var_dump($yac);
+ --EXPECTF--
+ string(18) "Yac is not enabled"
+
+-Notice: Undefined variable: yac in %s022.php on line %d
++%s: Undefined variable%syac in %s022.php on line %d
+ NULL
+diff --git a/yac.c b/yac.c
+index 2e961f7..408e694 100644
+--- a/yac.c
++++ b/yac.c
+@@ -504,17 +504,27 @@ static void yac_object_free(zend_object *object) /* {{{ */ {
+ }
+ /* }}} */
+
+-static zval* yac_read_property_ptr(zval *zobj, zval *name, int type, void **cache_slot) /* {{{ */ {
++#if PHP_VERSION_ID < 80000
++static zval* yac_read_property_ptr(zval *zobj, zval *zname, int type, void **cache_slot) /* {{{ */ {
++#else
++static zval* yac_read_property_ptr(zend_object *obj, zend_string *name, int type, void **cache_slot) /* {{{ */ {
++#endif
+ return &EG(error_zval);
+ }
+ /* }}} */
+
+-static zval* yac_read_property(zval *zobj, zval *name, int type, void **cache_slot, zval *rv) /* {{{ */ {
++#if PHP_VERSION_ID < 80000
++static zval* yac_read_property(zval *zobj, zval *zname, int type, void **cache_slot, zval *rv) /* {{{ */ {
++ zend_object *obj = Z_OBJ_P(zobj);
++ zend_string *name = Z_STR_P(zname);
++#else
++static zval* yac_read_property(zend_object *obj, zend_string *name, int type, void **cache_slot, zval *rv) /* {{{ */ {
++#endif
+ if (UNEXPECTED(type == BP_VAR_RW||type == BP_VAR_W)) {
+ return &EG(error_zval);
+ }
+
+- if (yac_get_impl(Z_YACOBJ_P(zobj), Z_STR_P(name), NULL, rv)) {
++ if (yac_get_impl(php_yac_fetch_object(obj), name, NULL, rv)) {
+ return rv;
+ }
+
+@@ -522,16 +532,26 @@ static zval* yac_read_property(zval *zobj, zval *name, int type, void **cache_sl
+ }
+ /* }}} */
+
+-static YAC_WHANDLER yac_write_property(zval *zobj, zval *name, zval *value, void **cache_slot) /* {{{ */ {
+- yac_add_impl(Z_YACOBJ_P(zobj), Z_STR_P(name), value, 0, 0);
++#if PHP_VERSION_ID < 80000
++static YAC_WHANDLER yac_write_property(zval *zobj, zval *zname, zval *value, void **cache_slot) /* {{{ */ {
++ yac_add_impl(Z_YACOBJ_P(zobj), Z_STR_P(zname), value, 0, 0);
++#else
++static YAC_WHANDLER yac_write_property(zend_object *obj, zend_string *name, zval *value, void **cache_slot) /* {{{ */ {
++ yac_add_impl(php_yac_fetch_object(obj), name, value, 0, 0);
++#endif
+ Z_TRY_ADDREF_P(value);
+
+ YAC_WHANDLER_RET(value);
+ }
+ /* }}} */
+
+-static void yac_unset_property(zval *zobj, zval *name, void **cache_slot) /* {{{ */ {
+- yac_delete_impl(Z_YACOBJ_P(zobj), Z_STR_P(name), 0);
++#if PHP_VERSION_ID < 80000
++static void yac_unset_property(zval *zobj, zval *zname, void **cache_slot) /* {{{ */ {
++ yac_delete_impl(Z_YACOBJ_P(zobj), Z_STR_P(zname), 0);
++#else
++static void yac_unset_property(zend_object *obj, zend_string *name, void **cache_slot) /* {{{ */ {
++ yac_delete_impl(php_yac_fetch_object(obj), name, 0);
++#endif
+ }
+ /* }}} */
+
diff --git a/php-pecl-yac.spec b/php-pecl-yac.spec
index 367de44..c42c72b 100644
--- a/php-pecl-yac.spec
+++ b/php-pecl-yac.spec
@@ -29,16 +29,17 @@
Summary: Lockless user data cache
Name: %{?sub_prefix}php-pecl-%{pecl_name}
Version: 2.2.1
+License: PHP
+URL: https://pecl.php.net/package/%{pecl_name}
%if 0%{?gh_date:1}
Release: 0.12.%{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: 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;')}}
Source0: https://pecl.php.net/get/%{pecl_name}-%{version}.tgz
%endif
-License: PHP
-URL: https://pecl.php.net/package/%{pecl_name}
+Patch0: https://patch-diff.githubusercontent.com/raw/laruence/yac/pull/115.patch
BuildRequires: %{?dtsprefix}gcc
BuildRequires: %{?scl_prefix}php-devel > 7
@@ -68,19 +69,16 @@ Provides: %{?scl_prefix}php-pecl-%{pecl_name} = %{version}-%{rele
Provides: %{?scl_prefix}php-pecl-%{pecl_name}%{?_isa} = %{version}-%{release}
%endif
-%if "%{?vendor}" == "Remi Collet" && 0%{!?scl:1} && 0%{?rhel}
+%if "%{?packager}" == "Remi Collet" && 0%{!?scl:1} && 0%{?rhel}
# Other third party repo stuff
-%if "%{php_version}" > "7.2"
-Obsoletes: php72u-pecl-%{pecl_name} <= %{version}
-Obsoletes: php72w-pecl-%{pecl_name} <= %{version}
-%endif
%if "%{php_version}" > "7.3"
Obsoletes: php73-pecl-%{pecl_name} <= %{version}
-Obsoletes: php73w-pecl-%{pecl_name} <= %{version}
%endif
%if "%{php_version}" > "7.4"
Obsoletes: php74-pecl-%{pecl_name} <= %{version}
-Obsoletes: php74w-pecl-%{pecl_name} <= %{version}
+%endif
+%if "%{php_version}" > "8.0"
+Obsoletes: php80-pecl-%{pecl_name} <= %{version}
%endif
%endif
@@ -119,6 +117,8 @@ sed -e 's/role="test"/role="src"/' \
-i package.xml
cd NTS
+%patch0 -p1 -b .pr115
+
%if %{with_fastlz}
sed -e '\:name="compressor/fastlz:d' -i ../package.xml
rm -r compressor/fastlz
@@ -204,7 +204,11 @@ done
%check
cd NTS
-OPTS="-n -d extension=json.so -d extension=igbinary.so -d extension=msgpack.so"
+OPTS="-n"
+[ -f %{php_extdir}/json.so ] && OPTS="$OPTS -d extension=json.so"
+[ -f %{php_extdir}/igbinary.so ] && OPTS="$OPTS -d extension=igbinary.so"
+[ -f %{php_extdir}/msgpack.so ] && OPTS="$OPTS -d extension=msgpack.so"
+
: Minimal load test for NTS extension
%{_bindir}/php $OPTS \
--define extension=%{buildroot}%{php_extdir}/%{pecl_name}.so \
@@ -277,6 +281,10 @@ fi
%changelog
+* Wed Sep 23 2020 Remi Collet <remi@remirepo.net> - 2.2.1-2
+- add patch for PHP 8 from
+ https://github.com/laruence/yac/pull/115
+
* Fri May 15 2020 Remi Collet <remi@remirepo.net> - 2.2.1-1
- update to 2.2.1