Skip to content

Commit 1774650

Browse files
committed
fix session on PHP 8.6+
reference: php/php-src@71096cd
1 parent 4ef6dce commit 1774650

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

php_memcached_session.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,21 @@ PS_OPEN_FUNC(memcached)
324324

325325
memcached_server_list_st servers;
326326

327+
#if PHP_VERSION_ID >= 80600
328+
const char *save_path_str = ZSTR_VAL(save_path);
329+
#else
330+
const char *save_path_str = save_path;
331+
#endif
332+
327333
// Fail on incompatible PERSISTENT identifier (removed in php-memcached 3.0)
328-
if (strstr(save_path, "PERSISTENT=")) {
334+
if (strstr(save_path_str, "PERSISTENT=")) {
329335
php_error_docref(NULL, E_WARNING, "failed to parse session.save_path: PERSISTENT is replaced by memcached.sess_persistent = On");
330336
PS_SET_MOD_DATA(NULL);
331337
return FAILURE;
332338
}
333339

334340
// First parse servers
335-
servers = memcached_servers_parse(save_path);
341+
servers = memcached_servers_parse(save_path_str);
336342

337343
if (!servers) {
338344
php_error_docref(NULL, E_WARNING, "failed to parse session.save_path");
@@ -343,7 +349,7 @@ PS_OPEN_FUNC(memcached)
343349
if (MEMC_SESS_INI(persistent_enabled)) {
344350
zend_resource *le_p;
345351

346-
plist_key_len = spprintf(&plist_key, 0, "memc-session:%s", save_path);
352+
plist_key_len = spprintf(&plist_key, 0, "memc-session:%s", save_path_str);
347353

348354
if ((le_p = zend_hash_str_find_ptr(&EG(persistent_list), plist_key, plist_key_len)) != NULL) {
349355
if (le_p->type == s_memc_sess_list_entry()) {

0 commit comments

Comments
 (0)