Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatible with PHP 8.4 #5462

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/framework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: [ '8.0', '8.1', '8.2', '8.3' ]
php-version: [ '8.0', '8.1', '8.2', '8.3', '8.4' ]
framework: [ 'Laravel Octane', 'Hyperf', 'Simps', 'imi' ]
name: ${{ matrix.framework }} - PHP ${{ matrix.php-version }}
steps:
Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php-version: [ '8.0', '8.1', '8.2', '8.3' ]
php-version: [ '8.0', '8.1', '8.2', '8.3', '8.4' ]
framework: [ 'Simps' ]
name: ${{ matrix.framework }} - PHP ${{ matrix.php-version }} - macOS
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['8.0', '8.1', '8.2', '8.3']
php: ['8.0', '8.1', '8.2', '8.3', '8.4-dev']
steps:
- uses: actions/checkout@v4
- name: Setup PHP
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/xdebug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['8.0', '8.1', '8.2', '8.3']
php: ['8.0', '8.1', '8.2', '8.3', '8.4-dev']

name: PHP ${{ matrix.php }} - Swoole

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PROJECT(libswoole)

ENABLE_LANGUAGE(ASM)
set(SWOOLE_VERSION 5.1.4)
set(SWOOLE_VERSION 5.1.5-dev)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -g")
Expand Down
29 changes: 24 additions & 5 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -1014,12 +1014,15 @@ EOF
swoole_source_file="$swoole_source_file \
thirdparty/php/curl/interface.cc \
thirdparty/php/curl/multi.cc \
thirdparty/php84/curl/interface.cc \
thirdparty/php84/curl/multi.cc \
thirdparty/php/sockets/multicast.cc \
thirdparty/php/sockets/sendrecvmsg.cc \
thirdparty/php/sockets/conversions.cc \
thirdparty/php/sockets/sockaddr_conv.cc \
thirdparty/php/standard/var_decoder.cc \
thirdparty/php/standard/proc_open.cc"
thirdparty/php/standard/proc_open.cc \
thirdparty/php84/hash/hash_sha.c "

swoole_source_file="$swoole_source_file \
thirdparty/swoole_http_parser.c \
Expand Down Expand Up @@ -1051,7 +1054,10 @@ EOF
thirdparty/php81/pdo_pgsql/pgsql_driver.c \
thirdparty/php81/pdo_pgsql/pgsql_statement.c \
thirdparty/php83/pdo_pgsql/pgsql_driver.c \
thirdparty/php83/pdo_pgsql/pgsql_statement.c"
thirdparty/php83/pdo_pgsql/pgsql_statement.c \
thirdparty/php84/pdo_pgsql/pgsql_driver.c \
thirdparty/php84/pdo_pgsql/pgsql_statement.c \
thirdparty/php84/pdo_pgsql/pgsql_sql_parser.c"
fi

if test "$PHP_SWOOLE_ORACLE" != "no"; then
Expand All @@ -1061,7 +1067,9 @@ EOF
thirdparty/php81/pdo_oci/oci_driver.c \
thirdparty/php81/pdo_oci/oci_statement.c \
thirdparty/php83/pdo_oci/oci_driver.c \
thirdparty/php83/pdo_oci/oci_statement.c"
thirdparty/php83/pdo_oci/oci_statement.c \
thirdparty/php84/pdo_oci/oci_driver.c \
thirdparty/php84/pdo_oci/oci_statement.c"
fi

if test "$PHP_SWOOLE_ODBC" != "no"; then
Expand All @@ -1071,7 +1079,9 @@ EOF
thirdparty/php81/pdo_odbc/odbc_driver.c \
thirdparty/php81/pdo_odbc/odbc_stmt.c \
thirdparty/php83/pdo_odbc/odbc_driver.c \
thirdparty/php83/pdo_odbc/odbc_stmt.c"
thirdparty/php83/pdo_odbc/odbc_stmt.c \
thirdparty/php84/pdo_odbc/odbc_driver.c \
thirdparty/php84/pdo_odbc/odbc_stmt.c"
fi

