Changeset 327
- Timestamp:
- 08/19/07 18:42:47 (9 months ago)
- Files:
-
- eaccelerator/trunk/ChangeLog (modified) (1 diff)
- eaccelerator/trunk/shm.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
eaccelerator/trunk/ChangeLog
r326 r327 1 1 2007-08-19 Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> 2 2 * Fix an E_NOTICE error in the control panel 3 * Improve storing of objects and fix bug #264 3 4 4 5 2007-08-16 Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> eaccelerator/trunk/shm.c
r302 r327 39 39 #include "zend_extensions.h" 40 40 #include "standard/php_var.h" 41 #include "standard/php_smart_str.h" 41 42 42 43 /* where to cache the keys */ … … 105 106 time_t ttl = 0; 106 107 long where = eaccelerator_keys_cache_place; 108 int ret_val = 0; 109 smart_str buf = {0}; 107 110 108 111 if (zend_parse_parameters (ZEND_NUM_ARGS ()TSRMLS_CC, "sz|ll", &key, &key_len, &val, &ttl, &where) == FAILURE) … … 111 114 if ((Z_TYPE_P(val) & ~IS_CONSTANT_INDEX) == IS_OBJECT) { 112 115 php_serialize_data_t var_hash; 113 smart_str buf = {0};114 result = (zval *)emalloc(sizeof(zval));115 116 116 117 PHP_VAR_SERIALIZE_INIT(var_hash); … … 118 119 PHP_VAR_SERIALIZE_DESTROY(var_hash); 119 120 120 Z_TYPE_P(result) = IS_NULL;121 121 if (buf.c) { 122 ALLOC_ZVAL(result); 122 123 ZVAL_STRINGL(result, buf.c, buf.len, 1); 123 124 Z_TYPE_P(result) = Z_TYPE_P(val); 124 125 } 125 INIT_PZVAL(result);126 126 } else { 127 127 result = val; 128 128 } 129 129 130 if (eaccelerator_put (key, key_len, result, ttl, where TSRMLS_CC)) { 130 ret_val = eaccelerator_put (key, key_len, result, ttl, where TSRMLS_CC); 131 132 if ((Z_TYPE_P(val) & ~IS_CONSTANT_INDEX) == IS_OBJECT) { 133 smart_str_free(&buf); 134 } 135 136 if (ret_val) { 131 137 RETURN_TRUE; 132 138 } else { … … 140 146 int key_len; 141 147 long where = eaccelerator_keys_cache_place; 142 zval *value;143 148 144 149 if (zend_parse_parameters (ZEND_NUM_ARGS ()TSRMLS_CC, "s|l", &key, &key_len, &where) == FAILURE) 145 150 return; 146 151 147 ALLOC_ZVAL(value); 148 if (eaccelerator_get (key, key_len, value, where TSRMLS_CC)) { 149 if ((Z_TYPE_P(value) & ~IS_CONSTANT_INDEX) == IS_OBJECT) { 152 if (eaccelerator_get (key, key_len, return_value, where TSRMLS_CC)) { 153 if ((Z_TYPE_P(return_value) & ~IS_CONSTANT_INDEX) == IS_OBJECT) { 150 154 const unsigned char *p; 151 155 php_unserialize_data_t var_hash; 152 153 p = (const unsigned char*)Z_STRVAL_P(value); 156 zval *object; 157 158 /* 159 * We serialized the object to a string but stored the object type 160 * so it will be serialized here. 161 */ 162 Z_TYPE_P(return_value) = IS_STRING; 163 154 164 PHP_VAR_UNSERIALIZE_INIT(var_hash); 155 if (!php_var_unserialize(&return_value, &p, p + Z_STRLEN_P(value), &var_hash TSRMLS_CC)) { 156 PHP_VAR_UNSERIALIZE_DESTROY(var_hash); 157 zval_dtor(return_value); 158 php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Error at offset %ld of %d bytes", 159 (long)((char*)p - Z_STRVAL_P(value)), Z_STRLEN_P(value)); 165 p = (const unsigned char *)Z_STRVAL_P(return_value); 166 if (!php_var_unserialize(&return_value, &p, p + Z_STRLEN_P(return_value), &var_hash TSRMLS_CC)) { 167 zval_dtor(object); 168 Z_TYPE_P(object) = IS_NULL; 160 169 } 161 170 PHP_VAR_UNSERIALIZE_DESTROY(var_hash);