php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #60501
Patch binary-session-support revision 2011-12-12 16:29 UTC by trevor at blubolt dot com

Patch binary-session-support for memcached Bug #60501

Patch version 2011-12-12 16:29 UTC

Return to Bug #60501 | Download this patch
Patch Revisions:

Developer: trevor@blubolt.com

--- a/memcached-2.0.0b2/php_memcached.h
+++ b/memcached-2.0.0b2/php_memcached.h
@@ -61,6 +61,7 @@
 ZEND_BEGIN_MODULE_GLOBALS(php_memcached)
 #ifdef HAVE_MEMCACHED_SESSION
 	zend_bool sess_locking_enabled;
+	zend_bool sess_binary_enabled;
 	long  sess_lock_wait;
 	char* sess_prefix;
 	zend_bool sess_locked;
--- a/memcached-2.0.0b2/php_memcached.c
+++ b/memcached-2.0.0b2/php_memcached.c
@@ -280,6 +280,7 @@
 PHP_INI_BEGIN()
 #ifdef HAVE_MEMCACHED_SESSION
 	STD_PHP_INI_ENTRY("memcached.sess_locking",		"1",		PHP_INI_ALL, OnUpdateBool,		sess_locking_enabled,	zend_php_memcached_globals,	php_memcached_globals)
+	STD_PHP_INI_ENTRY("memcached.sess_binary",		"0",		PHP_INI_ALL, OnUpdateBool,		sess_binary_enabled,	zend_php_memcached_globals,	php_memcached_globals)
 	STD_PHP_INI_ENTRY("memcached.sess_lock_wait",		"150000",	PHP_INI_ALL, OnUpdateLongGEZero,sess_lock_wait,			zend_php_memcached_globals,	php_memcached_globals)
 	STD_PHP_INI_ENTRY("memcached.sess_prefix",		"memc.sess.key.",	PHP_INI_ALL, OnUpdateString, sess_prefix,		zend_php_memcached_globals,	php_memcached_globals)
 #endif
@@ -2923,6 +2924,7 @@
 {
 #ifdef HAVE_MEMCACHED_SESSION
 	MEMC_G(sess_locking_enabled) = 1;
+	MEMC_G(sess_binary_enabled) = 1;
 	MEMC_G(sess_prefix) = NULL;
 	MEMC_G(sess_lock_wait) = 0;
 	MEMC_G(sess_locked) = 0;
--- a/memcached-2.0.0b2/memcached.ini
+++ b/memcached-2.0.0b2/memcached.ini
@@ -17,6 +17,9 @@
 ; the default value is "memc.sess.key."
 memcached.sess_prefix = "memc.sess.key."
 
+; memcached session binary mode
+memcached.sess_binary = Off
+
 ; Set the compression type
 ; valid values are: fastlz, zlib
 ; the default is fastlz
--- a/memcached-2.0.0b2/php_memcached_session.c
+++ b/memcached-2.0.0b2/php_memcached_session.c
@@ -188,6 +188,14 @@
 				}
 				efree(plist_key);
 			}
+
+			if (MEMC_G(sess_binary_enabled)) {
+				if (memcached_behavior_set(memc_sess->memc_sess, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, (uint64_t) 1) == MEMCACHED_FAILURE) {
+					php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to set memcached session binary protocol");
+					return FAILURE;
+				}
+			}
+
 			return SUCCESS;
 		}
 	}
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 23 17:01:58 2014 UTC