if test "$PHP_SWOOLE_SQLITE" != "no"; then
Expand All @@ -1081,7 +1091,10 @@ EOF
thirdparty/php81/pdo_sqlite/sqlite_driver.c \
thirdparty/php81/pdo_sqlite/sqlite_statement.c \
thirdparty/php83/pdo_sqlite/sqlite_driver.c \
thirdparty/php83/pdo_sqlite/sqlite_statement.c"
thirdparty/php83/pdo_sqlite/sqlite_statement.c \
thirdparty/php84/pdo_sqlite/sqlite_driver.c \
thirdparty/php84/pdo_sqlite/sqlite_statement.c \
thirdparty/php84/pdo_sqlite/sqlite_sql_parser.c"
fi

SW_ASM_DIR="thirdparty/boost/asm/"
Expand Down Expand Up @@ -1232,27 +1245,33 @@ EOF
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php/sockets)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php/standard)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php/curl)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php84/curl)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php84/hash)
if test "$PHP_NGHTTP2_DIR" = "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/nghttp2)
fi
if test "$PHP_SWOOLE_PGSQL" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php80/pdo_pgsql)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php81/pdo_pgsql)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php83/pdo_pgsql)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php84/pdo_pgsql)
fi
if test "$PHP_SWOOLE_ODBC" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php80/pdo_odbc)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php81/pdo_odbc)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php83/pdo_odbc)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php84/pdo_odbc)
fi
if test "$PHP_SWOOLE_ORACLE" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php80/pdo_oci)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php81/pdo_oci)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php83/pdo_oci)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php84/pdo_oci)
fi
if test "$PHP_SWOOLE_SQLITE" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php80/pdo_sqlite)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php81/pdo_sqlite)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php83/pdo_sqlite)
PHP_ADD_BUILD_DIR($ext_builddir/thirdparty/php84/pdo_sqlite)
fi
fi
1 change: 1 addition & 0 deletions ext-src/php_swoole_coroutine.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

#define SW_DEFAULT_MAX_CORO_NUM 100000
#define SW_DEFAULT_PHP_STACK_PAGE_SIZE 8192
enum sw_exit_flags { SW_EXIT_IN_COROUTINE = 1 << 1, SW_EXIT_IN_SERVER = 1 << 2 };

#define SWOG ((zend_output_globals *) &OG(handlers))

Expand Down
6 changes: 6 additions & 0 deletions ext-src/php_swoole_curl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@
SW_EXTERN_C_BEGIN
#include <curl/curl.h>
#include <curl/multi.h>
#ifdef SW_USE_CURL
#if PHP_VERSION_ID >= 80400
#include "thirdparty/php84/curl/curl_private.h"
#else
#include "thirdparty/php/curl/curl_private.h"
#endif
#endif
SW_EXTERN_C_END

#if LIBCURL_VERSION_NUM < 0x073800
Expand Down
10 changes: 8 additions & 2 deletions ext-src/php_swoole_odbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ BEGIN_EXTERN_C()

#include "ext/pdo/php_pdo_driver.h"

#if PHP_VERSION_ID > 80100
#if PHP_VERSION_ID >= 80000 && PHP_VERSION_ID < 80100
#include "thirdparty/php80/pdo_odbc/php_pdo_odbc_int.h"
#elif PHP_VERSION_ID >= 80100 && PHP_VERSION_ID < 80200
#include "thirdparty/php81/pdo_odbc/php_pdo_odbc_int.h"
#elif PHP_VERSION_ID >= 80200 && PHP_VERSION_ID < 80300
#include "thirdparty/php81/pdo_odbc/php_pdo_odbc_int.h"
#elif PHP_VERSION_ID >= 80300 && PHP_VERSION_ID < 80400
#include "thirdparty/php83/pdo_odbc/php_pdo_odbc_int.h"
#else
#include "thirdparty/php80/pdo_odbc/php_pdo_odbc_int.h"
#include "thirdparty/php84/pdo_odbc/php_pdo_odbc_int.h"
#endif

extern const pdo_driver_t swoole_pdo_odbc_driver;
Expand Down
11 changes: 9 additions & 2 deletions ext-src/php_swoole_oracle.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,17 @@
BEGIN_EXTERN_C()

