From 5df5a00c5882c5bc55177696302c084ce30bb38b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 13 Dec 2020 11:52:29 +0100 Subject: [PATCH] php: add detection of PHP 8.0, fix compilation errors --- cmake/FindPHP.cmake | 7 ++++--- src/plugins/php/weechat-php-api.c | 2 +- src/plugins/php/weechat-php.c | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/cmake/FindPHP.cmake b/cmake/FindPHP.cmake index 901aa07b3..ade865ff1 100644 --- a/cmake/FindPHP.cmake +++ b/cmake/FindPHP.cmake @@ -24,11 +24,12 @@ endif() find_package(PkgConfig) if(PKG_CONFIG_FOUND) - pkg_search_module(PHP php7) + pkg_search_module(PHP php8 php7) endif() if(NOT PHP_FOUND) find_program(PHP_CONFIG_EXECUTABLE NAMES + php-config8.0 php-config80 php-config7.4 php-config74 php-config7.3 php-config73 php-config7.2 php-config72 @@ -41,9 +42,9 @@ if(NOT PHP_FOUND) execute_process(COMMAND ${PHP_CONFIG_EXECUTABLE} --includes OUTPUT_VARIABLE PHP_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${PHP_CONFIG_EXECUTABLE} --libs OUTPUT_VARIABLE PHP_LIBS OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND ${PHP_CONFIG_EXECUTABLE} --version OUTPUT_VARIABLE PHP_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) - if(${PHP_VERSION} MATCHES "^7") + if(${PHP_VERSION} MATCHES "^[78]") find_library(PHP_LIB - NAMES php7.4 php7.3 php7.2 php7.1 php7.0 php7 + NAMES php8.0 php7.4 php7.3 php7.2 php7.1 php7.0 php7 HINTS ${PHP_LIB_PREFIX} ${PHP_LIB_PREFIX}/lib ${PHP_LIB_PREFIX}/lib64 ) if(PHP_LIB) diff --git a/src/plugins/php/weechat-php-api.c b/src/plugins/php/weechat-php-api.c index 5e3bcaaa3..76644ef1d 100644 --- a/src/plugins/php/weechat-php-api.c +++ b/src/plugins/php/weechat-php-api.c @@ -119,7 +119,7 @@ API_FUNC(register) php_registered_script->name); API_RETURN_ERROR; } - if (zend_parse_parameters (ZEND_NUM_ARGS() TSRMLS_CC, "SSSSSzS", + if (zend_parse_parameters (ZEND_NUM_ARGS(), "SSSSSzS", &name, &author, &version, &license, &description, &shutdown_func, &charset) == FAILURE) { diff --git a/src/plugins/php/weechat-php.c b/src/plugins/php/weechat-php.c index 484573c9d..ef1caa2a2 100644 --- a/src/plugins/php/weechat-php.c +++ b/src/plugins/php/weechat-php.c @@ -1246,8 +1246,18 @@ php_weechat_sapi_error (int type, const char *format, ...) } } -#if PHP_VERSION_ID >= 70100 -/* PHP >= 7.1 */ +#if PHP_VERSION_ID >= 80000 +/* PHP >= 8.0 */ +void +php_weechat_log_message (const char *message, int syslog_type_int) +{ + /* make C compiler happy */ + (void) syslog_type_int; + + php_weechat_ub_write (message, strlen (message)); +} +#elif PHP_VERSION_ID >= 70100 +/* 7.1 <= PHP < 8.0 */ void php_weechat_log_message (char *message, int syslog_type_int) {