git: c5e0b8b2123e - main - security/pecl-pkcs11: Fix build with PHP 8.1

From: Po-Chuan Hsieh <sunpoet_at_FreeBSD.org>
Date: Fri, 28 Jan 2022 23:28:19 UTC
The branch main has been updated by sunpoet:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c5e0b8b2123e07c969f1807d45e850af7985ac87

commit c5e0b8b2123e07c969f1807d45e850af7985ac87
Author:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
AuthorDate: 2022-01-28 23:19:14 +0000
Commit:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
CommitDate: 2022-01-28 23:26:43 +0000

    security/pecl-pkcs11: Fix build with PHP 8.1
    
    Obtained from:  https://github.com/gamringer/php-pkcs11/commit/0df4a939a65137ef9002077cad4e6dab8c58c6cc
---
 security/pecl-pkcs11/Makefile          |  2 --
 security/pecl-pkcs11/files/patch-php81 | 46 ++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/security/pecl-pkcs11/Makefile b/security/pecl-pkcs11/Makefile
index fd82b25a97d7..936b9386da86 100644
--- a/security/pecl-pkcs11/Makefile
+++ b/security/pecl-pkcs11/Makefile
@@ -12,6 +12,4 @@ LICENSE_FILE=	${WRKSRC}/LICENSE
 
 USES=		localbase php:pecl
 
-IGNORE_WITH_PHP=81
-
 .include <bsd.port.mk>
diff --git a/security/pecl-pkcs11/files/patch-php81 b/security/pecl-pkcs11/files/patch-php81
new file mode 100644
index 000000000000..c09ad9077ecd
--- /dev/null
+++ b/security/pecl-pkcs11/files/patch-php81
@@ -0,0 +1,46 @@
+Obtained from:	https://github.com/gamringer/php-pkcs11/commit/0df4a939a65137ef9002077cad4e6dab8c58c6cc
+
+--- pkcs11int.h.orig	2021-03-23 21:45:06 UTC
++++ pkcs11int.h
+@@ -192,6 +192,19 @@ DECLARE_MAGIC_FUNCS(pkcs11_digestcontext,             
+ DECLARE_MAGIC_FUNCS(pkcs11_encryptioncontext,             EncryptionContext)
+ DECLARE_MAGIC_FUNCS(pkcs11_decryptioncontext,             DecryptionContext)
+ 
++#if PHP_VERSION_ID < 80100
++
++#define PKCS11_ACC_NOT_SERIALIZABLE(ce) \
++    ce->serialize = zend_class_serialize_deny; \
++    ce->unserialize = zend_class_unserialize_deny;
++
++#else
++
++#define PKCS11_ACC_NOT_SERIALIZABLE(ce) \
++    ce->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
++
++#endif
++
+ #define DEFINE_MAGIC_FUNCS(tt, lowername, classname)                            \
+ static zend_object *tt##_ctor(zend_class_entry *ce) {                           \
+     tt##_object *objval = zend_object_alloc(sizeof(tt##_object), ce);           \
+@@ -216,8 +229,7 @@ void register_##tt() {                                
+     tt##_handlers.clone_obj = NULL;                                             \
+     tt##_handlers.free_obj = tt##_dtor;                                         \
+     ce_Pkcs11_##classname = zend_register_internal_class(&ce);                  \
+-    ce_Pkcs11_##classname->serialize = zend_class_serialize_deny;               \
+-    ce_Pkcs11_##classname->unserialize = zend_class_unserialize_deny;           \
++    PKCS11_ACC_NOT_SERIALIZABLE(ce_Pkcs11_##classname);                         \
+ }
+ 
+ 
+--- pkcs11key.c.orig	2021-03-23 21:45:06 UTC
++++ pkcs11key.c
+@@ -612,6 +612,5 @@ void register_pkcs11_key() {
+     pkcs11_key_handlers.offset = XtOffsetOf(pkcs11_key_object, std);
+     pkcs11_key_handlers.clone_obj = NULL;
+     ce_Pkcs11_Key = zend_register_internal_class_ex(&ce, ce_Pkcs11_P11Object);
+-    ce_Pkcs11_Key->serialize = zend_class_serialize_deny;
+-    ce_Pkcs11_Key->unserialize = zend_class_unserialize_deny;
+-}
+\ No newline at end of file
++    PKCS11_ACC_NOT_SERIALIZABLE(ce_Pkcs11_Key);
++}