#include "ext/pdo/php_pdo_driver.h"
#if PHP_VERSION_ID >= 80100

#if PHP_VERSION_ID >= 80000 && PHP_VERSION_ID < 80100
#include "thirdparty/php80/pdo_oci/php_pdo_oci_int.h"
#elif PHP_VERSION_ID >= 80100 && PHP_VERSION_ID < 80200
#include "thirdparty/php81/pdo_oci/php_pdo_oci_int.h"
#elif PHP_VERSION_ID >= 80200 && PHP_VERSION_ID < 80300
#include "thirdparty/php81/pdo_oci/php_pdo_oci_int.h"
#elif PHP_VERSION_ID >= 80300 && PHP_VERSION_ID < 80400
#include "thirdparty/php83/pdo_oci/php_pdo_oci_int.h"
#else
#include "thirdparty/php80/pdo_oci/php_pdo_oci_int.h"
#include "thirdparty/php84/pdo_oci/php_pdo_oci_int.h"
#endif

extern const pdo_driver_t swoole_pdo_oci_driver;
Expand Down
4 changes: 4 additions & 0 deletions ext-src/php_swoole_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ extern zend_object_handlers swoole_exception_handlers;
extern zend_class_entry *swoole_error_ce;
extern zend_class_entry *swoole_resolve_context_ce;
extern zend_object_handlers swoole_resolve_context_handlers;
#if PHP_VERSION_ID >= 80400
extern zend_class_entry *swoole_exit_exception_ce;
extern zend_object_handlers swoole_exit_exception_handlers;
#endif

PHP_FUNCTION(swoole_clear_dns_cache);
PHP_FUNCTION(swoole_last_error);
Expand Down
11 changes: 9 additions & 2 deletions ext-src/php_swoole_sqlite.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@
BEGIN_EXTERN_C()

#include "ext/pdo/php_pdo_driver.h"
#if PHP_VERSION_ID >= 80100

#if PHP_VERSION_ID >= 80000 && PHP_VERSION_ID < 80100
#include "thirdparty/php80/pdo_sqlite/php_pdo_sqlite_int.h"
#elif PHP_VERSION_ID >= 80100 && PHP_VERSION_ID < 80200
#include "thirdparty/php81/pdo_sqlite/php_pdo_sqlite_int.h"
#elif PHP_VERSION_ID >= 80200 && PHP_VERSION_ID < 80300
#include "thirdparty/php81/pdo_sqlite/php_pdo_sqlite_int.h"
#elif PHP_VERSION_ID >= 80300 && PHP_VERSION_ID < 80400
#include "thirdparty/php83/pdo_sqlite/php_pdo_sqlite_int.h"
#else
#include "thirdparty/php80/pdo_sqlite/php_pdo_sqlite_int.h"
#include "thirdparty/php84/pdo_sqlite/php_pdo_sqlite_int.h"
#endif

extern const pdo_driver_t swoole_pdo_sqlite_driver;
Expand Down
22 changes: 17 additions & 5 deletions ext-src/swoole_coroutine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
#include "php_swoole_cxx.h"
#include "php_swoole_coroutine_system.h"

#if PHP_VERSION_ID < 80400
#include "swoole_server.h"
#endif
#include "swoole_signal.h"

#include "zend_builtin_functions.h"
Expand Down Expand Up @@ -55,8 +57,6 @@ static zend_always_inline zend_vm_stack zend_vm_stack_new_page(size_t size, zend
}
#endif

enum sw_exit_flags { SW_EXIT_IN_COROUTINE = 1 << 1, SW_EXIT_IN_SERVER = 1 << 2 };

bool PHPCoroutine::activated = false;
zend_array *PHPCoroutine::options = nullptr;

Expand All @@ -73,19 +73,27 @@ bool PHPCoroutine::interrupt_thread_running = false;

extern void php_swoole_load_library();

static zend_atomic_bool *zend_vm_interrupt = nullptr;
#if PHP_VERSION_ID < 80400
static user_opcode_handler_t ori_exit_handler = nullptr;
#endif

