Skip to content

Fix session persistence by checking memcached behavior values before setting #379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions php_memcached_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,15 @@ void s_unlock_session(memcached_st *memc)
static
zend_bool s_configure_from_ini_values(memcached_st *memc, zend_bool silent)
{
memcached_return rc;

#define check_set_behavior(behavior, value) \
if ((rc = memcached_behavior_set(memc, (behavior), (value))) != MEMCACHED_SUCCESS) { \
if (!silent) { php_error_docref(NULL, E_WARNING, "failed to initialise session memcached configuration: %s", memcached_strerror(memc, rc)); } \
return 0; \
if ((value) != memcached_behavior_get(memc, (behavior))) { \
memcached_return rc; \
if ((rc = memcached_behavior_set(memc, (behavior), (value))) != MEMCACHED_SUCCESS) { \
if (!silent) { \
php_error_docref(NULL, E_WARNING, "failed to initialise session memcached configuration: %s", memcached_strerror(memc, rc)); \
} \
return 0; \
} \
}

if (MEMC_SESS_INI(binary_protocol_enabled)) {
Expand Down Expand Up @@ -243,7 +246,7 @@ zend_bool s_configure_from_ini_values(memcached_st *memc, zend_bool silent)
user_data->has_sasl_data = 1;
}

#undef safe_set_behavior
#undef check_set_behavior

return 1;
}
Expand Down