git: a8592eb7375e - main - textproc/php81-xml: fix compatibility with libxml2>=2.13

From: Dima Panov <fluffy_at_FreeBSD.org>
Date: Mon, 27 Oct 2025 21:17:58 UTC
The branch main has been updated by fluffy:

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

commit a8592eb7375ea088a96051ad62e46af739f23331
Author:     Dima Panov <fluffy@FreeBSD.org>
AuthorDate: 2025-10-27 21:16:07 +0000
Commit:     Dima Panov <fluffy@FreeBSD.org>
CommitDate: 2025-10-27 21:17:53 +0000

    textproc/php81-xml: fix compatibility with libxml2>=2.13
    
    Fix compatibility issue with libxml2>=2.13 which caused parse error
    on some XML files so that devel/pear work again with php81.
    
    See https://github.com/php/php-src/issues/14834 for details.
    
    Approved by:    portmgr blanket (backport trivial fix from upstream)
---
 textproc/php81-xml/Makefile             |  1 +
 textproc/php81-xml/files/patch-compat.c | 19 +++++++++++++++----
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/textproc/php81-xml/Makefile b/textproc/php81-xml/Makefile
index 6baacc4611cc..0800edeb41eb 100644
--- a/textproc/php81-xml/Makefile
+++ b/textproc/php81-xml/Makefile
@@ -1,3 +1,4 @@
+PORTREVISION=	1
 CATEGORIES=	textproc
 
 MASTERDIR=	${.CURDIR}/../../lang/php81
diff --git a/textproc/php81-xml/files/patch-compat.c b/textproc/php81-xml/files/patch-compat.c
index 02125961b20c..af608e129191 100644
--- a/textproc/php81-xml/files/patch-compat.c
+++ b/textproc/php81-xml/files/patch-compat.c
@@ -1,6 +1,6 @@
---- compat.c.orig	Tue Jul 20 10:55:02 2004
-+++ compat.c	Tue Jul 20 10:55:55 2004
-@@ -16,6 +16,10 @@
+--- compat.c.orig	2025-07-01 21:17:52 UTC
++++ compat.c
+@@ -14,6 +14,10 @@
     +----------------------------------------------------------------------+
   */
  
@@ -9,5 +9,16 @@
 +#endif
 +
  #include "php.h"
- #if defined(HAVE_LIBXML) && defined(HAVE_XML) && !defined(HAVE_LIBEXPAT)
+ #if defined(HAVE_LIBXML) && (defined(HAVE_XML) || defined(HAVE_XMLRPC)) && !defined(HAVE_LIBEXPAT)
  #include "expat_compat.h"
+@@ -375,7 +379,9 @@ _get_entity(void *user, const xmlChar *name)
+ 		if (ret == NULL)
+ 			ret = xmlGetDocEntity(parser->parser->myDoc, name);
+ 
+-		if (ret == NULL || (parser->parser->instate != XML_PARSER_ENTITY_VALUE && parser->parser->instate != XML_PARSER_ATTRIBUTE_VALUE)) {
++/* Fix parse error on some XML files so that devel/pear work again. */
++/* See https://github.com/php/php-src/issues/14834 for details. */
++		if (ret == NULL || parser->parser->instate == XML_PARSER_CONTENT) {
+ 			if (ret == NULL || ret->etype == XML_INTERNAL_GENERAL_ENTITY || ret->etype == XML_INTERNAL_PARAMETER_ENTITY || ret->etype == XML_INTERNAL_PREDEFINED_ENTITY) {
+ 				/* Predefined entities will expand unless no cdata handler is present */
+ 				if (parser->h_default && ! (ret && ret->etype == XML_INTERNAL_PREDEFINED_ENTITY && parser->h_cdata)) {