[pkg-uWSGI-devel] Bug#1155643: uwsgi-src: php plugin fails to build with PHP 8.6 (session save handler API)

Ondřej Surý ondrej at sury.org
Sat Nov 28 09:39:13 GMT 2026


Package: uwsgi-src
Version: 2.0.31-7
Severity: important
Tags: ftbfs patch upstream
Control: affects -1 + src:uwsgi-plugin-php
Control: block 1149581 by -1

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Hi,

uwsgi-plugin-php fails to build with PHP 8.6, which is in experimental and
becomes the default in unstable with the php8.6 transition (#1149581).
The code that fails is plugins/php/session.c from uwsgi-src:

  /usr/include/php/20261112/ext/session/php_session.h:76:36: error: 'ps_create_sid_uwsgi' undeclared here (not in a function); did you mean 'ps_read_uwsgi'?
  /usr/include/php/20261112/ext/session/php_session.h:77:10: error: 'ps_validate_sid_uwsgi' undeclared here (not in a function)
  /usr/src/uwsgi/plugins/php/session.c:50:9: note: in expansion of macro 'PS_MOD'
  *** unable to build php plugin ***

PHP 8.6 changed the session save handler API in two ways that matter
here (UPGRADING.INTERNALS, ext/session):

  * "PS_MOD() now requires that the PS_CREATE_SID_FUNC() and
    PS_VALIDATE_SID_FUNC() functions are defined."  That is the build
    failure.

  * PS_OPEN_ARGS passes save_path as a zend_string instead of a char
    pointer.  The plugin casts save_path to char * and keeps it as the
    name of the uWSGI cache that holds the sessions.  The cast still
    compiles without a warning, but the cache functions are then handed
    a pointer to the zend_string header and do not find the cache: every
    request starts with an empty session and PHP logs "Failed to write
    session data (uwsgi)".

The attached patch for src:uwsgi fixes both, in code that is only used
with PHP 8.6 and later:

  * it defines the two functions and has them call
    php_session_create_id() and php_session_validate_sid(), which is what
    PS_MOD() filled in up to PHP 8.5, so the handler behaves as before;
  * the open function stores ZSTR_VAL(save_path).

I did not find a fix elsewhere: uwsgi's master and uwsgi-2.0 branches
have the same session.c.  The patch has not been sent upstream yet.

Tested in sbuild chroots:

  * uwsgi 2.0.31-7 with the patch builds in unstable.
  * uwsgi-plugin-php 0.0.15 builds against that uwsgi-src with php8.6
    8.6.0-3 and php-defaults 108~exp2 from experimental.  Its
    debian/tests/smoke passes, and a page that counts in $_SESSION with
    session.save_handler=uwsgi counts 1, 2, 3 over three requests.
  * The same with php8.4 8.4.28-3 in unstable: it builds and both tests
    pass.
  * With only the first half of the patch it builds and the smoke test
    still passes, but the counter stays at 1.  So the smoke test alone
    does not show that the save handler works.

uwsgi-plugin-php has no source of its own for this; once uwsgi-src is
fixed it only needs a rebuild.


- -- System Information:
Debian Release: 13.8
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable-debug'), (500, 'proposed-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.12.117+deb13-amd64 (SMP w/12 CPU threads; PREEMPT)
Locale: LANG=en_IE.UTF-8, LC_CTYPE=en_IE.UTF-8 (charmap=UTF-8), LANGUAGE=en_IE:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)

