summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlly Betts <olly@survex.com>2023-04-14 17:38:01 +1200
committerOlly Betts <olly@survex.com>2023-04-14 17:38:01 +1200
commite3b112c69ceed5c39cb07fa45a3ba62b27712679 (patch)
treec7c771a2b1d09862632facdf01ae10a05e2d61a4
parent33f6a2d0b2c3d90b928f56ddfa599afe87903f76 (diff)
downloadswig-e3b112c69ceed5c39cb07fa45a3ba62b27712679.tar.gz
Remove support for PHP7
PHP7 security support ended 2022-11-28 so it doesn't make sense to include support for it in the SWIG 4.2.x release series.
-rw-r--r--.github/workflows/ci.yml10
-rw-r--r--CHANGES.current7
-rw-r--r--Doc/Manual/Php.html94
-rw-r--r--Doc/Manual/SWIG.html2
-rw-r--r--Examples/test-suite/php/default_args_runme.php17
-rw-r--r--Examples/test-suite/php/director_classes_runme.php8
-rw-r--r--Examples/test-suite/php/director_thread_runme.php2
-rw-r--r--Lib/php/const.i2
-rw-r--r--Lib/php/phprun.swg67
-rw-r--r--RELEASENOTES3
-rw-r--r--Source/Modules/php.cxx5
-rw-r--r--Source/Modules/swigmain.cxx2
-rw-r--r--configure.ac10
13 files changed, 56 insertions, 173 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 35c6d31cb..5b09dba7d 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -108,16 +108,6 @@ jobs:
CPPSTD: c++11
- SWIGLANG: perl5
- SWIGLANG: php
- VER: '7.0'
- - SWIGLANG: php
- VER: '7.1'
- - SWIGLANG: php
- VER: '7.2'
- - SWIGLANG: php
- VER: '7.3'
- - SWIGLANG: php
- VER: '7.4'
- - SWIGLANG: php
VER: '8.0'
- SWIGLANG: php
VER: '8.1'
diff --git a/CHANGES.current b/CHANGES.current
index f7c95b320..e427e60f6 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -7,6 +7,13 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.2.0 (in progress)
===========================
+2023-04-14: olly
+ [PHP7] Support for PHP7 has been removed. PHP7 security support
+ ended 2022-11-28 so it doesn't make sense to include support for
+ it in the SWIG 4.2.x release series.
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
2023-03-25: alatina
[Octave] #2512 Add support for Octave 8.1.
diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html
index fad7f6a2f..815d99dce 100644
--- a/Doc/Manual/Php.html
+++ b/Doc/Manual/Php.html
@@ -51,12 +51,13 @@
<p>
-In this chapter, we discuss SWIG's support of PHP. Currently any PHP7 or PHP8
+In this chapter, we discuss SWIG's support of PHP. Currently any PHP8
release should work.
</p>
<p>
-Support for PHP7 was added in SWIG 3.0.11 and for PHP8 in 4.1.0.
+Support for PHP8 was added in SWIG 4.1.0.
+Support for PHP7 was added in SWIG 3.0.11 and removed in 4.2.0.
Support for PHP5 was removed in SWIG 4.0.0 and support for PHP4 was removed in
SWIG 1.3.37. There never was a PHP6 release.
</p>
@@ -76,13 +77,14 @@ available.
<p>
-To build a PHP extension, run swig using the <tt>-php7</tt> option as follows
-(<tt>-php</tt> is also supported and currently is an alias for <tt>-php7</tt>
-but prior to SWIG 4.0.0 it was an alias for <tt>-php5</tt>):
+To build a PHP extension, run swig using the <tt>-php</tt> option
+(you can also use <tt>-php7</tt> - PHP7 and PHP8 have a largely compatible C
+extension API, hence the same option name has been used for both). For
+example:
</p>
<div class="code"><pre>
-swig -php7 example.i
+swig -php example.i
</pre></div>
<p>
@@ -146,9 +148,9 @@ least work for Linux though):
<p>
To test the extension from a PHP script, you first need to tell PHP to
-load it. Assuming you're using PHP 7.2 or higher, the recommended (and
-simplest!) way to do this is to copy it to PHP's default extension directory
-and add a line like this to the <tt>[PHP]</tt> section of <tt>php.ini</tt>:
+load it. The recommended (and simplest!) way to do this is to copy it to
+PHP's default extension directory and add a line like this to the
+<tt>[PHP]</tt> section of <tt>php.ini</tt>:
</p>
<div class="code"><pre>
@@ -156,10 +158,9 @@ and add a line like this to the <tt>[PHP]</tt> section of <tt>php.ini</tt>:
</pre></div>
<p>
-PHP &lt; 7.2 doesn't support loading by just the module name, so you need
-to specify the filename of the module to be specified, which varies
-between platforms. And for any PHP version, if the module is not in PHP's
-default extension directory, you also need to specify the path, for example:
+If the module is not in PHP's default extension directory, you also need to
+specify the path, in which case you'll also need to deal with platform-specific
+naming - for example, on Linux:
</p>
<div class="code"><pre>
@@ -167,6 +168,14 @@ default extension directory, you also need to specify the path, for example:
</pre></div>
<p>
+but on Microsoft Windows you'd need to use:
+</p>
+
+<div class="code"><pre>
+ extension=/path/to/php_modulename.dll
+</pre></div>
+
+<p>
If you're using the PHP CLI SAPI it's possible (but not recommended) to use the
<a href="https://www.php.net/manual/en/function.dl.php">dl() function</a> to
load an extension at run time, by adding a line like this to the start of each
@@ -174,15 +183,17 @@ PHP script which uses your extension:
</p>
<div class="code"><pre>
- dl("/path/to/modulename.so"); // Load the module
+ dl("modulename"); // Load the module
</pre></div>
<p>
-But to do this portably you need to take into account that pathnames and the
-filename extension vary by platform, and for security reasons PHP no longer
-supports <tt>dl()</tt> when running PHP through a webserver. Overall it's
-better to instead use <tt>extension</tt> in <tt>php.ini</tt> as described
-above.
+Again, if the module isn't in PHP's default extension directory you'll also
+need to specify the path and deal with that varying by platform.
+</p>
+
+<p>
+For security reasons PHP no longer supports <tt>dl()</tt> when running PHP
+through a webserver, so this isn't an option there.
</p>
<H2><a name="Php_nn2">32.2 Basic PHP interface</a></H2>
@@ -227,47 +238,6 @@ echo "E = " . E . "\n";
</pre>
</div>
-<p>
-There's one peculiarity of how constants work in PHP prior to PHP 8
-which it is useful to note (this is not specific to SWIG though) - if you try
-to use an undeclared constant, PHP will emit a warning (or a notice in PHP 7.1
-and earlier) and then expand the constant to a string version of the constant's
-name. Unfortunately it is easy to miss the warning message if you're using PHP
-in a webserver as it will probably end up in error.log or similar. PHP 8.0
-made this an error.
-</p>
-
-<p>
-For example,
-</p>
-
-<div class="code"><pre>
-%module example
-
-#define EASY_TO_MISPELL 0
-</pre>
-</div>
-
-<p>
-accessed incorrectly in PHP,
-</p>
-
-<div class="code">
-<pre>
-if(EASY_TO_MISPEL) {
- ...
-} else {
- ...
-}
-
-</pre>
-</div>
-
-<p>
-The mis-spelled constant will become the string 'EASY_TO_MISPEL', which
-is treated as true by the if test, when the value of the intended constant
-would be treated as false!
-</p>
<H3><a name="Php_nn2_2">32.2.2 Global Variables</a></H3>
@@ -346,9 +316,7 @@ $c = bar(3.5); # Use default argument for 2nd parameter
<p>
SWIG generates PHP type declarations for function parameters and return
-types for PHP 8 and later (we don't try to support PHP 7's more limited type
-declarations and the generated wrappers compiled for PHP 7 will not have any
-type declarations).
+types for PHP 8 and later.
</p>
<p>
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index 3fb41e522..cc01d9e6c 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -128,7 +128,7 @@ Supported Target Language Options
-lua - Generate Lua wrappers
-octave - Generate Octave wrappers
-perl5 - Generate Perl 5 wrappers
- -php7 - Generate PHP 7 or later wrappers
+ -php7 - Generate PHP 8 or later wrappers
-python - Generate Python wrappers
-r - Generate R (aka GNU S) wrappers
-ruby - Generate Ruby wrappers
diff --git a/Examples/test-suite/php/default_args_runme.php b/Examples/test-suite/php/default_args_runme.php
index 59350644f..31cbe0ff4 100644
--- a/Examples/test-suite/php/default_args_runme.php
+++ b/Examples/test-suite/php/default_args_runme.php
@@ -42,19 +42,6 @@ check::equal($f->double_if_void_ptr_is_null(6, Null), 12, "\$f->double_if_void_p
check::equal($f->double_if_void_ptr_is_null(7), 14, "\$f->double_if_void_ptr_is_null(7)");
-# For the testcases below, PHP 7 emits an error, while PHP 8 throws an
-# exception. To simplify the testcases we install an error handler function
-# for PHP7 which throws an ArgumentCountError exception (which we have to
-# define ourselves for PHP 7.0).
-
-if (PHP_MAJOR_VERSION == 7) {
- if (PHP_MINOR_VERSION == 0) {
- # ArgumentCountError was added in PHP 7.1.
- class ArgumentCountError extends Error {}
- }
- $old_error_handler = set_error_handler(function($n,$s,$f,$l){throw preg_match('/^Wrong parameter count/', $s) ? new ArgumentCountError($s) : new Error($s);});
-}
-
try {
$f = new Foo(1);
check::fail("Foo::Foo ignore is not working");
@@ -91,10 +78,6 @@ try {
} catch (Error $e) {
}
-if (PHP_MAJOR_VERSION == 7) {
- set_error_handler($old_error_handler);
-}
-
check::equal(Klass::inc(100, new Klass(22))->val, 122, "Klass::inc failed");
check::equal(klass::inc(100)->val, 99, "klass::inc failed");
diff --git a/Examples/test-suite/php/director_classes_runme.php b/Examples/test-suite/php/director_classes_runme.php
index d187ed82e..937d0db3f 100644
--- a/Examples/test-suite/php/director_classes_runme.php
+++ b/Examples/test-suite/php/director_classes_runme.php
@@ -41,12 +41,8 @@ if (PHP_MAJOR_VERSION < 8) {
class PHPDerived extends Base {
function Val(DoubleHolder $x) { return $x; }
function Ref(DoubleHolder $x) { return $x; }
- // PHP 7.0 fails to parse the `?` - revert once we drop 7.0 support:
- // function Ptr(?DoubleHolder $x) { return $x; }
- function Ptr($x) { return $x; }
- // PHP 7.0 fails to parse the `?` - revert once we drop 7.0 support:
- // function ConstPtrRef(?DoubleHolder $x) { return $x; }
- function ConstPtrRef($x) { return $x; }
+ function Ptr(?DoubleHolder $x) { return $x; }
+ function ConstPtrRef(?DoubleHolder $x) { return $x; }
function FullyOverloaded($x) {
$rv = parent::FullyOverloaded($x);
$rv = preg_replace('/Base/', 'PHPDerived', $rv);
diff --git a/Examples/test-suite/php/director_thread_runme.php b/Examples/test-suite/php/director_thread_runme.php
index 190dbad71..e4eb3684a 100644
--- a/Examples/test-suite/php/director_thread_runme.php
+++ b/Examples/test-suite/php/director_thread_runme.php
@@ -3,7 +3,7 @@
require "tests.php";
# Fails in a ZTS-build of PHP5 - see: https://github.com/swig/swig/pull/155
-# FIXME: Does this still fail in a threaded build of PHP7?
+# FIXME: Does this still fail in a threaded build of PHP8?
exit(0);
// New functions
diff --git a/Lib/php/const.i b/Lib/php/const.i
index a74af0d78..1e1fe9cad 100644
--- a/Lib/php/const.i
+++ b/Lib/php/const.i
@@ -95,7 +95,7 @@
SWIG_SetPointerZval(&c.value, (void*)($value), $1_descriptor, 0);
zval_copy_ctor(&c.value);
c.name = zend_string_init("$symname", sizeof("$symname") - 1, 0);
- SWIG_ZEND_CONSTANT_SET_FLAGS(&c, CONST_CS, module_number);
+ ZEND_CONSTANT_SET_FLAGS(&c, CONST_CS, module_number);
zend_register_constant(&c);
}
diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg
index d3ad0d26a..588701f9b 100644
--- a/Lib/php/phprun.swg
+++ b/Lib/php/phprun.swg
@@ -10,35 +10,14 @@
extern "C" {
#endif
-#if PHP_MAJOR_VERSION < 7
-# error These bindings need PHP 7 or later - to generate PHP5 bindings use: SWIG < 4.0.0 and swig -php5
+#if PHP_MAJOR_VERSION < 8
+# error These bindings need PHP 8 or later - to generate PHP7 bindings use SWIG < 4.1.0; to generate PHP5 bindings use: SWIG < 4.0.0 and swig -php5
#endif
#include "zend_inheritance.h"
#include "zend_exceptions.h"
#include "zend_inheritance.h"
-#if PHP_MAJOR_VERSION == 7
-/* These macros were new in PHP 8.0. For PHP 7.x we define them to give the
- * same result except without any type declarations. PHP 7.x supports type
- * declarations, but not for the return type, and alternate types aren't
- * supported, so we don't try to support these.
- */
-# define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(name, byref, num_req, classes, types) \
- ZEND_BEGIN_ARG_INFO_EX(name, 0, byref, num_req)
-# define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(name, byref, num_req, types) \
- ZEND_BEGIN_ARG_INFO_EX(name, 0, byref, num_req)
-
-/* NB We can just ignore `default` here we currently always pass NULL for it
- * (this mechanism for specifying default parameter values was new in PHP 8.0
- * so it's not useful while we still want to support PHP7 too).
- */
-# define ZEND_ARG_OBJ_TYPE_MASK(byref, name, classes, types, default) \
- ZEND_ARG_INFO(byref, name)
-# define ZEND_ARG_TYPE_MASK(byref, name, types, default) \
- ZEND_ARG_INFO(byref, name)
-#endif
-
#include <stdlib.h> /* for abort(), used in generated code. */
#define SWIG_BOOL_CONSTANT(N, V) REGISTER_BOOL_CONSTANT(#N, V, CONST_CS | CONST_PERSISTENT)
@@ -50,27 +29,6 @@ extern "C" {
REGISTER_STRINGL_CONSTANT(#N, &swig_char, 1, CONST_CS | CONST_PERSISTENT);\
} while (0)
-/* ZEND_CONSTANT_SET_FLAGS was new in PHP 7.3. */
-#ifdef ZEND_CONSTANT_SET_FLAGS
-# define SWIG_ZEND_CONSTANT_SET_FLAGS ZEND_CONSTANT_SET_FLAGS
-#else
-# define SWIG_ZEND_CONSTANT_SET_FLAGS(C, F, N) do { (C)->flags = (F); (C)->module_number = (N); } while (0)
-#endif
-
-/* zend_object_alloc was new in PHP 7.3. */
-#if PHP_MAJOR_VERSION == 7 && PHP_MINOR_VERSION < 3
-static zend_always_inline void *zend_object_alloc(size_t obj_size, zend_class_entry *ce) {
- void *obj = emalloc(obj_size + zend_object_properties_size(ce));
- memset(obj, 0, obj_size - sizeof(zval));
- return obj;
-}
-#endif
-
-/* ZEND_THIS was new in PHP 7.4. */
-#ifndef ZEND_THIS
-# define ZEND_THIS &EX(This)
-#endif
-
#ifdef __cplusplus
}
#endif
@@ -93,27 +51,6 @@ static int default_error_code = E_ERROR;
static zend_class_entry SWIG_Php_swig_wrapped_interface_ce;
-#if PHP_MAJOR_VERSION == 7
-/* zend_class_implements_interface() was new in PHP 8.0.
- *
- * We could use instanceof_function_ex(C, I, 1) here for 7.4, but for 7.3
- * and earlier that doesn't work, so instead we just provide a compatibility
- * implementation which does what zend_class_implements_interface() does in 8.x
- * and use that for all 7.x so there are fewer variants to worry about testing.
- */
-static int zend_class_implements_interface(const zend_class_entry *class_ce, const zend_class_entry *interface_ce) {
- uint32_t i;
- if (class_ce->num_interfaces) {
- for (i = 0; i < class_ce->num_interfaces; i++) {
- if (class_ce->interfaces[i] == interface_ce) {
- return 1;
- }
- }
- }
- return 0;
-}
-#endif
-
/* used to wrap returned objects in so we know whether they are newobject
and need freeing, or not */
typedef struct {
diff --git a/RELEASENOTES b/RELEASENOTES
index 493f19954..300e79c09 100644
--- a/RELEASENOTES
+++ b/RELEASENOTES
@@ -7,6 +7,9 @@ Release Notes
Detailed release notes are available with the release and are also
published on the SWIG web site at https://swig.org/release.html.
+SWIG-4.2.0 summary:
+- PHP7 support removed, PHP8 is now the supported PHP version.
+
SWIG-4.1.1 summary:
- Couple of stability fixes.
- Stability fix in ccache-swig when calculating hashes of inputs.
diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
index c8cc9212b..6f326c15b 100644
--- a/Source/Modules/php.cxx
+++ b/Source/Modules/php.cxx
@@ -784,8 +784,9 @@ public:
Printf(s_init, "#ifdef __cplusplus\n");
Printf(s_init, "extern \"C\" {\n");
Printf(s_init, "#endif\n");
- // We want to write "SWIGEXPORT ZEND_GET_MODULE(%s)" but ZEND_GET_MODULE
- // in PHP7 has "extern "C" { ... }" around it so we can't do that.
+ // We want to write "SWIGEXPORT ZEND_GET_MODULE(%s)" but the definition
+ // of ZEND_GET_MODULE has "extern "C" { ... }" around it so we can't do
+ // that.
Printf(s_init, "SWIGEXPORT zend_module_entry *get_module(void) { return &%s_module_entry; }\n", module);
Printf(s_init, "#ifdef __cplusplus\n");
Printf(s_init, "}\n");
diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx
index d553fe893..1d1b2946c 100644
--- a/Source/Modules/swigmain.cxx
+++ b/Source/Modules/swigmain.cxx
@@ -70,7 +70,7 @@ static TargetLanguageModule modules[] = {
{"-perl5", swig_perl5, "Perl 5", Supported},
{"-php", swig_php, NULL, Supported},
{"-php5", NULL, "PHP 5", Disabled},
- {"-php7", swig_php, "PHP 7 or later", Supported},
+ {"-php7", swig_php, "PHP 8 or later", Supported},
{"-pike", NULL, "Pike", Disabled},
{"-python", swig_python, "Python", Supported},
{"-r", swig_r, "R (aka GNU S)", Supported},
diff --git a/configure.ac b/configure.ac
index 830214a74..c0f57571f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1851,17 +1851,15 @@ if test x"${PHPBIN}" = xno; then
PHP=
else
if test "x$PHPBIN" = xyes; then
- AC_CHECK_PROGS(PHP, [php8.2 php8.1 php8.0 php7.4 php7.3 php7.2 php7.1 php7.0 php])
+ AC_CHECK_PROGS(PHP, [php8.2 php8.1 php8.0 php])
else
PHP=$PHPBIN
fi
if test -n "$PHP"; then
AC_MSG_CHECKING(for PHP header files)
- dnl /usr/bin/php7.0 -> /usr/bin/php-config7.0
+ dnl /usr/bin/php8.0 -> /usr/bin/php-config8.0
case $PHP in
- *7.*)
- PHPCONFIG=`echo "$PHP"|sed 's/7\...*$/-config&/'` ;;
*8.*)
PHPCONFIG=`echo "$PHP"|sed 's/8\...*$/-config&/'` ;;
*)
@@ -1869,7 +1867,7 @@ else
esac
php_version=`$PHPCONFIG --version 2>/dev/null`
case $php_version in
- 7.*|8.*)
+ 8.*)
PHPINC=`$PHPCONFIG --includes 2>/dev/null`
if test -n "$PHPINC"; then
AC_MSG_RESULT($PHPINC)
@@ -1880,7 +1878,7 @@ else
"")
AC_MSG_RESULT([could not find $PHPCONFIG or obtain PHP version from it]) ;;
*)
- AC_MSG_RESULT([found PHP $php_version - not PHP 7 or 8]) ;;
+ AC_MSG_RESULT([found PHP $php_version - not PHP 8]) ;;
esac
fi
fi