Skip to content

Commit c65cc1c

Browse files
authored
Fix session persistence by checking memcached behavior values before setting (#379)
1 parent 6767a79 commit c65cc1c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Diff for: php_memcached_session.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,15 @@ void s_unlock_session(memcached_st *memc)
186186
static
187187
zend_bool s_configure_from_ini_values(memcached_st *memc, zend_bool silent)
188188
{
189-
memcached_return rc;
190-
191189
#define check_set_behavior(behavior, value) \
192-
if ((rc = memcached_behavior_set(memc, (behavior), (value))) != MEMCACHED_SUCCESS) { \
193-
if (!silent) { php_error_docref(NULL, E_WARNING, "failed to initialise session memcached configuration: %s", memcached_strerror(memc, rc)); } \
194-
return 0; \
190+
if ((value) != memcached_behavior_get(memc, (behavior))) { \
191+
memcached_return rc; \
192+
if ((rc = memcached_behavior_set(memc, (behavior), (value))) != MEMCACHED_SUCCESS) { \
193+
if (!silent) { \
194+
php_error_docref(NULL, E_WARNING, "failed to initialise session memcached configuration: %s", memcached_strerror(memc, rc)); \
195+
} \
196+
return 0; \
197+
} \
195198
}
196199

197200
if (MEMC_SESS_INI(binary_protocol_enabled)) {
@@ -243,7 +246,7 @@ zend_bool s_configure_from_ini_values(memcached_st *memc, zend_bool silent)
243246
user_data->has_sasl_data = 1;
244247
}
245248

246-
#undef safe_set_behavior
249+
#undef check_set_behavior
247250

248251
return 1;
249252
}

0 commit comments

Comments
 (0)