[PECL-CVS] [pecl-networking-gearman] add-ssl-support: address reviews
[email protected] (Rasmus Lerdorf) Sat, 4 Apr 2026 19:15:41 +0000
| Newsgroups | php.pecl.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: Rasmus Lerdorf (rlerdorf)
Date: 2026-04-04T15:15:36-04:00
Commit: https://github.com/php/pecl-networking-gearman/commit/c5eff71ac116f495f29cfbf7eaa44cba5358fc39
Raw diff: https://github.com/php/pecl-networking-gearman/commit/c5eff71ac116f495f29cfbf7eaa44cba5358fc39.diff
address reviews
Changed paths:
M config.m4
M gearman.stub.php
M gearman_arginfo.h
M php_gearman_worker.c
Diff:
diff --git a/config.m4 b/config.m4
index db5930f..b31f448 100644
--- a/config.m4
+++ b/config.m4
@@ -85,6 +85,14 @@ if test "$PHP_GEARMAN" != "no"; then
-L$GEARMAN_LIB_DIR -R$GEARMAN_LIB_DIR
])
+ AC_MSG_CHECKING([for GEARMAN_WORKER_SSL option])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libgearman-1.0/gearman.h>]],
+ [[int x = GEARMAN_WORKER_SSL;]])],
+ [AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE_GEARMAN_WORKER_SSL_OPTION, 1, [Whether GEARMAN_WORKER_SSL option is available])],
+ [AC_MSG_RESULT([no])]
+ )
+
PHP_SUBST(GEARMAN_SHARED_LIBADD)
PHP_ADD_INCLUDE($GEARMAN_INC_DIR)
diff --git a/gearman.stub.php b/gearman.stub.php
index be0dc38..aee65ec 100644
--- a/gearman.stub.php
+++ b/gearman.stub.php
@@ -40,6 +40,9 @@ public function timeout(): int {}
/** @alias gearman_client_set_timeout */
public function setTimeout(int $timeout): bool {}
+ /* NOTE: setSSL is conditionally compiled (#ifdef HAVE_GEARMAN_CLIENT_SET_SSL).
+ * The arginfo in gearman_arginfo.h is manually maintained with #ifdef guards.
+ * Do not regenerate gearman_arginfo.h from this stub without re-adding guards. */
/** @alias gearman_client_set_ssl */
public function setSSL(bool $ssl = true, ?string $ca_file = null, ?string $certificate = null, ?string $key_file = null): bool {}
@@ -156,6 +159,7 @@ function gearman_client_add_options(GearmanClient $obj, int $option): bool {}
function gearman_client_remove_options(GearmanClient $obj, int $option): bool {}
function gearman_client_timeout(GearmanClient $obj): ?int {}
function gearman_client_set_timeout(GearmanClient $obj, int $timeout): bool {}
+/* NOTE: conditionally compiled, see comment on GearmanClient::setSSL */
function gearman_client_set_ssl(GearmanClient $obj, bool $ssl = true, ?string $ca_file = null, ?string $certificate = null, ?string $key_file = null): bool {}
function gearman_client_add_server(GearmanClient $obj, ?string $host = null, int $port = 0, bool $setupExceptionHandler = true): bool {}
function gearman_client_add_servers(GearmanClient $obj, ?string $servers = null, bool $setupExceptionHandler = true): bool {}
diff --git a/gearman_arginfo.h b/gearman_arginfo.h
index 690e8a0..1d825d3 100644
--- a/gearman_arginfo.h
+++ b/gearman_arginfo.h
@@ -1,5 +1,5 @@
-/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 61b9d7c4865da96ac967a58f08937db3999e6548 */
+/* This file is manually maintained for cross-PHP-version compatibility.
+ * Do not regenerate from gearman.stub.php without re-adding #ifdef guards. */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_version, 0, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()
@@ -46,6 +46,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_client_set_timeout, 0, 2
ZEND_ARG_TYPE_INFO(0, timeout, IS_LONG, 0)
ZEND_END_ARG_INFO()
+#ifdef HAVE_GEARMAN_CLIENT_SET_SSL
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_client_set_ssl, 0, 1, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanClient, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, ssl, _IS_BOOL, 0, "true")
@@ -53,6 +54,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_client_set_ssl, 0, 1, _I
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, certificate, IS_STRING, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, key_file, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
+#endif
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_client_add_server, 0, 1, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanClient, 0)
@@ -816,8 +818,8 @@ static const zend_function_entry ext_functions[] = {
ZEND_FE(gearman_worker_remove_options, arginfo_gearman_worker_remove_options)
ZEND_FE(gearman_worker_timeout, arginfo_gearman_worker_timeout)
ZEND_FE(gearman_worker_set_timeout, arginfo_gearman_worker_set_timeout)
- ZEND_FE(gearman_worker_set_ssl, arginfo_gearman_worker_set_ssl)
ZEND_FE(gearman_worker_set_id, arginfo_gearman_worker_set_id)
+ ZEND_FE(gearman_worker_set_ssl, arginfo_gearman_worker_set_ssl)
ZEND_FE(gearman_worker_add_server, arginfo_gearman_worker_add_server)
ZEND_FE(gearman_worker_add_servers, arginfo_gearman_worker_add_servers)
ZEND_FE(gearman_worker_wait, arginfo_gearman_worker_wait)
diff --git a/php_gearman_worker.c b/php_gearman_worker.c
index 8767e43..6d65d5d 100644
--- a/php_gearman_worker.c
+++ b/php_gearman_worker.c
@@ -318,7 +318,7 @@ PHP_FUNCTION(gearman_worker_set_ssl) {
#ifdef HAVE_GEARMAN_WORKER_SET_SSL
gearman_worker_set_ssl(&(obj->worker), ssl, ca_file, certificate, key_file);
-#else
+#elif defined(HAVE_GEARMAN_WORKER_SSL_OPTION)
/* gearman_worker_set_ssl() is declared in libgearman headers but not
* implemented (missing symbol through 1.1.22). Toggle the SSL option
* flag only. Per-worker cert paths are not supported in this fallback;
@@ -336,6 +336,10 @@ PHP_FUNCTION(gearman_worker_set_ssl) {
"GEARMAND_CA_CERTIFICATE, GEARMAN_CLIENT_SSL_CERTIFICATE, "
"and GEARMAN_CLIENT_SSL_KEY instead");
}
+#else
+ php_error_docref(NULL, E_WARNING,
+ "SSL is not supported by this version of libgearman");
+ RETURN_FALSE;
#endif
RETURN_TRUE;
}