xref: /PHP-5.6/UPGRADING.INTERNALS (revision dbe8c374)
1$Id$
2
3PHP 5.6 INTERNALS UPGRADE NOTES
4
51. Internal API changes
6  a. Addition of do_operation and compare object handlers
7  b. return_value_ptr now always available, RETVAL_ZVAL_FAST macros
8  c. POST data handling
9  d. Arginfo changes
10  e. tsrm_virtual_cwd.h moved to zend_virtual_cwd.h
11  f. empty strings are interned
12  g. Additional str_* APIs
13  h. Addition of zend_hash_reindex
14  i. Addition of zend_hash_splice
15  j. Unserialization of manipulated object strings
16  k. Removal of IS_CONSTANT_ARRAY and IS_CONSTANT_INDEX hack
17
182. Build system changes
19  a. Unix build system changes
20  b. Windows build system changes
21
22
23========================
241. Internal API changes
25========================
26
27  a. Addition of do_operation and compare object handlers
28
29  Two new object handlers have been added:
30
31    do_operation:
32    typedef int (*zend_object_do_operation_t)(
33        zend_uchar opcode, zval *result, zval *op1, zval *op2 TSRMLS_DC
34    );
35
36    compare:
37    typedef int (*zend_object_compare_zvals_t)(
38        zval *result, zval *op1, zval *op2 TSRMLS_DC
39    );
40
41  The first handler is used to overload arithmetic operations. The first
42  argument specifies the opcode of the operator, result is the target zval,
43  op1 the first operand and op2 the second operand. For unary operations
44  op2 is NULL. If the handler returns FAILURE PHP falls back to the default
45  behavior for the operation.
46
47  The second handler is used to perform comparison operations with
48  non-objects. The value written into result must be an IS_LONG with value
49  -1 (smaller), 0 (equal) or 1 (greater). The return value is a SUCCESS/FAILURE
50  return code. The difference between this handler and compare_objects is
51  that it will be triggered for comparisons with non-objects and objects of
52  different types. It takes precedence over compare_objects.
53
54  Further docs in the RFC: https://wiki.php.net/rfc/operator_overloading_gmp
55
56  b. return_value_ptr now always available, RETVAL_ZVAL_FAST macros
57
58  The return_value_ptr argument to internal functions is now always set.
59  Previously it was only available for functions returning by-reference.
60  return_value_ptr can now be used to return zvals without copying them.
61  For this purpose two new macros are provided:
62
63      RETVAL_ZVAL_FAST(zv); /* analog to RETVAL_ZVAL(zv, 1, 0) */
64      RETURN_ZVAL_FAST(zv); /* analog to RETURN_ZVAL(zv, 1, 0) */
65
66  The macros behave similarly to the non-FAST variants with copy=1 and
67  dtor=0, but will try to return the zval without making a copy by utilizing
68  return_value_ptr.
69
70  c. POST data handling
71
72  The sapi_request_info's members post_data, post_data_len and raw_post_data as
73  well as raw_post_data_len have been replaced with a temp PHP stream
74  request_body.
75
76  The recommended way to access raw POST data is to open and use a php://input
77  stream wrapper.  It is safe to be used concurrently and more than once.
78
79  d. Arginfo changes
80
81  The pass_rest_by_reference argument of the ZEND_BEGIN_ARG_INFO and
82  ZEND_BEGIN_ARG_INFO_EX() is no longer used. The value passed to it is ignored.
83
84  Instead a variadic argument is created using ZEND_ARG_VARIADIC_INFO():
85
86      ZEND_ARG_VARIADIC_INFO(0, name) /* pass rest by value */
87      ZEND_ARG_VARIADIC_INFO(1, name) /* pass rest by reference */
88      ZEND_ARG_VARIADIC_INFO(ZEND_SEND_PREFER_REF, name)
89          /* pass rest by prefer-ref */
90
91  ZEND_ARG_VARIADIC_INFO() should only be used for the last argument.
92
93  The following changes were applied to the zend_arg_info struct:
94
95       typedef struct _zend_arg_info {
96           const char *class_name;
97           zend_uint class_name_len;
98           zend_uchar type_hint;
99      +    zend_uchar pass_by_reference;
100           zend_bool allow_null;
101      -    zend_bool pass_by_reference;
102      +    zend_bool is_variadic;
103       } zend_arg_info;
104
105  The following changes were applied to the zend_internal_function_info struct:
106
107       typedef struct _zend_internal_function_info {
108           zend_uint required_num_args;
109           zend_uchar _type_hint;
110           zend_bool return_reference;
111      -    zend_bool pass_rest_by_reference;
112      +    zend_bool _allow_null;
113      +    zend_bool _is_variadic;
114       } zend_internal_function_info;
115
116  The CHECK_ARG_SEND_TYPE(), ARG_MUST_BE_SENT_BY_REF(),
117  ARG_SHOULD_BE_SENT_BY_REF() and ARG_MAY_BE_SENT_BY_REF() macros now assume
118  that the argument passed to them is a zend_function* and that it is non-NULL.
119
120  e. tsrm_virtual_cwd.h moved to zend_virtual_cwd.h
121
122  Memory allocation is now managed by emalloc/efree instead of malloc/free.
123
124  f. empty strings are interned
125
126  String created using STR_EMPTY_ALLOC() are now interned.
127  convert_to_string use STR_EMPTY_ALLOC() for zval when IS_NULL.
128  str_efree() shoud be preferred as efree() on such strings can cause memory
129  corruption.
130
131  g. Additional str_* APIs
132
133  In addition to the previously existing str_free() and str_efree() macros, the
134  following macros have been introduced to simplify dealing with potentially
135  interned strings:
136
137      str_efree_rel(str)         - efree_rel() if not interned
138      str_erealloc(str, new_len) - erealloc() or emalloc+memcpy if interned
139      str_estrndup(str, len)     - estrndup() if not interned
140      str_strndup(str, len)      - zend_strndup() if not interned
141      str_hash(str, len)         - INTERNED_HASH(str) if interned,
142                                   zend_hash_func(str, len+1) otherwise
143
144  h. Addition of zend_hash_reindex
145
146  A zend_hash_reindex() function with the following prototype has been added:
147
148      void zend_hash_reindex(HashTable *ht, zend_bool only_integer_keys);
149
150  If only_integer_keys==0, this function will change all keys to be continuous,
151  zero-based integers in hash order. If only_integer_keys==1 the same will be
152  done only for keys that were already integers previously, while leaving
153  string keys alone.
154
155  i. Addition of zend_hash_splice
156
157  A zend_hash_splice() macro with the following prototype has been added:
158
159      void zend_hash_splice(
160          HashTable *ht, uint nDataSize, copy_ctor_func_t pCopyConstructor,
161          uint offset, uint length,
162          void **list, uint list_count, HashTable *removed
163      );
164
165  This function performs an in-place splice operation on a hashtable:
166
167  The elements between offset and offset+length are removed and the elements in
168  list[list_count] are inserted in their place. The removed elements can be
169  optionally collected into a hashtable.
170
171  This operation reindexes the hashtable, i.e. integer keys will be zero-based
172  and sequential, while string keys stay intact. The same applies to the
173  elements inserted into the removed HT.
174
175  As a side-effect of this addition the signature of the php_splice() function
176  changed:
177
178      void php_splice(
179          HashTable *ht, zend_uint offset, zend_uint length,
180          zval ***list, zend_uint list_count, HashTable *removed TSRMLS_DC
181      )
182
183  This function now directly forwards to zend_hash_splice(), resets the
184  IAP of ht (for compatibility with the previous implementation) and resets
185  CVs if the passed hashtable is the global symbol table.
186
187  j. Unserialization of manipulated object strings
188
189  Strings requiring unserialization of objects are now explicitly checked
190  whether the object they contain implements the Serializable interface.
191  This solves the situation where manipulated strings could be passed for
192  objects using Serializable to disallow serialization. An object
193  implementing Serializable will always start with "C:" in the serialized
194  string, all other objects are represented with starting "O:". Objects
195  implementing Serializable to disable serialization using
196  zend_class_unserialize_deny and zend_class_serialize_deny, when
197  instantiated from the serializer with a manipulated "O:" string at the
198  start, will most likely be defectively initialized. This is now
199  fixed at the appropriate place by checking for the presence of the
200  serialize callback in the class entry.
201
202  k. Removal of IS_CONSTANT_ARRAY and IS_CONSTANT_INDEX hack
203
204  These two #defines disappeared. Instead we have now IS_CONSTANT_AST which
205  covers also the functionality IS_CONSTANT_ARRAY bid and furthermore the
206  hack for marking zvals as constant index with IS_CONSTANT_INDEX is now
207  superfluous and so removed.
208  Please note that IS_CONSTANT_AST now has the same value than
209  IS_CONSTANT_ARRAY had.
210
211========================
2122. Build system changes
213========================
214
215  a. Unix build system changes
216    - The bison version check is now a blacklist instead of a whitelist.
217    - The bison binary can be specified through the YACC environment/configure
218      variable. Previously `bison` was assumed to be in $PATH.
219
220  b. Windows build system changes
221    - The configure option --enable-static-analyze isn't available anymore.
222      The new option was introduced --with-analyzer.
223    - It is possible to disable PGO for single extensions, to do that
224      define a global variable PHP_MYMODULE_PGO evaluating to false
225      inside config.w32
226