-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEw2Gx4wKVQ+vGJel9g3Kkd++uWcIFAmsKoUFfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldEMz
NjFCMUUzMDI5NTQzRUJDNjI1RTk3RDgzNzJBNDc3RUZBRTU5QzIACgkQg3Kkd++u
WcJALg/9FiP3lj05AYZy8u1oLT1BO7NxgbTmsmyYxAQNGqDeB/J1fiyTvShqo69i
bnLIqc8gr/uA01PcCiGOTont7jQxWi5DfrMr87oU+KemZA49cAEKonPhd012s2T6
5DPjMfTe65wKdOISFq/TsXq6i+23dsr+pgTwTtW97Ia3KpBW7QebiAykLRJw8+Sv
VZpL2T36+laYmNxrskajf4sVs3XlMOhQY8u6I3RUUktis1CpCZJ3fNpy7JChDMpq
jL2TsisJwe6NG+cSuRAHzQ4FVlpu2PzW0NRuHMYVt6rZiwWRUnHwJjyPIQX501h4
5BugllJR+/6YuFDNLD9J2L+v1jbGfZLx9k+PlE1YkygQgv419ovznFFHY/0KcVvf
yhGk5pA/1TrtHxSaVRdLxpsZTZS1BESrEsP+3LvmuXOH3KfSavZds5Cq0MSqI80j
h3yEJRNUN5BJhNDQtGa37XC6LzlMIMyPqwVJJ1m1tXdWuZdn0FqrFf15kXkwvCRE
8w+QsvXrgLDJ9RvqUdAjQXpWYHlP29tV133mit3nv969exlrc/ay1P2waKW+04ca
/XjKS/ak6MwwOTSdgA+SWMbz5nViC3IgYnA4gAEMOWSJpe8nX+YbsqheoroQ5JFz
aNSBnkYaE6Gbs4WJZjWZQr2e6KcZ3PRwPTdsfo8TV6yZnn5tpv0=
=RLJe
-----END PGP SIGNATURE-----
-------------- next part --------------
Description: php: adapt the session save handler to PHP 8.6
 PHP 8.6 changed the save handler API of ext/session in two ways that
 matter for the "uwsgi" save handler of the php plugin:
 .
  * PS_MOD() no longer fills in php_session_create_id() and
    php_session_validate_sid(); the module has to define
    PS_CREATE_SID_FUNC() and PS_VALIDATE_SID_FUNC() itself.  The plugin
    failed to build:
 .
      php_session.h:76:36: error: 'ps_create_sid_uwsgi' undeclared here
      php_session.h:77:10: error: 'ps_validate_sid_uwsgi' undeclared here
 .
    Define both and have them call the functions PS_MOD() used before,
    so the handler behaves as it did.
 .
  * The save_path argument of the open function is a zend_string instead
    of a char pointer.  The plugin casts it to char * and keeps it as the
    name of the uWSGI cache that holds the sessions.  That cast compiles
    without a warning with PHP 8.6 too, but the cache functions are then
    handed a pointer to the zend_string header and do not find the cache:
    the session comes back empty on every request and PHP logs "Failed
    to write session data (uwsgi)".  The smoke test in uwsgi-plugin-php
    does not notice, it only calls session_start().
 .
 Older PHP versions are not affected, the new code is only used with
 PHP 8.6 and later.
Author: Ond?ej Sur? <ondrej at debian.org>
Forwarded: no
Last-Update: 2026-11-28
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/plugins/php/session.c
+++ b/plugins/php/session.c
@@ -1,7 +1,12 @@
 #include "common.h"
 
 PS_OPEN_FUNC(uwsgi) {
+#if PHP_VERSION_ID >= 80600
+	/* save_path is a zend_string since PHP 8.6 */
+	PS_SET_MOD_DATA(ZSTR_VAL(save_path));
+#else
 	PS_SET_MOD_DATA((char *)save_path);
+#endif
 	return SUCCESS;
 }
 
@@ -46,6 +51,20 @@
 	return SUCCESS;
 }
 
+#if PHP_VERSION_ID >= 80600
+/*
+ * Since PHP 8.6 PS_MOD() wants the module to bring its own create_sid and
+ * validate_sid functions.  Use the ones PS_MOD() filled in before.
+ */
+PS_CREATE_SID_FUNC(uwsgi) {
+	return php_session_create_id(mod_data);
+}
+
+PS_VALIDATE_SID_FUNC(uwsgi) {
+	return php_session_validate_sid(mod_data, key);
+}
+#endif
+
 ps_module ps_mod_uwsgi = {
 	PS_MOD(uwsgi)
 };


More information about the pkg-uWSGI-devel mailing list