static zend_atomic_bool *zend_vm_interrupt = nullptr;
static user_opcode_handler_t ori_begin_silence_handler = nullptr;
static user_opcode_handler_t ori_end_silence_handler = nullptr;
static unordered_map<long, Coroutine *> user_yield_coros;

static void (*orig_interrupt_function)(zend_execute_data *execute_data) = nullptr;

static zend_class_entry *swoole_coroutine_util_ce;
static zend_class_entry *swoole_exit_exception_ce;
static zend_object_handlers swoole_exit_exception_handlers;
static zend_class_entry *swoole_coroutine_iterator_ce;
static zend_class_entry *swoole_coroutine_context_ce;
#if PHP_VERSION_ID >= 80400
zend_class_entry *swoole_exit_exception_ce;
zend_object_handlers swoole_exit_exception_handlers;
#else
static zend_class_entry *swoole_exit_exception_ce;
static zend_object_handlers swoole_exit_exception_handlers;
#endif

SW_EXTERN_C_BEGIN
static PHP_METHOD(swoole_coroutine, exists);
Expand Down Expand Up @@ -180,6 +188,7 @@ static const zend_function_entry swoole_exit_exception_methods[] = {
};
// clang-format on

#if PHP_VERSION_ID < 80400
static int coro_exit_handler(zend_execute_data *execute_data) {
zval ex;
zend_object *obj;
Expand Down Expand Up @@ -224,6 +233,7 @@ static int coro_exit_handler(zend_execute_data *execute_data) {

return ZEND_USER_OPCODE_DISPATCH;
}
#endif

static int coro_begin_silence_handler(zend_execute_data *execute_data) {
PHPContext *task = PHPCoroutine::get_context();
Expand Down Expand Up @@ -989,8 +999,10 @@ void php_swoole_coroutine_minit(int module_number) {

void php_swoole_coroutine_rinit() {
if (SWOOLE_G(cli)) {
#if PHP_VERSION_ID < 80400
ori_exit_handler = zend_get_user_opcode_handler(ZEND_EXIT);
zend_set_user_opcode_handler(ZEND_EXIT, coro_exit_handler);
#endif

ori_begin_silence_handler = zend_get_user_opcode_handler(ZEND_BEGIN_SILENCE);
zend_set_user_opcode_handler(ZEND_BEGIN_SILENCE, coro_begin_silence_handler);
Expand Down
6 changes: 6 additions & 0 deletions ext-src/swoole_mysql_coro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@
#undef L64

SW_EXTERN_C_BEGIN

#if PHP_VERSION_ID >= 80400
#include "thirdparty/php84/hash/php_hash.h"
#include "thirdparty/php84/hash/php_hash_sha.h"
#else
#include "ext/hash/php_hash.h"
#include "ext/hash/php_hash_sha.h"
#endif
#include "ext/standard/php_math.h"
#ifdef SW_USE_MYSQLND
#include "ext/mysqlnd/mysqlnd.h"
Expand Down
11 changes: 9 additions & 2 deletions ext-src/swoole_pgsql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,17 @@
#include "swoole_coroutine_system.h"

#ifdef SW_USE_PGSQL
#if PHP_VERSION_ID > 80100

#if PHP_VERSION_ID >= 80000 && PHP_VERSION_ID < 80100
#include "thirdparty/php80/pdo_pgsql/php_pdo_pgsql_int.h"
#elif PHP_VERSION_ID >= 80100 && PHP_VERSION_ID < 80200
#include "thirdparty/php81/pdo_pgsql/php_pdo_pgsql_int.h"
#elif PHP_VERSION_ID >= 80200 && PHP_VERSION_ID < 80300
#include "thirdparty/php81/pdo_pgsql/php_pdo_pgsql_int.h"
#elif PHP_VERSION_ID >= 80300 && PHP_VERSION_ID < 80400
#include "thirdparty/php83/pdo_pgsql/php_pdo_pgsql_int.h"
#else
#include "thirdparty/php80/pdo_pgsql/php_pdo_pgsql_int.h"
#include "thirdparty/php84/pdo_pgsql/php_pdo_pgsql_int.h"
#endif

using swoole::Reactor;
Expand Down
Loading
Loading