@@ -446,6 +446,10 @@ static void php_memc_get_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key)
446446
447447 status = memcached_mget_by_key (m_obj -> memc , server_key , server_key_len , keys , key_lens , 1 );
448448
449+ if (orig_cas_flag == 0 ) {
450+ memcached_behavior_set (m_obj -> memc , MEMCACHED_BEHAVIOR_SUPPORT_CAS , orig_cas_flag );
451+ }
452+
449453 if (php_memc_handle_error (i_obj , status TSRMLS_CC ) < 0 ) {
450454 RETURN_FROM_GET ;
451455 }
@@ -497,12 +501,6 @@ static void php_memc_get_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key)
497501
498502 memcached_result_free (& result );
499503
500- /*
501- * Restore the CAS support flag, but only if we had to turn it on.
502- */
503- if (orig_cas_flag == 0 ) {
504- memcached_behavior_set (m_obj -> memc , MEMCACHED_BEHAVIOR_SUPPORT_CAS , orig_cas_flag );
505- }
506504 return ;
507505
508506 } else {
@@ -665,10 +663,8 @@ static void php_memc_getMulti_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_ke
665663 /*
666664 * Restore the CAS support flag, but only if we had to turn it on.
667665 */
668- if (cas_tokens ) {
669- if (orig_cas_flag == 0 ) {
670- memcached_behavior_set (m_obj -> memc , MEMCACHED_BEHAVIOR_SUPPORT_CAS , orig_cas_flag );
671- }
666+ if (cas_tokens && orig_cas_flag == 0 ) {
667+ memcached_behavior_set (m_obj -> memc , MEMCACHED_BEHAVIOR_SUPPORT_CAS , orig_cas_flag );
672668 }
673669
674670 efree (mkeys );
@@ -839,10 +835,8 @@ static void php_memc_getDelayed_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_
839835 /*
840836 * Restore the CAS support flag, but only if we had to turn it on.
841837 */
842- if (with_cas ) {
843- if (orig_cas_flag == 0 ) {
844- memcached_behavior_set (m_obj -> memc , MEMCACHED_BEHAVIOR_SUPPORT_CAS , orig_cas_flag );
845- }
838+ if (with_cas && orig_cas_flag == 0 ) {
839+ memcached_behavior_set (m_obj -> memc , MEMCACHED_BEHAVIOR_SUPPORT_CAS , orig_cas_flag );
846840 }
847841
848842 efree (mkeys );
0 commit comments