rfc:internal_serialize_api

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
rfc:internal_serialize_api [2013/09/15 18:52] – New version with patch bukkarfc:internal_serialize_api [2017/09/22 13:28] – external edit 127.0.0.1
Line 1: Line 1:
 ====== PHP RFC: Internal Serialize API ====== ====== PHP RFC: Internal Serialize API ======
-  * Version: 1.0+  * Version: 1.1
   * Date: 2013-07-27   * Date: 2013-07-27
   * Author: Jakub Zelenka, bukka@php.net   * Author: Jakub Zelenka, bukka@php.net
Line 121: Line 121:
  
 <code> <code>
 +/* whether unserialization finished */
 +PHPAPI int php_var_unserialize_has_properties(const unsigned char *buf, zend_uint buf_len);
 +
 +/* unserialize all properties of the serialized object and save them to ht */
 +PHPAPI int php_var_unserialize_properties(HashTable *ht, const unsigned char **buf, zend_uint *buf_len, zend_unserialize_data *data TSRMLS_DC);
 +
 /* unserialize one property (key and value) of the serialized object */ /* unserialize one property (key and value) of the serialized object */
 PHPAPI int php_var_unserialize_property(zval *key, zval *value, const unsigned char **buf, zend_uint *buf_len, zend_unserialize_data *data TSRMLS_DC); PHPAPI int php_var_unserialize_property(zval *key, zval *value, const unsigned char **buf, zend_uint *buf_len, zend_unserialize_data *data TSRMLS_DC);
- 
-/* unserialize all properties of the serialized object and save them to ht */ 
-PHPAPI int php_var_unserialize_properties(HashTable *ht, const unsigned char **buf, zend_uint *buf_len, zend_uint elements, zend_unserialize_data *data TSRMLS_DC); 
 </code> </code>
  
Line 139: Line 142:
     zval key, value;     zval key, value;
  
- if (!php_var_unserialize_property(&key, &value, &buf, &buf_len, data TSRMLS_CC)) { +    while (php_var_unserialize_has_properties(buf, buf_len)) 
-        return -1; +    
-+        if (!php_var_unserialize_property(&key, &value, &buf, &buf_len, data TSRMLS_CC)) { 
- /* process first key and value... */ +            return -1; 
- +        
- if (!php_var_unserialize_property(&key, &value, &buf, &buf_len, data TSRMLS_CC)) { +        /* process key and value... */ 
-        return -1; +         
-+        zval_dtor(&key); 
- /* process second key and value... */ +        zval_dtor(&value); 
- +    }
- if (!php_var_unserialize_property(&key, &value, &buf, &buf_len, data TSRMLS_CC)) { +
-        return -1; +
-+
- /* process third key and value... */ +
- +
- if (!php_var_unserialize_property(&key, &value, &buf, &buf_len, data TSRMLS_CC)) { +
-        return -1+
- } +
- /* process fourth key and value... */+
  
- return (int) buf_len;+    return (int) buf_len;
 } }
 </code> </code>
Line 169: Line 163:
 ===== Patches and Tests ===== ===== Patches and Tests =====
  
-Pull request is at https://github.com/php/php-src/pull/453+PAtch is in my branch: https://github.com/bukka/php-src/compare/serialize_internal_api
rfc/internal_serialize_api.txt · Last modified: 2018/06/18 10:15 by cmb