View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0000622 | Redland Language Bindings | installation | public | 2017-06-13 22:33 | 2017-06-13 22:33 |
| Reporter | ppisar | Assigned To | |||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | new | Resolution | open | ||
| Product Version | 1.0.16.1 | ||||
| Summary | 0000622: Fails to buld with PHP 7 | ||||
| Description | After upgrading PHP to 7.1.6, the build fails with: gcc -DHAVE_CONFIG_H -I. -DREDLAND_POST_I -DREDLAND_INIT_I -DREDLAND_DECL_I -DREDLAND_TYPE MAP_I -UHAVE_CONFIG_H -I/usr/include/raptor2 -I/usr/include/rasqal -I/usr/include/php - I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ ext -I/usr/include/php/ext/date/lib -DREDLAND_BINDINGS_VERSION=\"1.0.16.1\" -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-stron g --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-harden ed-cc1 -m64 -mtune=generic -I/usr/include/raptor2 -I/usr/include/rasqal -O2 -g -pipe -W all -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened -cc1 -m64 -mtune=generic -fPIC -DPIC redland_wrap.c -c -o redland_wrap.o redland_wrap.c:730:3: error: #error These bindings need PHP5 - to generate PHP7 bindings use: swig -php7 # error These bindings need PHP5 - to generate PHP7 bindings use: swig -php7 ^~~~~ After patching configure.ac to invoke swig with -php7 option, it will fail due to changes in PHP Zend API. A possible fix is attached. It builds, tests pass, but because I have zero knowledge about PHP, it's possible it contains some mistakes. It definitely breaks compatibility with PHP 5. | ||||
| Tags | No tags attached. | ||||
| Binding Language (java, perl, php, python, ruby, tcl) | php | ||||
|
|
redland-bindings-1.0.16.1-Add-PHP-7-support.patch (3,176 bytes)
From ccd93f6c71f7e03485e75b13bc16caa6eb57782e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Tue, 13 Jun 2017 15:29:15 +0200
Subject: [PATCH] Add PHP 7 support
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The "#if PHP_MAJOR_VERSION < 7" condition does not work in .i files
for me. So it breaks support for PHP 5 and older.
I think proper fix needs more understanding to this PHP change
<https://nikic.github.io/2015/05/05/Internal-value-representation-in-PHP-7-part-1.html>.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
configure.ac | 4 +++-
php/redland-post.i | 7 +++++--
php/redland-typemap.i | 12 ++++++------
3 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/configure.ac b/configure.ac
index b285c3b..79bae9c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -165,7 +165,9 @@ if test "X$PHP_CONFIG" != X ; then
PHP_INCLUDES=`$PHP_CONFIG --includes`
PHP_EXTENSION_DIR=`$PHP_CONFIG --extension-dir`
- if test $PHP_VERSION '>' 5.0.0; then
+ if test $PHP_VERSION '>' 7; then
+ PHP_SWIG="-php7"
+ elif test $PHP_VERSION '>' 5.0.0; then
PHP_SWIG="-php5"
else
PHP_SWIG="-php4"
diff --git a/php/redland-post.i b/php/redland-post.i
index 2ab09dd..6b16e0a 100644
--- a/php/redland-post.i
+++ b/php/redland-post.i
@@ -132,8 +132,11 @@ librdf_php_world_init(void)
exception_ce = zend_exception_get_default();
INIT_CLASS_ENTRY(ee_ce, "RedlandException", NULL);
redland_exception_ptr = zend_register_internal_class_ex(&ee_ce,
- exception_ce,
- NULL TSRMLS_CC);
+ exception_ce
+#if PHP_MAJOR_VERSION < 7
+ ,NULL TSRMLS_CC
+#endif
+ );
#endif
memset(&librdf_php_locator, '\0', sizeof(raptor_locator));
diff --git a/php/redland-typemap.i b/php/redland-typemap.i
index 3b97818..717878a 100644
--- a/php/redland-typemap.i
+++ b/php/redland-typemap.i
@@ -1,17 +1,17 @@
-%typemap(in) librdf_uri* %{
- if(SWIG_ConvertPtr(*$input, (void **) &$1, SWIGTYPE_p_librdf_uri_s, 0) < 0) {
+%typemap(in) librdf_uri %{
+ if(SWIG_ConvertPtr($input, (void **) &$1, SWIGTYPE_p_librdf_uri_s, 0) < 0) {
/* Allow NULL from php for librdf_uri* */
- if ((*$input)->type==IS_NULL)
+ if ($input->type==IS_NULL)
$1=NULL;
else
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor");
}
%}
-%typemap(in) librdf_node* %{
- if(SWIG_ConvertPtr(*$input, (void **) &$1, SWIGTYPE_p_librdf_node_s, 0) < 0) {
+%typemap(in) librdf_node %{
+ if(SWIG_ConvertPtr($input, (void **) &$1, SWIGTYPE_p_librdf_node_s, 0) < 0) {
/* Allow NULL from php for librdf_node* */
- if ((*$input)->type==IS_NULL)
+ if ($input->type==IS_NULL)
$1=NULL;
else
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $1_descriptor");
--
2.9.4
|